diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0cdc4dca..b8ab5bd4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,8 +33,15 @@ variables: APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py" CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py" -# Docker images + # Docker images BOT_DOCKER_IMAGE_TAG: ":latest" + # target test repo parameters + TEST_ENV_CONFIG_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/ci-test-runner-configs.git" + CI_AUTO_TEST_SCRIPT_REPO_URL: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/auto_test_script.git" + CI_AUTO_TEST_SCRIPT_REPO_BRANCH: "ci/v3.1" + + # Versioned esp-idf-doc env image to use for all document building jobs + ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v5" # When 'fetch' strategy is used, Gitlab removes untracked files before checking out # new revision. However if the new revision doesn't include some of the submodules @@ -363,7 +370,11 @@ build_docker: DOCKER_TMP_IMAGE_NAME: "idf_tmp_image" before_script: [] script: - - export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}" + - export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL + - if [ -n "$LOCAL_GITLAB_HTTPS_HOST" ]; then export LOCAL_CI_REPOSITORY_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@${LOCAL_GITLAB_HTTPS_HOST}/${CI_PROJECT_PATH}"; fi + - echo "Using repository at $LOCAL_CI_REPOSITORY_URL" + - export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${LOCAL_CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}" + # Build - docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/ # We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227. @@ -792,6 +803,18 @@ check_pipeline_triggered_by_label: # We want to make sure some jobs are always executed to detect regression. - test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1 +# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update +# the version returned by 'git describe' +check_version_tag: + extends: .check_job_template + only: + refs: + - /^v\d+\.\d+(\.\d+)?($|-)/ + variables: + - $BOT_TRIGGER_WITH_LABEL == null + script: + - (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || echo "ESP-IDF versions must be annotated tags." && exit 1 + assign_test: tags: - assign_test @@ -806,6 +829,11 @@ assign_test: variables: TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw" EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs" + INTEGRATION_CONFIG_OUTPUT_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs" + TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles" + ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py" + PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages" + PYTHON_VER: 3.7.7 artifacts: paths: - components/idf_test/*/CIConfigs @@ -824,11 +852,11 @@ assign_test: # assign unit test cases - python $TEST_FW_PATH/CIAssignUnitTest.py $IDF_PATH/components/idf_test/unit_test/TestCaseAll.yml $IDF_PATH/.gitlab-ci.yml $IDF_PATH/components/idf_test/unit_test/CIConfigs # clone test script to assign tests - - git clone $TEST_SCRIPT_REPOSITORY + - ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch + - ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH} - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script - - cd auto_test_script # assgin integration test cases - - python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin + - python ${ASSIGN_TEST_CASE_SCRIPT} -t $TEST_CASE_FILE_PATH -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin -o $INTEGRATION_CONFIG_OUTPUT_PATH .define_config_file_name: &define_config_file_name | JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}') @@ -870,7 +898,7 @@ assign_test: # first test if config file exists, if not exist, exit 0 - test -e $CONFIG_FILE || exit 0 # clone test env configs - - git clone $TEST_ENV_CONFIG_REPOSITORY + - ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO - python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs - cd $TEST_FW_PATH # run test @@ -924,24 +952,28 @@ assign_test: variables: LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF" LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA" - TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test" + TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles" MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml" CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs" + KNOWN_ISSUE_FILE: "${CI_PROJECT_DIR}/components/idf_test/integration_test/KnownIssues" + PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages" + CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py" + PYTHON_VER: 3.7.7 before_script: *add_gitlab_key_before script: - *define_config_file_name # first test if config file exists, if not exist, exit 0 - test -e $CONFIG_FILE || exit 0 # clone local test env configs - - git clone $TEST_ENV_CONFIG_REPOSITORY + - ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO - python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs - - cd ci-test-runner-configs # clone test bench - - git clone $TEST_SCRIPT_REPOSITORY + - ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch + - ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH} - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script - - cd auto_test_script + - cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues # run test - - python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH + - python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH nvs_compatible_test: <<: *test_template @@ -959,17 +991,17 @@ nvs_compatible_test: # first test if config file exists, if not exist, exit 0 - test -e $CONFIG_FILE || exit 0 # clone local test env configs - - git clone $TEST_ENV_CONFIG_REPOSITORY + - ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO - python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs - - cd ci-test-runner-configs # clone test bench - - git clone $TEST_SCRIPT_REPOSITORY - - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script - - cd auto_test_script + - ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch + - ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH} + - python $CHECKOUT_REF_SCRIPT auto_test_script "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles" # prepare nvs bins - - ./Tools/prepare_nvs_bin.sh + - cd auto_test_script + - ./tools/prepare_nvs_bin.sh # run test - - python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH + - python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH example_test_001: <<: *example_test_template @@ -1324,7 +1356,7 @@ IT_002: IT_003: <<: *test_template - parallel: 13 + parallel: 14 tags: - ESP32_IDF - SSC_T2_5 @@ -1344,7 +1376,7 @@ IT_005: IT_006: <<: *test_template - parallel: 8 + parallel: 13 tags: - ESP32_IDF - SSC_T1_6 @@ -1368,13 +1400,6 @@ IT_009: - ESP32_IDF - SSC_T1_3 -IT_010: - <<: *test_template - parallel: 4 - tags: - - ESP32_IDF - - SSC_T5_1 - IT_011: <<: *test_template tags: @@ -1414,6 +1439,7 @@ IT_015: IT_016: <<: *test_template + allow_failure: true tags: - ESP32_IDF - SSC_T50_MESH1 @@ -1426,7 +1452,6 @@ IT_017: IT_018: <<: *test_template - parallel: 2 tags: - ESP32_IDF - SSC_T1_9 diff --git a/components/bootloader/subproject/main/esp32.bootloader.ld b/components/bootloader/subproject/main/esp32.bootloader.ld index 1eb345f76..7bba4b469 100644 --- a/components/bootloader/subproject/main/esp32.bootloader.ld +++ b/components/bootloader/subproject/main/esp32.bootloader.ld @@ -40,6 +40,7 @@ SECTIONS *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */ *liblog.a:(.literal .text .literal.* .text.*) *libgcc.a:(.literal .text .literal.* .text.*) + *libbootloader_support.a:bootloader_clock.*(.literal.esp_clk_apb_freq .text.esp_clk_apb_freq) *libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*) *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*) *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*) @@ -52,6 +53,7 @@ SECTIONS *libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*) *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*) *libspi_flash.a:*.*(.literal .text .literal.* .text.*) + *libsoc.a:rtc_clk.*(.literal.rtc_clk_apb_freq_get .text.rtc_clk_apb_freq_get) *libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*) *libefuse.a:*.*(.literal .text .literal.* .text.*) *(.fini.literal) diff --git a/components/bootloader_support/include_bootloader/bootloader_flash.h b/components/bootloader_support/include_bootloader/bootloader_flash.h index 6ac724646..705fa44e9 100644 --- a/components/bootloader_support/include_bootloader/bootloader_flash.h +++ b/components/bootloader_support/include_bootloader/bootloader_flash.h @@ -22,6 +22,7 @@ #define FLASH_SECTOR_SIZE 0x1000 #define FLASH_BLOCK_SIZE 0x10000 +#define MMAP_ALIGNED_MASK 0x0000FFFF /* Provide a Flash API for bootloader_support code, that can be used from bootloader or app code. @@ -35,7 +36,7 @@ * * @return Number of free pages */ -uint32_t bootloader_mmap_get_free_pages(); +uint32_t bootloader_mmap_get_free_pages(void); /** * @brief Map a region of flash to data memory diff --git a/components/bootloader_support/include_bootloader/bootloader_sha.h b/components/bootloader_support/include_bootloader/bootloader_sha.h index 079a45791..48f65feed 100644 --- a/components/bootloader_support/include_bootloader/bootloader_sha.h +++ b/components/bootloader_support/include_bootloader/bootloader_sha.h @@ -26,7 +26,7 @@ typedef void *bootloader_sha256_handle_t; -bootloader_sha256_handle_t bootloader_sha256_start(); +bootloader_sha256_handle_t bootloader_sha256_start(void); void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len); diff --git a/components/bootloader_support/include_bootloader/bootloader_utility.h b/components/bootloader_support/include_bootloader/bootloader_utility.h index 31213a016..227a328a8 100644 --- a/components/bootloader_support/include_bootloader/bootloader_utility.h +++ b/components/bootloader_support/include_bootloader/bootloader_utility.h @@ -62,3 +62,17 @@ __attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootload * It is not recommended to call this function from an app (if called, the app will abort). */ __attribute__((noreturn)) void bootloader_reset(void); + +/** @brief Generates the digest of the data between offset & offset+length. + * + * This function should be used when the size of the data is larger than 3.2MB. + * The MMU capacity is 3.2MB (50 pages - 64KB each). This function generates the SHA-256 + * of the data in chunks of 3.2MB, considering the MMU capacity. + * + * @param[in] flash_offset Offset of the data in flash. + * @param[in] len Length of data in bytes. + * @param[out] digest Pointer to buffer where the digest is written, if ESP_OK is returned. + * + * @return ESP_OK if secure boot digest is generated successfully. + */ +esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest); \ No newline at end of file diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index 61d89f67e..77473d990 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -26,6 +26,8 @@ #include "esp_flash_partitions.h" #include "bootloader_flash.h" #include "bootloader_common.h" +#include "bootloader_config.h" +#include "bootloader_utility.h" #include "soc/gpio_periph.h" #include "soc/efuse_reg.h" #include "soc/rtc.h" @@ -186,22 +188,7 @@ esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t size = data.image_len; } // If image is type by data then hash is calculated for entire image. - const void *partition_bin = bootloader_mmap(address, size); - if (partition_bin == NULL) { - ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", address, size); - return ESP_FAIL; - } - bootloader_sha256_handle_t sha_handle = bootloader_sha256_start(); - if (sha_handle == NULL) { - bootloader_munmap(partition_bin); - return ESP_ERR_NO_MEM; - } - bootloader_sha256_data(sha_handle, partition_bin, size); - bootloader_sha256_finish(sha_handle, out_sha_256); - - bootloader_munmap(partition_bin); - - return ESP_OK; + return bootloader_sha256_flash_contents(address, size, out_sha_256); } int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata, bool *valid_two_otadata, bool max) @@ -247,13 +234,15 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t return ESP_ERR_INVALID_ARG; } - const uint8_t *image = bootloader_mmap(partition->offset, partition->size); + const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t); + const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t); + const uint8_t *image = bootloader_mmap(partition->offset, mmap_size); if (image == NULL) { - ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size); + ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size); return ESP_FAIL; } - memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t)); + memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t)); bootloader_munmap(image); if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) { diff --git a/components/bootloader_support/src/bootloader_sha.c b/components/bootloader_support/src/bootloader_sha.c index 1f7c1b493..aed31396b 100644 --- a/components/bootloader_support/src/bootloader_sha.c +++ b/components/bootloader_support/src/bootloader_sha.c @@ -21,7 +21,7 @@ // App version is a wrapper around mbedTLS SHA API #include -bootloader_sha256_handle_t bootloader_sha256_start() +bootloader_sha256_handle_t bootloader_sha256_start(void) { mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context)); if (!ctx) { @@ -53,6 +53,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest } mbedtls_sha256_free(ctx); free(handle); + handle = NULL; } #else // Bootloader version @@ -70,7 +71,7 @@ static const size_t BLOCK_WORDS = (64/sizeof(uint32_t)); // Words in final SHA256 digest static const size_t DIGEST_WORDS = (32/sizeof(uint32_t)); -bootloader_sha256_handle_t bootloader_sha256_start() +bootloader_sha256_handle_t bootloader_sha256_start(void) { // Enable SHA hardware ets_sha_enable(); diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index 99bae9455..e5c6dad5b 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -703,3 +703,39 @@ void bootloader_reset(void) abort(); /* This function should really not be called from application code */ #endif } + + +esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest) +{ + + if (digest == NULL) { + return ESP_ERR_INVALID_ARG; + } + + /* Handling firmware images larger than MMU capacity */ + uint32_t mmu_free_pages_count = bootloader_mmap_get_free_pages(); + bootloader_sha256_handle_t sha_handle = NULL; + + sha_handle = bootloader_sha256_start(); + if (sha_handle == NULL) { + return ESP_ERR_NO_MEM; + } + + while (len > 0) { + uint32_t mmu_page_offset = ((flash_offset & MMAP_ALIGNED_MASK) != 0) ? 1 : 0; /* Skip 1st MMU Page if it is already populated */ + uint32_t partial_image_len = MIN(len, ((mmu_free_pages_count - mmu_page_offset) * SPI_FLASH_MMU_PAGE_SIZE)); /* Read the image that fits in the free MMU pages */ + + const void * image = bootloader_mmap(flash_offset, partial_image_len); + if (image == NULL) { + bootloader_sha256_finish(sha_handle, NULL); + return ESP_FAIL; + } + bootloader_sha256_data(sha_handle, image, partial_image_len); + bootloader_munmap(image); + + flash_offset += partial_image_len; + len -= partial_image_len; + } + bootloader_sha256_finish(sha_handle, digest); + return ESP_OK; +} \ No newline at end of file diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index b5d4bd154..032d9e74b 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -293,6 +293,7 @@ if(CONFIG_BT_ENABLED) if(CONFIG_BLE_MESH) list(APPEND COMPONENT_ADD_INCLUDEDIRS "esp_ble_mesh/mesh_common/include" + "esp_ble_mesh/mesh_common/tinycrypt/include" "esp_ble_mesh/mesh_core" "esp_ble_mesh/mesh_core/include" "esp_ble_mesh/mesh_core/storage" @@ -325,7 +326,21 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/btc/btc_ble_mesh_prov.c" "esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c" "esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c" - "esp_ble_mesh/mesh_common/mesh_aes_encrypt.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c" + "esp_ble_mesh/mesh_common/tinycrypt/src/utils.c" "esp_ble_mesh/mesh_common/mesh_atomic.c" "esp_ble_mesh/mesh_common/mesh_buf.c" "esp_ble_mesh/mesh_common/mesh_common.c" @@ -340,6 +355,7 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/mesh_core/cfg_cli.c" "esp_ble_mesh/mesh_core/cfg_srv.c" "esp_ble_mesh/mesh_core/crypto.c" + "esp_ble_mesh/mesh_core/fast_prov.c" "esp_ble_mesh/mesh_core/friend.c" "esp_ble_mesh/mesh_core/health_cli.c" "esp_ble_mesh/mesh_core/health_srv.c" @@ -355,12 +371,12 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/mesh_core/settings.c" "esp_ble_mesh/mesh_core/test.c" "esp_ble_mesh/mesh_core/transport.c" + "esp_ble_mesh/mesh_models/common/device_property.c" "esp_ble_mesh/mesh_models/client/client_common.c" "esp_ble_mesh/mesh_models/client/generic_client.c" "esp_ble_mesh/mesh_models/client/lighting_client.c" "esp_ble_mesh/mesh_models/client/sensor_client.c" "esp_ble_mesh/mesh_models/client/time_scene_client.c" - "esp_ble_mesh/mesh_models/server/device_property.c" "esp_ble_mesh/mesh_models/server/generic_server.c" "esp_ble_mesh/mesh_models/server/lighting_server.c" "esp_ble_mesh/mesh_models/server/sensor_server.c" diff --git a/components/bt/Kconfig b/components/bt/Kconfig index a0f63c84e..cfe594d32 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -89,6 +89,19 @@ menu Bluetooth default BTDM_CTRL_AUTO_LATENCY if BTDM_CONTROLLER_MODE_BTDM default n + config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT + bool "Legacy Authentication Vendor Specific Event Enable" + depends on BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM + default y + help + To protect from BIAS attack during Legacy authentication, + Legacy authentication Vendor specific event should be enabled + + + config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF + bool + default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM + default 0 config BTDM_CONTROLLER_BLE_MAX_CONN_EFF int @@ -1725,12 +1738,65 @@ if BLE_MESH option in the Bluetooth Controller section in menuconfig, which is "Scan Duplicate By Device Address and Advertising Data". - config BLE_MESH_ALLOC_FROM_PSRAM_FIRST - bool "BLE Mesh will first allocate memory from PSRAM" + choice BLE_MESH_MEM_ALLOC_MODE + prompt "Memory allocation strategy" + default BLE_MESH_MEM_ALLOC_MODE_INTERNAL + help + Allocation strategy for BLE Mesh stack, essentially provides ability to + allocate all required dynamic allocations from, + + - Internal DRAM memory only + - External SPIRAM memory only + - Either internal or external memory based on default malloc() + behavior in ESP-IDF + + Recommended mode here is always internal, since that is most preferred + from security perspective. But if application requirement does not allow + sufficient free internal memory then alternate mode can be selected. + + config BLE_MESH_MEM_ALLOC_MODE_INTERNAL + bool "Internal DRAM" + + config BLE_MESH_ALLOC_FROM_PSRAM_FIRST + bool "External SPIRAM" + depends on SPIRAM_SUPPORT + + config BLE_MESH_MEM_ALLOC_MODE_DEFAULT + bool "Default alloc mode" + depends on SPIRAM_SUPPORT + help + Enable this option to use the default memory allocation strategy when + external SPIRAM is enabled. See the SPIRAM options for more details. + + endchoice # BLE_MESH_MEM_ALLOC_MODE + + config BLE_MESH_FREERTOS_STATIC_ALLOC + bool "Enable FreeRTOS static allocation" + depends on SUPPORT_STATIC_ALLOCATION && SPIRAM_SUPPORT default n help - When this option is enabled, BLE Mesh stack will try to allocate memory - from PSRAM firstly. This will save the internal RAM if PSRAM exists. + Enable this option to use FreeRTOS static allocation APIs for BLE Mesh, + which provides the ability to use different dynamic memory (i.e. SPIRAM) + for FreeRTOS objects. + If this option is disabled, the FreeRTOS static allocation APIs will not + be used, and internal DRAM will be allocated for FreeRTOS objects. + + choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE + prompt "Memory allocation for FreeRTOS objects" + depends on BLE_MESH_FREERTOS_STATIC_ALLOC + help + Choose the memory to be used for FreeRTOS objects. + + config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL + bool "External SPIRAM" + depends on SPIRAM_SUPPORT + help + If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for + FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM + can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY + is enabled. See the SPIRAM options for more details. + + endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE config BLE_MESH_FAST_PROV bool "Enable BLE Mesh Fast Provisioning" @@ -1906,7 +1972,7 @@ if BLE_MESH advertising bearer. config BLE_MESH_NET_BUF_POOL_USAGE - bool "BLE Mesh net buffer pool usage tracking" + bool default y help Enable BLE Mesh net buffer pool tracking. This option is used to introduce another @@ -1964,7 +2030,7 @@ if BLE_MESH config BLE_MESH_SEQ_STORE_RATE int "How often the sequence number gets updated in storage" range 0 1000000 - default 6 + default 0 help This value defines how often the local sequence number gets updated in persistent storage (i.e. flash). e.g. a value of 100 means that the @@ -1979,7 +2045,7 @@ if BLE_MESH config BLE_MESH_RPL_STORE_TIMEOUT int "Minimum frequency that the RPL gets updated in storage" range 0 1000000 - default 5 + default 0 help This value defines in seconds how soon the RPL (Replay Protection List) gets written to persistent storage after a change occurs. If the node diff --git a/components/bt/bluedroid/api/esp_gap_bt_api.c b/components/bt/bluedroid/api/esp_gap_bt_api.c index 89e1df33f..b712e3ef6 100644 --- a/components/bt/bluedroid/api/esp_gap_bt_api.c +++ b/components/bt/bluedroid/api/esp_gap_bt_api.c @@ -213,7 +213,7 @@ esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr) int esp_bt_gap_get_bond_device_num(void) { if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { - return ESP_FAIL; + return ESP_ERR_INVALID_STATE; } return btc_storage_get_num_bt_bond_devices(); } @@ -221,7 +221,6 @@ int esp_bt_gap_get_bond_device_num(void) esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list) { int ret; - int dev_num_total; if (dev_num == NULL || dev_list == NULL) { return ESP_ERR_INVALID_ARG; @@ -231,12 +230,7 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list) return ESP_ERR_INVALID_STATE; } - dev_num_total = btc_storage_get_num_bt_bond_devices(); - if (*dev_num > dev_num_total) { - *dev_num = dev_num_total; - } - - ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num); + ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num); return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } diff --git a/components/bt/bluedroid/api/esp_gatt_common_api.c b/components/bt/bluedroid/api/esp_gatt_common_api.c index 9b532953f..b1bb5d877 100644 --- a/components/bt/bluedroid/api/esp_gatt_common_api.c +++ b/components/bt/bluedroid/api/esp_gatt_common_api.c @@ -50,9 +50,33 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu) #if (BLE_INCLUDED == TRUE) extern uint16_t L2CA_GetFreePktBufferNum_LE(void); +/** + * @brief This function is called to get currently sendable packets number on controller, + * the function is called only in BLE running core and single connection now. + * + * @return + * sendable packets number on controller + * + */ -uint16_t esp_ble_get_sendable_packets_num () +uint16_t esp_ble_get_sendable_packets_num (void) { return L2CA_GetFreePktBufferNum_LE(); } + +/** + * @brief This function is used to query the number of available buffers for the current connection. + * When you need to query the current available buffer number, it is recommended to use this API. + * @param[in] conn_id: current connection id. + * + * @return + * Number of available buffers for the current connection + * + */ +extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id); +uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid) +{ + return L2CA_GetCurFreePktBufferNum_LE(connid); +} + #endif diff --git a/components/bt/bluedroid/api/esp_gattc_api.c b/components/bt/bluedroid/api/esp_gattc_api.c index 578916e5f..e1e55ef1a 100644 --- a/components/bt/bluedroid/api/esp_gattc_api.c +++ b/components/bt/bluedroid/api/esp_gattc_api.c @@ -431,6 +431,9 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if, arg.write_char.value = value; arg.write_char.write_type = write_type; arg.write_char.auth_req = auth_req; + if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){ + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL); + } return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } @@ -462,6 +465,10 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if, arg.write_descr.write_type = write_type; arg.write_descr.auth_req = auth_req; + if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){ + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL); + } + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } diff --git a/components/bt/bluedroid/api/esp_gatts_api.c b/components/bt/bluedroid/api/esp_gatts_api.c index 80d89b30b..c8f2c60a9 100644 --- a/components/bt/bluedroid/api/esp_gatts_api.c +++ b/components/bt/bluedroid/api/esp_gatts_api.c @@ -274,6 +274,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, arg.send_ind.value_len = value_len; arg.send_ind.value = value; + if(need_confirm == false){ + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL); + } return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } diff --git a/components/bt/bluedroid/api/esp_spp_api.c b/components/bt/bluedroid/api/esp_spp_api.c index 05157ebdc..e8f7487e3 100644 --- a/components/bt/bluedroid/api/esp_spp_api.c +++ b/components/bt/bluedroid/api/esp_spp_api.c @@ -154,6 +154,17 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask, return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +esp_err_t esp_spp_stop_srv(void) +{ + btc_msg_t msg; + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_SPP; + msg.act = BTC_SPP_ACT_STOP_SRV; + + return (btc_transfer_context(&msg, NULL, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data) { diff --git a/components/bt/bluedroid/api/include/api/esp_a2dp_api.h b/components/bt/bluedroid/api/include/api/esp_a2dp_api.h index 3b002a405..96aad492b 100644 --- a/components/bt/bluedroid/api/include/api/esp_a2dp_api.h +++ b/components/bt/bluedroid/api/include/api/esp_a2dp_api.h @@ -76,7 +76,7 @@ typedef enum { /// A2DP media control commands typedef enum { - ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */ + ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< Not for application use, use inside stack only. */ ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */ ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */ ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */ diff --git a/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h b/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h index 1156f10da..627cb0418 100644 --- a/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h @@ -174,6 +174,7 @@ typedef enum { ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */ ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */ ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */ + ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< remove bond device complete event */ ESP_BT_GAP_EVT_MAX, } esp_bt_gap_cb_event_t; @@ -271,6 +272,14 @@ typedef union { struct key_req_param { esp_bd_addr_t bda; /*!< remote bluetooth device address*/ } key_req; /*!< passkey request parameter struct */ + + /** + * @brief ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT + */ + struct bt_remove_bond_dev_cmpl_evt_param { + esp_bd_addr_t bda; /*!< remote bluetooth device address*/ + esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */ + }remove_bond_dev_cmpl; /*!< Event parameter of ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT */ } esp_bt_gap_cb_param_t; /** diff --git a/components/bt/bluedroid/api/include/api/esp_gatt_common_api.h b/components/bt/bluedroid/api/include/api/esp_gatt_common_api.h index bee2c28f0..447a26bd9 100644 --- a/components/bt/bluedroid/api/include/api/esp_gatt_common_api.h +++ b/components/bt/bluedroid/api/include/api/esp_gatt_common_api.h @@ -46,6 +46,7 @@ extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu); #if (BLE_INCLUDED == TRUE) extern uint16_t esp_ble_get_sendable_packets_num (void); +extern uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid); #endif #ifdef __cplusplus diff --git a/components/bt/bluedroid/api/include/api/esp_spp_api.h b/components/bt/bluedroid/api/include/api/esp_spp_api.h index 9628a1ed0..9e6576424 100644 --- a/components/bt/bluedroid/api/include/api/esp_spp_api.h +++ b/components/bt/bluedroid/api/include/api/esp_spp_api.h @@ -57,6 +57,7 @@ typedef enum { */ typedef enum { ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */ + ESP_SPP_UNINIT_EVT = 1, /*!< When SPP is uninited, the event comes */ ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */ ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */ ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */ @@ -66,6 +67,7 @@ typedef enum { ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes, only for ESP_SPP_MODE_CB */ ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, only for ESP_SPP_MODE_CB */ ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */ + ESP_SPP_SRV_STOP_EVT = 35, /*!< When SPP server stopped, the event comes */ } esp_spp_cb_event_t; @@ -80,6 +82,13 @@ typedef union { esp_spp_status_t status; /*!< status */ } init; /*!< SPP callback param of SPP_INIT_EVT */ + /** + * @brief SPP_UNINIT_EVT + */ + struct spp_uninit_evt_param { + esp_spp_status_t status; /*!< status */ + } uninit; /*!< SPP callback param of SPP_UNINIT_EVT */ + /** * @brief SPP_DISCOVERY_COMP_EVT */ @@ -128,6 +137,14 @@ typedef union { uint8_t sec_id; /*!< security ID used by this server */ bool use_co; /*!< TRUE to use co_rfc_data */ } start; /*!< SPP callback param of ESP_SPP_START_EVT */ + + /** + * @brief ESP_SPP_SRV_STOP_EVT + */ + struct spp_srv_stop_evt_param { + esp_spp_status_t status; /*!< status */ + } srv_stop; /*!< SPP callback param of ESP_SPP_SRV_STOP_EVT */ + /** * @brief ESP_SPP_CL_INIT_EVT */ @@ -273,6 +290,16 @@ esp_err_t esp_spp_disconnect(uint32_t handle); esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask, esp_spp_role_t role, uint8_t local_scn, const char *name); +/** + * @brief This function stops a SPP server + * When the server is stopped successfully, the callback is called + * with ESP_SPP_SRV_STOP_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_spp_stop_srv(void); /** * @brief This function is used to write data, only for ESP_SPP_MODE_CB. diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 99fd45cc8..81cdcf84a 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -61,7 +61,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status); #if (SMP_INCLUDED == TRUE) static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator); static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit); -static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type); +static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type, BOOLEAN sc_support); static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); #endif ///SMP_INCLUDED == TRUE static void bta_dm_local_name_cback(BD_ADDR bd_addr); @@ -610,7 +610,7 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data) } } -void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data) +void bta_dm_read_rssi(tBTA_DM_MSG *p_data) { if (p_data->rssi.read_rssi_cb != NULL) { BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb); @@ -756,11 +756,13 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data) /* Take the link down first, and mark the device for removal when disconnected */ for (int i = 0; i < bta_dm_cb.device_list.count; i++) { if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr) - && bta_dm_cb.device_list.peer_device[i].transport == transport) { +#if BLE_INCLUDED == TRUE + && bta_dm_cb.device_list.peer_device[i].transport == transport +#endif + ) { bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING; - btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport); - APPL_TRACE_DEBUG("%s:transport = %d", __func__, - bta_dm_cb.device_list.peer_device[i].transport); + btm_remove_acl( p_dev->bd_addr, transport); + APPL_TRACE_DEBUG("%s:transport = %d", __func__, transport); break; } } @@ -822,7 +824,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data) if (!BTM_SecAddDevice (p_dev->bd_addr, p_dc, p_dev->bd_name, p_dev->features, trusted_services_mask, p_lc, p_dev->key_type, p_dev->io_cap, - p_dev->pin_length)) { + p_dev->pin_length, p_dev->sc_support)) { APPL_TRACE_ERROR ("BTA_DM: Error adding device %08x%04x", (p_dev->bd_addr[0] << 24) + (p_dev->bd_addr[1] << 16) + (p_dev->bd_addr[2] << 8) + p_dev->bd_addr[3], (p_dev->bd_addr[4] << 8) + p_dev->bd_addr[5]); @@ -2784,7 +2786,8 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_ ** *******************************************************************************/ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, - BD_NAME bd_name, LINK_KEY key, UINT8 key_type) + BD_NAME bd_name, LINK_KEY key, UINT8 key_type, + BOOLEAN sc_support) { tBTA_DM_SEC sec_event; tBTA_DM_AUTH_CMPL *p_auth_cmpl; @@ -2806,6 +2809,7 @@ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, p_auth_cmpl->key_present = TRUE; p_auth_cmpl->key_type = key_type; p_auth_cmpl->success = TRUE; + p_auth_cmpl->sc_support = sc_support; memcpy(p_auth_cmpl->key, key, LINK_KEY_LEN); sec_event.auth_cmpl.fail_reason = HCI_SUCCESS; @@ -3083,6 +3087,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data) switch (p_msg->event) { case BTM_BL_CONN_EVT: + p_msg->sc_downgrade = p_data->conn.sc_downgrade; p_msg->is_new = TRUE; bdcpy(p_msg->bd_addr, p_data->conn.p_bda); #if BLE_INCLUDED == TRUE @@ -3309,6 +3314,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data) APPL_TRACE_DEBUG("%s info: 0x%x", __func__, bta_dm_cb.device_list.peer_device[i].info); if (bta_dm_cb.p_sec_cback) { + conn.link_up.sc_downgrade = p_data->acl_change.sc_downgrade; bta_dm_cb.p_sec_cback(BTA_DM_LINK_UP_EVT, (tBTA_DM_SEC *)&conn); } } else { diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 2eec142b7..3252ccaa5 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -206,11 +206,11 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb) } } -void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb) +void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb) { tBTA_DM_API_READ_RSSI *p_msg; if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) { - p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT; + p_msg->hdr.event = BTA_DM_API_READ_RSSI_EVT; memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR)); p_msg->transport = transport; p_msg->read_rssi_cb = cmpl_cb; @@ -586,6 +586,7 @@ void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey) } } #endif ///BT_SSP_INCLUDED == TRUE +#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** ** Function BTA_DmAddDevice @@ -599,7 +600,8 @@ void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey) *******************************************************************************/ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted, - UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length) + UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length, + UINT8 sc_support) { tBTA_DM_API_ADD_DEVICE *p_msg; @@ -612,6 +614,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key, p_msg->tm = trusted_mask; p_msg->is_trusted = is_trusted; p_msg->io_cap = io_cap; + p_msg->sc_support = sc_support; if (link_key) { p_msg->link_key_known = TRUE; @@ -662,7 +665,6 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport) return BTA_SUCCESS; } -#endif ///SMP_INCLUDED == TRUE /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index eef04e7d7..d8a2e4ec2 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -159,7 +159,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */ bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */ bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */ - bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */ + bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */ bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */ }; diff --git a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h index 23c2d6328..9f857b14b 100644 --- a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h @@ -155,7 +155,7 @@ enum { BTA_DM_API_REMOVE_DEVICE_EVT, BTA_DM_API_UPDATE_WHITE_LIST_EVT, BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT, - BTA_DM_API_BLE_READ_RSSI_EVT, + BTA_DM_API_READ_RSSI_EVT, BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT, BTA_DM_MAX_EVT }; @@ -384,6 +384,7 @@ typedef struct { UINT8 new_role; BD_ADDR bd_addr; UINT8 hci_status; + BOOLEAN sc_downgrade; #if BLE_INCLUDED == TRUE UINT16 handle; tBT_TRANSPORT transport; @@ -425,6 +426,7 @@ typedef struct { BD_NAME bd_name; UINT8 features[BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)]; UINT8 pin_length; + UINT8 sc_support; } tBTA_DM_API_ADD_DEVICE; /* data type for BTA_DM_API_REMOVE_ACL_EVT */ @@ -1224,7 +1226,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data); extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data); extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data); extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data); -extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data); +extern void bta_dm_read_rssi(tBTA_DM_MSG *p_data); extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data); extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data); diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/bluedroid/bta/gatt/bta_gattc_api.c index 9a43c5588..bd5335a57 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_api.c @@ -31,7 +31,7 @@ #include "bta/bta_sys.h" #include "bta/bta_gatt_api.h" #include "bta_gattc_int.h" - +#include "stack/l2c_api.h" /***************************************************************************** ** Constants *****************************************************************************/ @@ -603,6 +603,10 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id, memcpy(p_buf->p_value, p_value, len); } + if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){ + l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL); + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL); + } bta_sys_sendmsg(p_buf); } return; @@ -650,6 +654,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id, memcpy(p_buf->p_value, p_data->p_value, p_data->len); } + if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){ + l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL); + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL); + } bta_sys_sendmsg(p_buf); } return; diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c index 40274aa90..05929c8aa 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_act.c @@ -35,6 +35,7 @@ #include "stack/btm_ble_api.h" #include #include "osi/allocator.h" +#include "stack/l2c_api.h" static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range); static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req, @@ -672,6 +673,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) p_msg->api_indicate.len, p_msg->api_indicate.value); } else { + l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL); status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific, p_msg->api_indicate.attr_id, p_msg->api_indicate.len, diff --git a/components/bt/bluedroid/bta/gatt/bta_gatts_api.c b/components/bt/bluedroid/bta/gatt/bta_gatts_api.c index 8f1882503..d569a7001 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gatts_api.c +++ b/components/bt/bluedroid/bta/gatt/bta_gatts_api.c @@ -31,7 +31,7 @@ #include "bta/bta_gatt_api.h" #include "bta_gatts_int.h" #include "osi/allocator.h" - +#include "stack/l2c_api.h" /***************************************************************************** ** Constants *****************************************************************************/ @@ -426,6 +426,11 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat memcpy(p_buf->value, p_data, data_len); } + + if(need_confirm == false){ + l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL); + l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL); + } bta_sys_sendmsg(p_buf); } return; diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index c580433ba..c1d2c1079 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -769,6 +769,7 @@ typedef struct { tBLE_ADDR_TYPE addr_type; /* Peer device address type */ tBT_DEVICE_TYPE dev_type; UINT8 auth_mode; + BOOLEAN sc_support; /* Denotes if peer device supported secure connection while bonding. */ } tBTA_DM_AUTH_CMPL; @@ -784,6 +785,7 @@ typedef struct { /* Structure associated with BTA_DM_LINK_UP_EVT */ typedef struct { + BOOLEAN sc_downgrade; /* Security downgrade state. */ BD_ADDR bd_addr; /* BD address peer device. */ #if BLE_INCLUDED == TRUE tBTA_TRANSPORT link_type; @@ -924,7 +926,7 @@ typedef union { tBTA_DM_PIN_REQ pin_req; /* PIN request. */ tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */ tBTA_DM_AUTHORIZE authorize; /* Authorization request. */ - tBTA_DM_LINK_UP link_up; /* ACL connection down event */ + tBTA_DM_LINK_UP link_up; /* ACL connection up event */ tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */ tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */ tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */ @@ -1455,7 +1457,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb); -extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb); +extern void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb); /******************************************************************************* ** @@ -1684,7 +1686,8 @@ extern void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passke extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted, UINT8 key_type, - tBTA_IO_CAP io_cap, UINT8 pin_length); + tBTA_IO_CAP io_cap, UINT8 pin_length, + UINT8 sc_support); /******************************************************************************* ** @@ -2293,8 +2296,8 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l ** Returns None ** *******************************************************************************/ -extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, - BD_ADDR device_info, +extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, + BD_ADDR device_info, tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback); /******************************************************************************* diff --git a/components/bt/bluedroid/bta/include/bta/bta_jv_api.h b/components/bt/bluedroid/bta/include/bta/bta_jv_api.h index bf23aab4e..7bd6195c5 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_jv_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_jv_api.h @@ -129,11 +129,13 @@ typedef UINT8 tBTA_JV_CONN_STATE; /* Java I/F callback events */ /* events received by tBTA_JV_DM_CBACK */ #define BTA_JV_ENABLE_EVT 0 /* JV enabled */ +#define BTA_JV_DISABLE_EVT 1 /* JV disabled */ #define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */ #define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */ #define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */ #define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */ /* events received by tBTA_JV_L2CAP_CBACK */ +#if BTA_JV_L2CAP_INCLUDED #define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */ #define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */ #define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */ @@ -144,6 +146,7 @@ typedef UINT8 tBTA_JV_CONN_STATE; #define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/ #define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/ #define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */ +#endif /* BTA_JV_L2CAP_INCLUDED */ /* events received by tBTA_JV_RFCOMM_CBACK */ #define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */ @@ -155,7 +158,8 @@ typedef UINT8 tBTA_JV_CONN_STATE; #define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */ #define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/ #define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */ -#define BTA_JV_MAX_EVT 35 /* max number of JV events */ +#define BTA_JV_FREE_SCN_EVT 35 /* FREE an SCN */ +#define BTA_JV_MAX_EVT 36 /* max number of JV events */ typedef UINT16 tBTA_JV_EVT; @@ -178,6 +182,7 @@ typedef struct { UINT32 handle; /* The SDP handle */ } tBTA_JV_CREATE_RECORD; +#if BTA_JV_L2CAP_INCLUDED /* data associated with BTA_JV_L2CAP_OPEN_EVT */ typedef struct { tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ @@ -186,18 +191,6 @@ typedef struct { INT32 tx_mtu; /* The transmit MTU */ } tBTA_JV_L2CAP_OPEN; -/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */ -typedef struct { - tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ - UINT32 handle; /* The connection handle */ - BD_ADDR rem_bda; /* The peer address */ - INT32 tx_mtu; /* The transmit MTU */ - void **p_p_cback; /* set them for new socket */ - void **p_user_data;/* set them for new socket */ - -} tBTA_JV_L2CAP_LE_OPEN; - - /* data associated with BTA_JV_L2CAP_CLOSE_EVT */ typedef struct { tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ @@ -255,6 +248,22 @@ typedef struct { BOOLEAN cong; /* congestion status */ } tBTA_JV_L2CAP_WRITE; +/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */ +typedef struct { + tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ + UINT32 handle; /* The connection handle */ + BD_ADDR rem_bda; /* The peer address */ + INT32 tx_mtu; /* The transmit MTU */ + void **p_p_cback; /* set them for new socket */ + void **p_user_data;/* set them for new socket */ + +} tBTA_JV_L2CAP_LE_OPEN; + +/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */ +typedef struct { + UINT32 handle; /* The connection handle */ + BT_HDR *p_buf; /* The incoming data */ +} tBTA_JV_LE_DATA_IND; /* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */ typedef struct { @@ -265,6 +274,7 @@ typedef struct { UINT16 len; /* The length of the data written. */ BOOLEAN cong; /* congestion status */ } tBTA_JV_L2CAP_WRITE_FIXED; +#endif /* BTA_JV_L2CAP_INCLUDED */ /* data associated with BTA_JV_RFCOMM_OPEN_EVT */ typedef struct { @@ -272,6 +282,7 @@ typedef struct { UINT32 handle; /* The connection handle */ BD_ADDR rem_bda; /* The peer address */ } tBTA_JV_RFCOMM_OPEN; + /* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */ typedef struct { tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ @@ -280,7 +291,6 @@ typedef struct { BD_ADDR rem_bda; /* The peer address */ } tBTA_JV_RFCOMM_SRV_OPEN; - /* data associated with BTA_JV_RFCOMM_CLOSE_EVT */ typedef struct { tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ @@ -304,19 +314,13 @@ typedef struct { UINT8 sec_id; /* security ID used by this client */ BOOLEAN use_co; /* TRUE to use co_rfc_data */ } tBTA_JV_RFCOMM_CL_INIT; + /*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */ typedef struct { UINT32 handle; /* The connection handle */ BT_HDR *p_buf; /* The incoming data */ } tBTA_JV_DATA_IND; -/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */ -typedef struct { - UINT32 handle; /* The connection handle */ - BT_HDR *p_buf; /* The incoming data */ -} tBTA_JV_LE_DATA_IND; - - /* data associated with BTA_JV_RFCOMM_CONG_EVT */ typedef struct { tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ @@ -356,6 +360,23 @@ typedef struct { tBTA_JV_CONN_STATE state; /* JV connection stata */ } tBTA_JV_NOTIFY_PM_STATE_CHANGE; +/* indicate server at which status */ +typedef enum { + BTA_JV_SERVER_START_FAILED, + BTA_JV_SERVER_RUNNING, + BTA_JV_SERVER_STATUS_MAX, +} tBTA_JV_SERVER_STATUS; + +typedef struct { + tBTA_JV_SERVER_STATUS server_status; + UINT32 slot_id; +}tBTA_JV_FREE_SCN_USER_DATA; + +/* data associated with BTA_JV_FREE_SCN_EVT */ +typedef struct { + tBTA_JV_STATUS status; /* Status of the operation */ + tBTA_JV_SERVER_STATUS server_status; +} tBTA_JV_FREE_SCN; /* union of data associated with JV callback */ typedef union { @@ -365,6 +386,7 @@ typedef union { UINT8 scn; /* BTA_JV_GET_SCN_EVT */ UINT16 psm; /* BTA_JV_GET_PSM_EVT */ tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */ +#if BTA_JV_L2CAP_INCLUDED tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */ tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */ tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */ @@ -372,6 +394,7 @@ typedef union { tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */ tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */ tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */ +#endif /* BTA_JV_L2CAP_INCLUDED */ tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */ tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */ tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */ @@ -382,9 +405,12 @@ typedef union { tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */ tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT BTA_JV_RFCOMM_DATA_IND_EVT */ - tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */ + tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */ +#if BTA_JV_L2CAP_INCLUDED tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */ + tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */ tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */ +#endif } tBTA_JV; /* JAVA DM Interface callback */ @@ -393,8 +419,10 @@ typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d /* JAVA RFCOMM interface callback */ typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data); +#if BTA_JV_L2CAP_INCLUDED /* JAVA L2CAP interface callback */ typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data); +#endif /* BTA_JV_L2CAP_INCLUDED */ /* JV configuration structure */ typedef struct { @@ -424,12 +452,25 @@ extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback); ** ** Function BTA_JvDisable ** -** Description Disable the Java I/F +** Description Disable the Java I/F. When the enable +** operation is complete the callback function will be +** called with a BTA_JV_DISABLE_EVT. ** ** Returns void ** *******************************************************************************/ -extern void BTA_JvDisable(void); +extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback); + +/******************************************************************************* +** +** Function BTA_JvFree +** +** Description Free JV configuration +** +** Returns void +** +*******************************************************************************/ +extern void BTA_JvFree(void); /******************************************************************************* ** @@ -484,12 +525,17 @@ extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, ** ** Description This function frees a SCN/PSM that was used ** by an application running over RFCOMM or L2CAP. +** Parameters +** channel The channel to free +** conn_type one of BTA_JV_CONN_TYPE_ +** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM +** user_data indicate the RFCOMM server status ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type); +extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); /******************************************************************************* ** @@ -532,6 +578,7 @@ extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel, *******************************************************************************/ extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle); +#if BTA_JV_L2CAP_INCLUDED /******************************************************************************* ** ** Function BTA_JvL2capConnectLE @@ -739,6 +786,7 @@ extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id, extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id, tBTA_JV_L2CAP_CBACK *p_cback, UINT8 *p_data, UINT16 len, void *user_data); +#endif /* BTA_JV_L2CAP_INCLUDED */ /******************************************************************************* ** @@ -769,7 +817,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data); +extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); /******************************************************************************* ** @@ -786,9 +834,9 @@ extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data); ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, - tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session, - tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); +extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, + UINT8 local_scn, UINT8 max_session, + tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); /******************************************************************************* ** @@ -815,8 +863,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data); ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, - UINT8 *p_data, UINT16 len); +extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len); /******************************************************************************* ** @@ -843,7 +890,6 @@ extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size); ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -// extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id); extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data); /******************************************************************************* @@ -865,8 +911,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, U ** BTA_JV_CONN_CLOSE to remove in case of connection close! ** *******************************************************************************/ -extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, - tBTA_JV_CONN_STATE init_st); +extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st); /******************************************************************************* ** diff --git a/components/bt/bluedroid/bta/jv/bta_jv_act.c b/components/bt/bluedroid/bta/jv/bta_jv_act.c index ecef90b12..e6dba0d36 100644 --- a/components/bt/bluedroid/bta/jv/bta_jv_act.c +++ b/components/bt/bluedroid/bta/jv/bta_jv_act.c @@ -48,6 +48,7 @@ #if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE) +#if BTA_JV_L2CAP_INCLUDED /* one of these exists for each client */ struct fc_client { struct fc_client *next_all_list; @@ -92,11 +93,10 @@ static void __attribute__((unused)) fc_init(void) pthread_once(&fc_init_once, fc_init_work); } - static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected, UINT16 reason, tBT_TRANSPORT ); static void fcchan_data_cbk(UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf); - +#endif /* BTA_JV_L2CAP_INCLUDED */ extern void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str); static inline void logu(const char *title, const uint8_t *p_uuid) @@ -114,6 +114,10 @@ static void bta_jv_pm_conn_idle(tBTA_JV_PM_CB *p_cb); static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE state); tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE new_st); +static int find_rfc_pcb(void *user_data, tBTA_JV_RFC_CB **cb, tBTA_JV_PCB **pcb); +static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle); +static void bta_jv_port_event_sr_cback(UINT32 code, UINT16 port_handle); +static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len, int type); /******************************************************************************* ** @@ -288,6 +292,12 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc BOOLEAN remove_server = FALSE; int close_pending = 0; + UINT8 used = 0, i, listen = 0; + tPORT_STATE port_state; + UINT32 event_mask = BTA_JV_RFC_EV_MASK; + UINT32 scn_num = (UINT32)p_cb->scn; + tBTA_JV evt_data; + if (!p_cb || !p_pcb) { APPL_TRACE_ERROR("bta_jv_free_sr_rfc_cb, p_cb or p_pcb cannot be null"); return BTA_JV_FAILURE; @@ -363,6 +373,57 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc } p_pcb->handle = 0; p_cb->curr_sess--; + + if ((p_cb->max_sess > 1) && + (p_cb->scn != 0) && + (p_cb->curr_sess == p_cb->max_sess - 1)) { + + for (i = 0; i < p_cb->max_sess; i++) { + if (p_cb->rfc_hdl[i] != 0) { + p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1]; + if (p_pcb->state == BTA_JV_ST_SR_LISTEN) { + listen++; + } + used++; + } + } + APPL_TRACE_DEBUG("%s max_sess=%d used:%d curr_sess:%d, listen:%d si:%d", + __func__, p_cb->max_sess, used, p_cb->curr_sess, listen, si); + if (used < p_cb->max_sess && + listen == 0 && + 0 <= si && + si < BTA_JV_MAX_RFC_SR_SESSION) { + /* make sure the server has a listen port */ + if ((RFCOMM_CreateConnection(p_cb->sec_id, p_cb->scn, TRUE, + BTA_JV_DEF_RFC_MTU, (UINT8 *)bd_addr_any, &(p_cb->rfc_hdl[si]), bta_jv_port_mgmt_sr_cback) == PORT_SUCCESS) && + (p_cb->rfc_hdl[si] != 0)) { + p_cb->curr_sess++; + p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[si] - 1]; + p_pcb->state = BTA_JV_ST_SR_LISTEN; + p_pcb->port_handle = p_cb->rfc_hdl[si]; + // p_pcb->user_data = p_pcb_open->user_data; + + PORT_ClearKeepHandleFlag(p_pcb->port_handle); + PORT_SetEventCallback(p_pcb->port_handle, bta_jv_port_event_sr_cback); + PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback); + PORT_SetEventMask(p_pcb->port_handle, event_mask); + PORT_GetState(p_pcb->port_handle, &port_state); + + port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT); + + PORT_SetState(p_pcb->port_handle, &port_state); + p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si); + APPL_TRACE_DEBUG("%s: p_pcb->handle:0x%x, curr_sess:%d", __func__, + p_pcb->handle, p_cb->curr_sess); + + evt_data.rfc_srv_open.handle = 0; + evt_data.rfc_srv_open.new_listen_handle = p_pcb->handle; + evt_data.rfc_srv_open.status = BTA_JV_SUCCESS; + p_pcb->user_data = p_cb->p_cback(BTA_JV_RFCOMM_SRV_OPEN_EVT, &evt_data, (void *)scn_num); + } + } + } + if (p_cb->curr_sess == 0) { p_cb->scn = 0; bta_jv_free_sec_id(&p_cb->sec_id); @@ -377,6 +438,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc return status; } +#if BTA_JV_L2CAP_INCLUDED /******************************************************************************* ** ** Function bta_jv_free_l2c_cb @@ -402,6 +464,7 @@ tBTA_JV_STATUS bta_jv_free_l2c_cb(tBTA_JV_L2C_CB *p_cb) p_cb->p_cback = NULL; return status; } +#endif /* BTA_JV_L2CAP_INCLUDED */ /******************************************************************************* ** @@ -456,10 +519,9 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle) } } - APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, " - "app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id); - APPL_TRACE_API("%s, bd_counter = %d, " - "appid_counter = %d", __func__, bd_counter, appid_counter); + APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id); + APPL_TRACE_API("%s, bd_counter = %d, appid_counter = %d", __func__, bd_counter, appid_counter); + if (bd_counter > 1) { bta_jv_pm_conn_idle(&bta_jv_cb.pm_cb[i]); } @@ -478,14 +540,15 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle) tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]); if (p_pcb) { if (NULL == p_pcb->p_pm_cb) { - APPL_TRACE_WARNING("%s(jv_handle:" - " 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to " - "pm_cb?", __func__, jv_handle, p_pcb->port_handle, i); + APPL_TRACE_WARNING("%s(jv_handle: 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to pm_cb?", + __func__, jv_handle, p_pcb->port_handle, i); } p_cb = &p_pcb->p_pm_cb; } } - } else { + } +#if BTA_JV_L2CAP_INCLUDED + else { if (jv_handle < BTA_JV_MAX_L2C_CONN) { tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle]; if (NULL == p_l2c_cb->p_pm_cb) { @@ -495,6 +558,8 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle) p_cb = &p_l2c_cb->p_pm_cb; } } +#endif /* BTA_JV_L2CAP_INCLUDED */ + if (p_cb) { *p_cb = NULL; status = BTA_JV_SUCCESS; @@ -537,7 +602,9 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P break; } } - } else { + } +#if BTA_JV_L2CAP_INCLUDED + else { /* use jv handle for l2cap bd address retrieval */ for (j = 0; j < BTA_JV_MAX_L2C_CONN; j++) { if (jv_handle == bta_jv_cb.l2c_cb[j].handle) { @@ -552,6 +619,7 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P } } } +#endif /* BTA_JV_L2CAP_INCLUDED */ APPL_TRACE_API("bta_jv_alloc_set_pm_profile_cb(handle 0x%2x, app_id %d): " "idx: %d, (BTA_JV_PM_MAX_NUM: %d), pp_cb: %p", jv_handle, app_id, i, BTA_JV_PM_MAX_NUM, (void *)pp_cb); @@ -634,7 +702,6 @@ BOOLEAN bta_jv_check_psm(UINT16 psm) } } return ret; - } /******************************************************************************* @@ -673,7 +740,12 @@ void bta_jv_enable(tBTA_JV_MSG *p_data) *******************************************************************************/ void bta_jv_disable (tBTA_JV_MSG *p_data) { - UNUSED(p_data); + tBTA_JV_STATUS evt_data; + evt_data = BTA_JV_SUCCESS; + // UNUSED(p_data); + if (p_data->disable.p_cback) { + p_data->disable.p_cback(BTA_JV_DISABLE_EVT, (tBTA_JV *)&evt_data, NULL); + } } @@ -782,7 +854,16 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data) *******************************************************************************/ void bta_jv_free_scn(tBTA_JV_MSG *p_data) { - UINT16 scn = p_data->free_channel.scn; + tBTA_JV_API_FREE_CHANNEL *fc = &(p_data->free_channel); + UINT16 scn = fc->scn; + tBTA_JV_FREE_SCN evt_data = { + .status = BTA_JV_SUCCESS, + .server_status = BTA_JV_SERVER_STATUS_MAX, + }; + + tBTA_JV_FREE_SCN_USER_DATA *user_data = NULL; + tBTA_JV_RFC_CB *p_cb = NULL; + tBTA_JV_PCB *p_pcb = NULL; switch (p_data->free_channel.type) { case BTA_JV_CONN_TYPE_RFCOMM: { @@ -802,6 +883,19 @@ void bta_jv_free_scn(tBTA_JV_MSG *p_data) default: break; } + + if (fc->user_data) { + user_data = (tBTA_JV_FREE_SCN_USER_DATA *)fc->user_data; + evt_data.server_status = user_data->server_status; + if (user_data->server_status == BTA_JV_SERVER_RUNNING && find_rfc_pcb((void *)user_data->slot_id, &p_cb, &p_pcb)) { + /* if call bta_jv_rfcomm_stop_server successfully, find_rfc_pcb shall return false */ + evt_data.status = BTA_JV_FAILURE; + } + + if (fc->p_cback) { + fc->p_cback(BTA_JV_FREE_SCN_EVT, (tBTA_JV *)&evt_data, (void *)user_data); + } + } } static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID *u) { @@ -1092,6 +1186,7 @@ void bta_jv_delete_record(tBTA_JV_MSG *p_data) } } +#if BTA_JV_L2CAP_INCLUDED /******************************************************************************* ** ** Function bta_jv_l2cap_client_cback @@ -1517,6 +1612,7 @@ void bta_jv_l2cap_write_fixed(tBTA_JV_MSG *p_data) ls->p_cback(BTA_JV_L2CAP_WRITE_FIXED_EVT, (tBTA_JV *)&evt_data, ls->user_data); } +#endif /* BTA_JV_L2CAP_INCLUDED */ /******************************************************************************* ** @@ -1596,6 +1692,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle) evt_data.rfc_close.async = TRUE; if (p_pcb->state == BTA_JV_ST_CL_CLOSING) { evt_data.rfc_close.async = FALSE; + evt_data.rfc_close.status = BTA_JV_SUCCESS; } //p_pcb->state = BTA_JV_ST_NONE; //p_pcb->cong = FALSE; @@ -1760,9 +1857,10 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data) tBTA_JV_API_RFCOMM_CLOSE *cc = &(p_data->rfcomm_close); tBTA_JV_RFC_CB *p_cb = NULL; tBTA_JV_PCB *p_pcb = NULL; - APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle); + tBTA_JV evt_data; + APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle); if (!cc->handle) { - APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null"); + APPL_TRACE_ERROR("%s, rfc handle is null", __func__); return; } @@ -1770,9 +1868,21 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data) if (!find_rfc_pcb(user_data, &p_cb, &p_pcb)) { return; } + if(cc->p_cback) { + evt_data.rfc_close.status = BTA_JV_SUCCESS; + evt_data.rfc_close.port_status = PORT_LOCAL_CLOSED; + evt_data.rfc_close.handle = cc->handle; + evt_data.rfc_close.async = TRUE; + if (p_pcb && (p_pcb->state == BTA_JV_ST_SR_LISTEN || + p_pcb->state == BTA_JV_ST_SR_OPEN || + p_pcb->state == BTA_JV_ST_CL_OPEN || + p_pcb->state == BTA_JV_ST_CL_OPENING)) { + evt_data.rfc_close.async = FALSE; + } + cc->p_cback(BTA_JV_RFCOMM_CLOSE_EVT, (tBTA_JV *)&evt_data, user_data); + } bta_jv_free_rfc_cb(p_cb, p_pcb); - APPL_TRACE_DEBUG("bta_jv_rfcomm_close: sec id in use:%d, rfc_cb in use:%d", - get_sec_id_used(), get_rfc_cb_used()); + APPL_TRACE_DEBUG("%s: sec id in use:%d, rfc_cb in use:%d", __func__, get_sec_id_used(), get_rfc_cb_used()); } /******************************************************************************* @@ -1976,6 +2086,8 @@ static tBTA_JV_PCB *bta_jv_add_rfc_port(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb p_pcb->handle, p_cb->curr_sess); } } else { + /* avoid p_pcb always points to the last element of rfc_hdl */ + p_pcb = p_pcb_open; APPL_TRACE_ERROR("bta_jv_add_rfc_port, cannot create new rfc listen port"); } } @@ -2351,7 +2463,7 @@ static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE } /**********************************************************************************************/ - +#if BTA_JV_L2CAP_INCLUDED static struct fc_channel *fcchan_get(uint16_t chan, char create) { struct fc_channel *t = fc_channels; @@ -2791,6 +2903,6 @@ extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data) fcclient_free(t); } } - +#endif /* BTA_JV_L2CAP_INCLUDED */ #endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE diff --git a/components/bt/bluedroid/bta/jv/bta_jv_api.c b/components/bt/bluedroid/bta/jv/bta_jv_api.c index 5430d36bc..ccbdadcb0 100644 --- a/components/bt/bluedroid/bta/jv/bta_jv_api.c +++ b/components/bt/bluedroid/bta/jv/bta_jv_api.c @@ -69,6 +69,16 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback) int i; APPL_TRACE_API( "BTA_JvEnable"); + +#if BTA_DYNAMIC_MEMORY == TRUE + /* Malloc buffer for JV configuration structure */ + p_bta_jv_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_jv_cfg->sdp_raw_size); + p_bta_jv_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_jv_cfg->sdp_db_size); + if (p_bta_jv_cfg->p_sdp_raw_data == NULL || p_bta_jv_cfg->p_sdp_db == NULL) { + return BTA_JV_NO_DATA; + } +#endif + if (p_cback && FALSE == bta_sys_is_register(BTA_ID_JV)) { memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB)); /* set handle to invalid value by default */ @@ -100,18 +110,39 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback) ** Returns void ** *******************************************************************************/ -void BTA_JvDisable(void) +void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback) { - BT_HDR *p_buf; + tBTA_JV_API_DISABLE *p_buf; APPL_TRACE_API( "BTA_JvDisable"); bta_sys_deregister(BTA_ID_JV); - if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) { - p_buf->event = BTA_JV_API_DISABLE_EVT; + if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) { + p_buf->hdr.event = BTA_JV_API_DISABLE_EVT; + p_buf->p_cback = p_cback; bta_sys_sendmsg(p_buf); } } +/******************************************************************************* +** +** Function BTA_JvFree +** +** Description Free JV configuration +** +** Returns void +** +*******************************************************************************/ +void BTA_JvFree(void) +{ +#if BTA_DYNAMIC_MEMORY == TRUE + /* Free buffer for JV configuration structure */ + osi_free(p_bta_jv_cfg->p_sdp_raw_data); + osi_free(p_bta_jv_cfg->p_sdp_db); + p_bta_jv_cfg->p_sdp_raw_data = NULL; + p_bta_jv_cfg->p_sdp_db = NULL; +#endif +} + /******************************************************************************* ** ** Function BTA_JvIsEnable @@ -199,12 +230,14 @@ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, INT32 channel) ** Parameters ** channel The channel to free ** conn_type one of BTA_JV_CONN_TYPE_ +** p_cback tBTA_JV_RFCOMM_CBACK is called with when server +** user_data indicate the RFCOMM server status ** ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type) +tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_FREE_CHANNEL *p_msg; @@ -214,6 +247,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type) p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT; p_msg->scn = channel; p_msg->type = conn_type; + p_msg->p_cback = p_cback; + p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; } @@ -310,6 +345,7 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle) return (status); } +#if BTA_JV_L2CAP_INCLUDED /******************************************************************************* ** ** Function BTA_JvL2capConnectLE @@ -823,6 +859,7 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i return (status); } +#endif /* BTA_JV_L2CAP_INCLUDED */ /******************************************************************************* ** @@ -868,19 +905,20 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, ** Function BTA_JvRfcommClose ** ** Description This function closes an RFCOMM connection -** +** When the connection is established or failed, +** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CLOSE_EVT ** Returns BTA_JV_SUCCESS, if the request is being processed. ** BTA_JV_FAILURE, otherwise. ** *******************************************************************************/ -tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data) +tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data) { tBTA_JV_STATUS status = BTA_JV_FAILURE; tBTA_JV_API_RFCOMM_CLOSE *p_msg; UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle); - APPL_TRACE_API( "BTA_JvRfcommClose"); + APPL_TRACE_API( "%s", __func__); if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback && si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] && (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL) { @@ -888,6 +926,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data) p_msg->handle = handle; p_msg->p_cb = &bta_jv_cb.rfc_cb[hi]; p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1]; + p_msg->p_cback = p_cback; p_msg->user_data = user_data; bta_sys_sendmsg(p_msg); status = BTA_JV_SUCCESS; diff --git a/components/bt/bluedroid/bta/jv/bta_jv_main.c b/components/bt/bluedroid/bta/jv/bta_jv_main.c index 9523d6e89..ec13d73ba 100644 --- a/components/bt/bluedroid/bta/jv/bta_jv_main.c +++ b/components/bt/bluedroid/bta/jv/bta_jv_main.c @@ -52,12 +52,14 @@ const tBTA_JV_ACTION bta_jv_action[] = { bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */ bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */ bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */ +#if BTA_JV_L2CAP_INCLUDED bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */ bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */ bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */ bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */ bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */ bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */ +#endif /* BTA_JV_L2CAP_INCLUDED */ bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */ bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */ bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */ @@ -66,11 +68,13 @@ const tBTA_JV_ACTION bta_jv_action[] = { bta_jv_rfcomm_write, /* BTA_JV_API_RFCOMM_WRITE_EVT */ bta_jv_set_pm_profile, /* BTA_JV_API_SET_PM_PROFILE_EVT */ bta_jv_change_pm_state, /* BTA_JV_API_PM_STATE_CHANGE_EVT */ +#if BTA_JV_L2CAP_INCLUDED bta_jv_l2cap_connect_le, /* BTA_JV_API_L2CAP_CONNECT_LE_EVT */ bta_jv_l2cap_start_server_le, /* BTA_JV_API_L2CAP_START_SERVER_LE_EVT */ bta_jv_l2cap_stop_server_le, /* BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT */ bta_jv_l2cap_write_fixed, /* BTA_JV_API_L2CAP_WRITE_FIXED_EVT */ bta_jv_l2cap_close_fixed, /* BTA_JV_API_L2CAP_CLOSE_FIXED_EVT */ +#endif /* BTA_JV_L2CAP_INCLUDED */ }; /******************************************************************************* diff --git a/components/bt/bluedroid/bta/jv/include/bta_jv_int.h b/components/bt/bluedroid/bta/jv/include/bta_jv_int.h index c25263314..eadbe1ce0 100644 --- a/components/bt/bluedroid/bta/jv/include/bta_jv_int.h +++ b/components/bt/bluedroid/bta/jv/include/bta_jv_int.h @@ -48,12 +48,14 @@ enum { BTA_JV_API_START_DISCOVERY_EVT, BTA_JV_API_CREATE_RECORD_EVT, BTA_JV_API_DELETE_RECORD_EVT, +#if BTA_JV_L2CAP_INCLUDED BTA_JV_API_L2CAP_CONNECT_EVT, BTA_JV_API_L2CAP_CLOSE_EVT, BTA_JV_API_L2CAP_START_SERVER_EVT, BTA_JV_API_L2CAP_STOP_SERVER_EVT, BTA_JV_API_L2CAP_READ_EVT, BTA_JV_API_L2CAP_WRITE_EVT, +#endif /* BTA_JV_L2CAP_INCLUDED */ BTA_JV_API_RFCOMM_CONNECT_EVT, BTA_JV_API_RFCOMM_CLOSE_EVT, BTA_JV_API_RFCOMM_START_SERVER_EVT, @@ -62,11 +64,13 @@ enum { BTA_JV_API_RFCOMM_WRITE_EVT, BTA_JV_API_SET_PM_PROFILE_EVT, BTA_JV_API_PM_STATE_CHANGE_EVT, +#if BTA_JV_L2CAP_INCLUDED BTA_JV_API_L2CAP_CONNECT_LE_EVT, BTA_JV_API_L2CAP_START_SERVER_LE_EVT, BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT, BTA_JV_API_L2CAP_WRITE_FIXED_EVT, BTA_JV_API_L2CAP_CLOSE_FIXED_EVT, +#endif /* BTA_JV_L2CAP_INCLUDED */ BTA_JV_MAX_INT_EVT }; @@ -80,6 +84,12 @@ typedef struct { tBTA_JV_DM_CBACK *p_cback; } tBTA_JV_API_ENABLE; +/* data type for BTA_JV_API_DISABLE_EVT */ +typedef struct { + BT_HDR hdr; + tBTA_JV_RFCOMM_CBACK *p_cback; +} tBTA_JV_API_DISABLE; + /* data type for BTA_JV_API_START_DISCOVERY_EVT */ typedef struct { BT_HDR hdr; @@ -115,6 +125,8 @@ enum { BTA_JV_ST_SR_CLOSING } ; typedef UINT8 tBTA_JV_STATE; + +#if BTA_JV_L2CAP_INCLUDED #define BTA_JV_ST_CL_MAX BTA_JV_ST_CL_CLOSING /* JV L2CAP control block */ typedef struct { @@ -127,6 +139,7 @@ typedef struct { tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */ void *user_data; /* user data for callback from higher layers */ } tBTA_JV_L2C_CB; +#endif /* BTA_JV_L2CAP_INCLUDED */ #define BTA_JV_RFC_HDL_MASK 0xFF #define BTA_JV_RFCOMM_MASK 0x80 @@ -156,6 +169,7 @@ typedef struct { int curr_sess; /* current sessions count*/ } tBTA_JV_RFC_CB; +#if BTA_JV_L2CAP_INCLUDED /* data type for BTA_JV_API_L2CAP_CONNECT_EVT & BTA_JV_API_L2CAP_CONNECT_LE_EVT */ typedef struct { BT_HDR hdr; @@ -233,6 +247,7 @@ typedef struct { UINT16 len; void *user_data; } tBTA_JV_API_L2CAP_WRITE_FIXED; +#endif /* BTA_JV_L2CAP_INCLUDED */ /* data type for BTA_JV_API_RFCOMM_CONNECT_EVT */ typedef struct { @@ -300,6 +315,7 @@ typedef struct { UINT32 handle; tBTA_JV_RFC_CB *p_cb; tBTA_JV_PCB *p_pcb; + tBTA_JV_RFCOMM_CBACK *p_cback; void *user_data; } tBTA_JV_API_RFCOMM_CLOSE; @@ -326,6 +342,8 @@ typedef struct { BT_HDR hdr; INT32 type; /* One of BTA_JV_CONN_TYPE_ */ UINT16 scn; + tBTA_JV_RFCOMM_CBACK *p_cback; + void *user_data; } tBTA_JV_API_FREE_CHANNEL; /* data type for BTA_JV_API_ALLOC_CHANNEL_EVT */ @@ -340,16 +358,20 @@ typedef union { /* GKI event buffer header */ BT_HDR hdr; tBTA_JV_API_ENABLE enable; + tBTA_JV_API_DISABLE disable; tBTA_JV_API_START_DISCOVERY start_discovery; tBTA_JV_API_ALLOC_CHANNEL alloc_channel; tBTA_JV_API_FREE_CHANNEL free_channel; tBTA_JV_API_CREATE_RECORD create_record; tBTA_JV_API_ADD_ATTRIBUTE add_attr; +#if BTA_JV_L2CAP_INCLUDED tBTA_JV_API_L2CAP_CONNECT l2cap_connect; tBTA_JV_API_L2CAP_READ l2cap_read; tBTA_JV_API_L2CAP_WRITE l2cap_write; tBTA_JV_API_L2CAP_CLOSE l2cap_close; tBTA_JV_API_L2CAP_SERVER l2cap_server; + tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed; +#endif /* BTA_JV_L2CAP_INCLUDED */ tBTA_JV_API_RFCOMM_CONNECT rfcomm_connect; tBTA_JV_API_RFCOMM_READ rfcomm_read; tBTA_JV_API_RFCOMM_WRITE rfcomm_write; @@ -357,7 +379,6 @@ typedef union { tBTA_JV_API_PM_STATE_CHANGE change_pm_state; tBTA_JV_API_RFCOMM_CLOSE rfcomm_close; tBTA_JV_API_RFCOMM_SERVER rfcomm_server; - tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed; } tBTA_JV_MSG; /* JV control block */ @@ -368,7 +389,9 @@ typedef struct { UINT32 sdp_handle[BTA_JV_MAX_SDP_REC]; /* SDP records created */ UINT8 *p_sel_raw_data;/* the raw data of last service select */ tBTA_JV_DM_CBACK *p_dm_cback; +#if BTA_JV_L2CAP_INCLUDED tBTA_JV_L2C_CB l2c_cb[BTA_JV_MAX_L2C_CONN]; /* index is GAP handle (index) */ +#endif /* BTA_JV_L2CAP_INCLUDED */ tBTA_JV_RFC_CB rfc_cb[BTA_JV_MAX_RFC_CONN]; tBTA_JV_PCB port_cb[MAX_RFC_PORTS]; /* index of this array is the port_handle, */ @@ -407,12 +430,14 @@ extern void bta_jv_free_scn (tBTA_JV_MSG *p_data); extern void bta_jv_start_discovery (tBTA_JV_MSG *p_data); extern void bta_jv_create_record (tBTA_JV_MSG *p_data); extern void bta_jv_delete_record (tBTA_JV_MSG *p_data); +#if BTA_JV_L2CAP_INCLUDED extern void bta_jv_l2cap_connect (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_close (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_start_server (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_stop_server (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_read (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_write (tBTA_JV_MSG *p_data); +#endif /* BTA_JV_L2CAP_INCLUDED */ extern void bta_jv_rfcomm_connect (tBTA_JV_MSG *p_data); extern void bta_jv_rfcomm_close (tBTA_JV_MSG *p_data); extern void bta_jv_rfcomm_start_server (tBTA_JV_MSG *p_data); @@ -421,11 +446,12 @@ extern void bta_jv_rfcomm_read (tBTA_JV_MSG *p_data); extern void bta_jv_rfcomm_write (tBTA_JV_MSG *p_data); extern void bta_jv_set_pm_profile (tBTA_JV_MSG *p_data); extern void bta_jv_change_pm_state(tBTA_JV_MSG *p_data); +#if BTA_JV_L2CAP_INCLUDED extern void bta_jv_l2cap_connect_le (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_start_server_le (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_stop_server_le (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_write_fixed (tBTA_JV_MSG *p_data); extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data); - +#endif /* BTA_JV_L2CAP_INCLUDED */ #endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE #endif /* BTA_JV_INT_H */ diff --git a/components/bt/bluedroid/btc/core/btc_dm.c b/components/bt/bluedroid/btc/core/btc_dm.c index fbf153b5e..697238009 100644 --- a/components/bt/bluedroid/btc/core/btc_dm.c +++ b/components/bt/bluedroid/btc/core/btc_dm.c @@ -22,7 +22,7 @@ #include "common/bt_target.h" #include "btc/btc_storage.h" #include "btc/btc_ble_storage.h" -#include "esp_gap_ble_api.h" +#include "btc_gap_ble.h" #include "btm_int.h" #include "bta/bta_api.h" #include "bta/bta_gatt_api.h" @@ -299,6 +299,27 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) } #endif ///SMP_INCLUDED == TRUE +static void btc_dm_link_up_evt(tBTA_DM_LINK_UP *p_link_up) +{ + BD_ADDR bd_addr; + bt_bdaddr_t bt_bdaddr; + + + if (p_link_up->sc_downgrade == 1) { + memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR)); + if (btc_storage_remove_bonded_device(&bt_bdaddr) == BT_STATUS_SUCCESS) { + memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR)); + if (BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS) { + BTC_TRACE_EVENT(" %s() Bonding information removed.", __FUNCTION__); + } else { + BTC_TRACE_ERROR(" %s() BTA_DmRemoveDevice error", __FUNCTION__); + } + } else { + BTC_TRACE_ERROR(" %s() btc_storage_remove_bonded_device error", __FUNCTION__); + } + } +} + static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { /* Save link key, if not temporary */ @@ -322,7 +343,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) __FUNCTION__, p_auth_cmpl->key_type); ret = btc_storage_add_bonded_device(&bd_addr, p_auth_cmpl->key, p_auth_cmpl->key_type, - 16); + 16, p_auth_cmpl->sc_support); BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret); } else { BTC_TRACE_DEBUG("%s: Temporary key. Not storing. key_type=0x%x", @@ -383,11 +404,10 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN); memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1); - ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_bt_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } #endif /// BTC_GAP_BT_INCLUDED == TRUE @@ -406,11 +426,10 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req) param.pin_req.min_16_digit = p_pin_req->min_16_digit; memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN); - ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_bt_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } #endif /// BTC_GAP_BT_INCLUDED == TRUE } @@ -434,11 +453,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req) param.cfm_req.num_val = p_cfm_req->num_val; memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN); - ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_bt_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } #endif /// BTC_GAP_BT_INCLUDED == TRUE } @@ -455,11 +473,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif) param.key_notif.passkey = p_key_notif->passkey; memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN); - ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_bt_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } #endif /// BTC_GAP_BT_INCLUDED == TRUE } @@ -475,16 +492,43 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req) msg.act = BTC_GAP_BT_KEY_REQ_EVT; memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN); - ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_bt_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } #endif /// BTC_GAP_BT_INCLUDED == TRUE } #endif /// BT_SSP_INCLUDED == TRUE +static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down) +{ + esp_bt_gap_cb_param_t param; + BTC_TRACE_DEBUG("%s",__func__); + memcpy(param.remove_bond_dev_cmpl.bda, p_link_down->bd_addr, ESP_BD_ADDR_LEN); + btm_set_bond_type_dev(p_link_down->bd_addr, BOND_TYPE_UNKNOWN); + if (p_link_down->status == HCI_SUCCESS) { + //remove the bonded key in the config and nvs flash. + param.remove_bond_dev_cmpl.status = btc_storage_remove_bonded_device((bt_bdaddr_t *)param.remove_bond_dev_cmpl.bda); + } else { + param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL; + } + +#if (BTC_GAP_BT_INCLUDED == TRUE) + bt_status_t ret; + btc_msg_t msg; + msg.sig = BTC_SIG_API_CB; + msg.pid = BTC_PID_GAP_BT; + msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT; + + ret = btc_inter_profile_call(&msg, ¶m); + + if (ret != BT_STATUS_SUCCESS) { + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); + } +#endif /// BTC_GAP_BT_INCLUDED == TRUE +} + tBTA_SERVICE_MASK btc_get_enabled_services_mask(void) { return btc_enabled_services; @@ -622,16 +666,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) #endif ///BT_SSP_INCLUDED == TRUE case BTA_DM_DEV_UNPAIRED_EVT: { -#if (SMP_INCLUDED == TRUE) - bt_bdaddr_t bd_addr; - BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT"); - memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR)); - btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN); - if (p_data->link_down.status == HCI_SUCCESS) { - //remove the bonded key in the config and nvs flash. - btc_storage_remove_bonded_device(&bd_addr); - } -#endif /* #if (SMP_INCLUDED == TRUE) */ + btc_dm_dev_unpaired_evt(&p_data->link_down); break; } case BTA_DM_BLE_DEV_UNPAIRED_EVT: { @@ -664,12 +699,14 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) break; } #endif /* BTC_GAP_BT_INCLUDED == TRUE */ - case BTA_DM_LINK_UP_EVT: case BTA_DM_LINK_DOWN_EVT: case BTA_DM_HW_ERROR_EVT: BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act ); break; -#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE)) + case BTA_DM_LINK_UP_EVT: + btc_dm_link_up_evt(&p_data->link_up); + break; +#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE)) case BTA_DM_BLE_AUTH_CMPL_EVT: { rsp_app = true; ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT; @@ -832,11 +869,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg) } if (rsp_app) { - ret = btc_transfer_context(&ble_msg, ¶m, - sizeof(esp_ble_gap_cb_param_t), NULL); + ret = btc_inter_profile_call(&ble_msg, ¶m); if (ret != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__); } } btc_dm_sec_arg_deep_free(msg); diff --git a/components/bt/bluedroid/btc/core/btc_storage.c b/components/bt/bluedroid/btc/core/btc_storage.c index 654a1bf28..97bef05fc 100644 --- a/components/bt/bluedroid/btc/core/btc_storage.c +++ b/components/bt/bluedroid/btc/core/btc_storage.c @@ -37,7 +37,8 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, LINK_KEY link_key, uint8_t key_type, - uint8_t pin_length) + uint8_t pin_length, + BOOLEAN sc_support) { bdstr_t bdstr; @@ -48,6 +49,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, int ret = btc_config_set_int(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR, (int)key_type); ret &= btc_config_set_int(bdstr, BTC_STORAGE_PIN_LENGTH_STR, (int)pin_length); ret &= btc_config_set_bin(bdstr, BTC_STORAGE_LINK_KEY_STR, link_key, sizeof(LINK_KEY)); + ret &= btc_config_set_bin(bdstr, BTC_STORAGE_SC_SUPPORT, (uint8_t *)&sc_support, sizeof(sc_support)); /* write bonded info immediately */ btc_config_flush(); btc_config_unlock(); @@ -69,6 +71,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, static bt_status_t btc_in_fetch_bonded_devices(int add) { BOOLEAN bt_linkkey_file_found = FALSE; + UINT8 sc_support = 0; btc_config_lock(); for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) { @@ -93,9 +96,11 @@ static bt_status_t btc_in_fetch_bonded_devices(int add) uint2devclass((UINT32)cod, dev_class); } btc_config_get_int(name, BTC_STORAGE_PIN_LENGTH_STR, &pin_length); + size = sizeof(sc_support); + btc_config_get_bin(name, BTC_STORAGE_SC_SUPPORT, &sc_support, &size); #if (SMP_INCLUDED == TRUE) BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0, - (UINT8)linkkey_type, 0, pin_length); + (UINT8)linkkey_type, 0, pin_length, (UINT8)sc_support); #endif ///SMP_INCLUDED == TRUE } bt_linkkey_file_found = TRUE; @@ -160,6 +165,9 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr) if (btc_config_exist(bdstr, BTC_STORAGE_LINK_KEY_STR)) { ret &= btc_config_remove(bdstr, BTC_STORAGE_LINK_KEY_STR); } + if (btc_config_exist(bdstr, BTC_STORAGE_SC_SUPPORT)) { + ret &= btc_config_remove(bdstr, BTC_STORAGE_SC_SUPPORT); + } /* write bonded info immediately */ btc_config_flush(); btc_config_unlock(); @@ -187,12 +195,12 @@ int btc_storage_get_num_bt_bond_devices(void) if (string_is_bdaddr(name) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) && btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) && + btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) { num_dev++; } } btc_config_unlock(); - return num_dev; } @@ -206,15 +214,17 @@ int btc_storage_get_num_bt_bond_devices(void) ** BT_STATUS_FAIL otherwise ** *******************************************************************************/ -bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num) +bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num) { bt_bdaddr_t bd_addr; + int in_dev_num = *dev_num; /* buffer size */ + int out_dev_num = 0; /* bond_dev size */ btc_config_lock(); for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) { - if (dev_num-- <= 0) { + if (in_dev_num <= 0) { break; } @@ -223,13 +233,17 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int de if (string_is_bdaddr(name) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) && btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) && + btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) && btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) { string_to_bdaddr(name, &bd_addr); memcpy(bond_dev, &bd_addr, sizeof(bt_bdaddr_t)); + in_dev_num--; + out_dev_num++; bond_dev++; } } + *dev_num = out_dev_num; /* out_dev_num <= in_dev_num */ btc_config_unlock(); return BT_STATUS_SUCCESS; -} \ No newline at end of file +} diff --git a/components/bt/bluedroid/btc/include/btc/btc_storage.h b/components/bt/bluedroid/btc/include/btc/btc_storage.h index f40b169d4..f74c3eeb3 100644 --- a/components/bt/bluedroid/btc/include/btc/btc_storage.h +++ b/components/bt/bluedroid/btc/include/btc/btc_storage.h @@ -25,6 +25,7 @@ #define BTC_STORAGE_LINK_KEY_STR "LinkKey" /* same as the ble */ #define BTC_STORAGE_LINK_KEY_TYPE_STR "LinkKeyType" #define BTC_STORAGE_PIN_LENGTH_STR "PinLength" +#define BTC_STORAGE_SC_SUPPORT "SCSupport" /******************************************************************************* ** @@ -40,7 +41,8 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr, LINK_KEY link_key, uint8_t key_type, - uint8_t pin_length); + uint8_t pin_length, + BOOLEAN sc_support); /******************************************************************************* ** @@ -87,6 +89,6 @@ int btc_storage_get_num_bt_bond_devices(void); ** BT_STATUS_FAIL otherwise ** *******************************************************************************/ -bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num); +bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num); #endif /* BTC_STORAGE_H */ diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c index d5e1b1ca8..732ab503f 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c @@ -127,12 +127,16 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) switch (ctrl) { case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY: #if BTC_AV_SRC_INCLUDED - if (btc_a2dp_source_is_task_shutting_down()) { - btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); - } else if ((btc_av_stream_ready() == TRUE) || - (btc_av_stream_started_ready() == TRUE)) { - /* check whether av is ready to setup a2dp datapath */ - btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); + if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) { + if (btc_a2dp_source_is_task_shutting_down()) { + btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); + } else if ((btc_av_stream_ready() == TRUE) || + (btc_av_stream_started_ready() == TRUE)) { + /* check whether av is ready to setup a2dp datapath */ + btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); + } else { + btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); + } } else { btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); } @@ -159,6 +163,10 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) } break; case ESP_A2D_MEDIA_CTRL_STOP: + if (btc_av_is_connected() == FALSE) { + btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); + break; + } #if BTC_AV_SRC_INCLUDED if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() && btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) { @@ -174,7 +182,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) } #endif break; - case ESP_A2D_MEDIA_CTRL_SUSPEND: /* local suspend */ if (btc_av_stream_started_ready()) { @@ -184,14 +191,15 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); } #endif - } else { + } else if (btc_av_is_connected() == TRUE) { /* we are not in started state; just ack back ok. This can happen if we are remotely suspended; clear REMOTE SUSPEND Flag */ btc_av_clear_remote_suspend_flag(); btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); + } else { + btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); } break; - default : APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl); btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 6046c57c4..505488fa0 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1120,7 +1120,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback); break; case BTC_GAP_BLE_ACT_READ_RSSI: - BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback); + BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback); break; case BTC_GAP_BLE_ACT_SET_CONN_PARAMS: BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int, diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c index 0f9789d52..6baef4993 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -633,7 +633,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data) static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg) { - BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback); + BTA_DmReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback); } static esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg) @@ -852,6 +852,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg) case BTC_GAP_BT_READ_RSSI_DELTA_EVT: case BTC_GAP_BT_AUTH_CMPL_EVT: case BTC_GAP_BT_PIN_REQ_EVT: + case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT: #if (BT_SSP_INCLUDED == TRUE) case BTC_GAP_BT_CFM_REQ_EVT: case BTC_GAP_BT_KEY_NOTIF_EVT: @@ -905,6 +906,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg) break; } #endif ///BT_SSP_INCLUDED == TRUE + case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:{ + btc_gap_bt_cb_to_app(ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT,(esp_bt_gap_cb_param_t *)msg->arg); + break; + } default: BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); break; diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h b/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h index 847b93819..dd37aa717 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h @@ -33,6 +33,7 @@ typedef enum { BTC_GAP_BT_KEY_NOTIF_EVT, BTC_GAP_BT_KEY_REQ_EVT, BTC_GAP_BT_READ_RSSI_DELTA_EVT, + BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT, }btc_gap_bt_evt_t; typedef enum { diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_spp.h b/components/bt/bluedroid/btc/profile/std/include/btc_spp.h index a8b409e0a..d3c8a4938 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_spp.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_spp.h @@ -35,6 +35,7 @@ typedef enum { BTC_SPP_ACT_CONNECT, BTC_SPP_ACT_DISCONNECT, BTC_SPP_ACT_START_SRV, + BTC_SPP_ACT_STOP_SRV, BTC_SPP_ACT_WRITE, } btc_spp_act_t; diff --git a/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c index bc2d62427..dfe07112d 100644 --- a/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c @@ -29,6 +29,7 @@ #include #include "esp_vfs.h" #include "esp_vfs_dev.h" +#include "stack/port_api.h" #if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE) @@ -55,13 +56,20 @@ typedef struct { char service_name[ESP_SPP_SERVER_NAME_MAX + 1]; } spp_slot_t; -static struct spp_local_param_t { - spp_slot_t *spp_slots[BTA_JV_MAX_RFC_SR_SESSION + 1]; +typedef struct { + spp_slot_t *spp_slots[MAX_RFC_PORTS + 1]; uint32_t spp_slot_id; esp_spp_mode_t spp_mode; osi_mutex_t spp_slot_mutex; esp_vfs_id_t spp_vfs_id; -} spp_local_param; +} spp_local_param_t; + +#if SPP_DYNAMIC_MEMORY == FALSE +static spp_local_param_t spp_local_param; +#else +static spp_local_param_t *spp_local_param_ptr; +#define spp_local_param (*spp_local_param_ptr) +#endif static void spp_osi_free(void *p) { @@ -73,7 +81,7 @@ static spp_slot_t *spp_malloc_slot(void) if (++spp_local_param.spp_slot_id == 0) { spp_local_param.spp_slot_id = 1; } - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { if (spp_local_param.spp_slots[i] == NULL) { spp_local_param.spp_slots[i] = (spp_slot_t *)osi_malloc(sizeof(spp_slot_t)); if (!spp_local_param.spp_slots[i]) { @@ -81,6 +89,9 @@ static spp_slot_t *spp_malloc_slot(void) } spp_local_param.spp_slots[i]->id = spp_local_param.spp_slot_id; spp_local_param.spp_slots[i]->serial = i; + spp_local_param.spp_slots[i]->sdp_handle = 0; + spp_local_param.spp_slots[i]->rfc_handle = 0; + spp_local_param.spp_slots[i]->rfc_port_handle = 0; spp_local_param.spp_slots[i]->connected = FALSE; spp_local_param.spp_slots[i]->write_data = NULL; spp_local_param.spp_slots[i]->list = list_new(spp_osi_free); @@ -101,7 +112,7 @@ static spp_slot_t *spp_malloc_slot(void) static spp_slot_t *spp_find_slot_by_id(uint32_t id) { - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->id == id) { return spp_local_param.spp_slots[i]; } @@ -111,7 +122,7 @@ static spp_slot_t *spp_find_slot_by_id(uint32_t id) static spp_slot_t *spp_find_slot_by_handle(uint32_t handle) { - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->rfc_handle == handle) { return spp_local_param.spp_slots[i]; } @@ -121,7 +132,7 @@ static spp_slot_t *spp_find_slot_by_handle(uint32_t handle) static spp_slot_t *spp_find_slot_by_fd(int fd) { - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->fd == fd) { return spp_local_param.spp_slots[i]; } @@ -129,6 +140,16 @@ static spp_slot_t *spp_find_slot_by_fd(int fd) return NULL; } +static spp_slot_t *spp_find_slot_by_scn(uint32_t scn) +{ + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { + if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->scn == (uint8_t)scn) { + return spp_local_param.spp_slots[i]; + } + } + return NULL; +} + static void spp_free_slot(spp_slot_t *slot) { if (!slot) { @@ -160,15 +181,6 @@ static void btc_create_server_fail_cb(void) btc_spp_cb_to_app(ESP_SPP_START_EVT, ¶m); } -static void btc_disconnect_cb(uint32_t handle) -{ - esp_spp_cb_param_t param; - param.close.status = ESP_SPP_SUCCESS; - param.close.handle = handle; - param.close.async = FALSE; - btc_spp_cb_to_app(ESP_SPP_CLOSE_EVT, ¶m); -} - static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data) { bt_status_t status; @@ -177,34 +189,53 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u uint32_t id = (uintptr_t)user_data; spp_slot_t *slot, *slot_new; + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_WARNING("%s SPP have been deinit, incoming events ignore!\n", __func__); + return new_user_data; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); switch (event) { - case BTA_JV_RFCOMM_SRV_OPEN_EVT: + case BTA_JV_RFCOMM_START_EVT: slot = spp_find_slot_by_id(id); if (!slot) { BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } - slot_new = spp_malloc_slot(); - if (!slot_new) { - BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__); + slot->rfc_handle = p_data->rfc_start.handle; + slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_start.handle); + break; + case BTA_JV_RFCOMM_SRV_OPEN_EVT: + slot = p_data->rfc_srv_open.handle ? spp_find_slot_by_id(id) : spp_find_slot_by_scn((uint32_t)user_data); + if (!slot) { + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } - new_user_data = (void *)(uintptr_t)slot_new->id; - slot_new->security = slot->security; - slot_new->role = slot->role; - slot_new->scn = slot->scn;; - slot_new->max_session = slot->max_session; - strcpy(slot_new->service_name, slot->service_name); - slot_new->sdp_handle = slot->sdp_handle; - slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle; - slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle); - memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN); - slot->connected = TRUE; - slot->rfc_handle = p_data->rfc_srv_open.handle; - slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle); - BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN); + if (p_data->rfc_srv_open.handle) { + new_user_data = (void *)(uintptr_t)slot->id; + memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN); + slot->connected = TRUE; + slot->rfc_handle = p_data->rfc_srv_open.handle; + slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle); + BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN); + } + + if (p_data->rfc_srv_open.handle != p_data->rfc_srv_open.new_listen_handle) { + slot_new = spp_malloc_slot(); + if (!slot_new) { + BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__); + break; + } + new_user_data = (void *)(uintptr_t)slot_new->id; + slot_new->security = slot->security; + slot_new->role = slot->role; + slot_new->scn = slot->scn; + slot_new->max_session = slot->max_session; + strcpy(slot_new->service_name, slot->service_name); + slot_new->sdp_handle = slot->sdp_handle; + slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle; + slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle); + } break; case BTA_JV_RFCOMM_OPEN_EVT: slot = spp_find_slot_by_id(id); @@ -223,14 +254,26 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); break; } - if (slot->connected) { - BTA_JvRfcommClose(slot->rfc_handle, (void *)slot->id); + if (slot->connected && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) { + BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id); } spp_free_slot(slot); p_data->rfc_close.status = BTA_JV_SUCCESS; break; case BTA_JV_RFCOMM_DATA_IND_EVT: break; + case BTA_JV_FREE_SCN_EVT: + if (user_data) { + id = ((tBTA_JV_FREE_SCN_USER_DATA *)user_data)->slot_id; + slot = spp_find_slot_by_id(id); + if (slot) { + spp_free_slot(slot); + } else { + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); + } + osi_free(user_data); + } + break; default: break; } @@ -292,8 +335,15 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d } else { BTC_TRACE_ERROR("%s unable to create record, start server fail!", __func__); btc_create_server_fail_cb(); - BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM); - spp_free_slot(slot); + tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA)); + if (user_data) { + user_data->server_status = BTA_JV_SERVER_START_FAILED; + user_data->slot_id = slot->id; + } else { + BTC_TRACE_ERROR("%s unable to malloc user data!", __func__); + } + BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM, + (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data); } osi_mutex_unlock(&spp_local_param.spp_slot_mutex); break; @@ -313,6 +363,22 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d static void btc_spp_init(btc_spp_args_t *arg) { + if (spp_local_param.spp_slot_mutex) { + esp_spp_cb_param_t param; + param.init.status = ESP_SPP_FAILURE; + btc_spp_cb_to_app(ESP_SPP_INIT_EVT, ¶m); + BTC_TRACE_ERROR("%s SPP has been initiated, shall uninit first!", __func__); + return; + } + +#if SPP_DYNAMIC_MEMORY == TRUE + if ((spp_local_param_ptr = (spp_local_param_t *)osi_malloc(sizeof(spp_local_param_t))) == NULL) { + BTC_TRACE_ERROR("%s malloc failed\n", __func__); + return; + } + memset((void *)spp_local_param_ptr, 0, sizeof(spp_local_param_t)); +#endif + if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) { BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__); return; @@ -324,40 +390,65 @@ static void btc_spp_init(btc_spp_args_t *arg) static void btc_spp_uninit(void) { + esp_spp_cb_param_t param; if (!spp_local_param.spp_slot_mutex) { - BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + param.uninit.status = ESP_SPP_FAILURE; + btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, ¶m); + BTC_TRACE_ERROR("%s SPP has not been initiated, shall init first!", __func__); return; } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { + // first, remove all connection + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) { - BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (void *)spp_local_param.spp_slots[i]->id); - spp_free_slot(spp_local_param.spp_slots[i]); - spp_local_param.spp_slots[i] = NULL; - } - } - for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) { - if (spp_local_param.spp_slots[i] != NULL && !(spp_local_param.spp_slots[i]->connected)) { - BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->sdp_handle, (void *)spp_local_param.spp_slots[i]->id); - BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle); - BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM); - spp_free_slot(spp_local_param.spp_slots[i]); - spp_local_param.spp_slots[i] = NULL; + BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, + (void *)spp_local_param.spp_slots[i]->id); } } + // second, remove all server + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { + if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) { + if (spp_local_param.spp_slots[i]->sdp_handle > 0) { + BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle); + } - BTA_JvDisable(); + if (spp_local_param.spp_slots[i]->rfc_handle > 0) { + BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle, + (void *)spp_local_param.spp_slots[i]->id); + } + + tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA)); + if (user_data) { + user_data->server_status = BTA_JV_SERVER_RUNNING; + user_data->slot_id = spp_local_param.spp_slots[i]->id; + } else { + BTC_TRACE_ERROR("%s unable to malloc user data!", __func__); + param.srv_stop.status = ESP_SPP_NO_RESOURCE; + btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m); + } + BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM, + (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data); + } + } + BTA_JvDisable((tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); - osi_mutex_free(&spp_local_param.spp_slot_mutex); } static void btc_spp_start_discovery(btc_spp_args_t *arg) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } BTA_JvStartDiscovery(arg->start_discovery.bd_addr, arg->start_discovery.num_uuid, arg->start_discovery.p_uuid_list, NULL); } static void btc_spp_connect(btc_spp_args_t *arg) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_malloc_slot(); if (!slot) { @@ -376,6 +467,10 @@ static void btc_spp_connect(btc_spp_args_t *arg) static void btc_spp_disconnect(btc_spp_args_t *arg) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_handle(arg->disconnect.handle); if (!slot) { @@ -383,14 +478,16 @@ static void btc_spp_disconnect(btc_spp_args_t *arg) osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } - BTA_JvRfcommClose(arg->disconnect.handle, (void *)slot->id); - btc_disconnect_cb(slot->rfc_handle); - spp_free_slot(slot); + BTA_JvRfcommClose(arg->disconnect.handle, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); } static void btc_spp_start_srv(btc_spp_args_t *arg) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_malloc_slot(); if (!slot) { @@ -408,8 +505,54 @@ static void btc_spp_start_srv(btc_spp_args_t *arg) osi_mutex_unlock(&spp_local_param.spp_slot_mutex); } +static void btc_spp_stop_srv(void) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } + esp_spp_cb_param_t param; + osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); + // first, remove all connection + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { + if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) { + BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, + (void *)spp_local_param.spp_slots[i]->id); + } + } + // second, remove all server + for (size_t i = 1; i <= MAX_RFC_PORTS; i++) { + if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) { + if (spp_local_param.spp_slots[i]->sdp_handle > 0) { + BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle); + } + + if (spp_local_param.spp_slots[i]->rfc_handle > 0) { + BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle, + (void *)spp_local_param.spp_slots[i]->id); + } + + tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA)); + if (user_data) { + user_data->server_status = BTA_JV_SERVER_RUNNING; + user_data->slot_id = spp_local_param.spp_slots[i]->id; + } else { + BTC_TRACE_ERROR("%s unable to malloc user data!", __func__); + param.srv_stop.status = ESP_SPP_NO_RESOURCE; + btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m); + } + BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM, + (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data); + } + } + osi_mutex_unlock(&spp_local_param.spp_slot_mutex); +} + static void btc_spp_write(btc_spp_args_t *arg) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_handle(arg->write.handle); if (!slot) { @@ -423,7 +566,7 @@ static void btc_spp_write(btc_spp_args_t *arg) osi_mutex_unlock(&spp_local_param.spp_slot_mutex); return; } - uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990); + uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU); if (item_size != 0){ slot->write_data = data; BTA_JvRfcommWrite(arg->write.handle, slot->id, item_size, data); @@ -504,6 +647,9 @@ void btc_spp_call_handler(btc_msg_t *msg) case BTC_SPP_ACT_START_SRV: btc_spp_start_srv(arg); break; + case BTC_SPP_ACT_STOP_SRV: + btc_spp_stop_srv(); + break; case BTC_SPP_ACT_WRITE: btc_spp_write(arg); break; @@ -562,22 +708,24 @@ void btc_spp_cb_handler(btc_msg_t *msg) btc_spp_cb_to_app(ESP_SPP_START_EVT, ¶m); break; case BTA_JV_RFCOMM_SRV_OPEN_EVT: - if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) { - osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle); - if (!slot) { - BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); + if (p_data->rfc_srv_open.handle) { + if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) { + osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); + slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle); + if (!slot) { + BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); + osi_mutex_unlock(&spp_local_param.spp_slot_mutex); + break; + } + param.srv_open.fd = slot->fd; osi_mutex_unlock(&spp_local_param.spp_slot_mutex); - break; } - param.srv_open.fd = slot->fd; - osi_mutex_unlock(&spp_local_param.spp_slot_mutex); + param.srv_open.status = p_data->rfc_srv_open.status; + param.srv_open.handle = p_data->rfc_srv_open.handle; + param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle; + memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN); + btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, ¶m); } - param.srv_open.status = p_data->rfc_srv_open.status; - param.srv_open.handle = p_data->rfc_srv_open.handle; - param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle; - memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN); - btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, ¶m); break; case BTA_JV_RFCOMM_WRITE_EVT: osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); @@ -609,7 +757,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) slot->write_data = NULL; } size_t item_size = 0; - uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990); + uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU); if (item_size != 0){ slot->write_data = data; BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data); @@ -645,7 +793,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) slot->write_data = NULL; } size_t item_size = 0; - uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990); + uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU); if (item_size != 0){ slot->write_data = data; BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data); @@ -668,6 +816,22 @@ void btc_spp_cb_handler(btc_msg_t *msg) btc_spp_cb_to_app(ESP_SPP_DATA_IND_EVT, ¶m); osi_free (p_data->data_ind.p_buf); break; + case BTA_JV_FREE_SCN_EVT: + if (p_data->free_scn.server_status == BTA_JV_SERVER_RUNNING) { + param.srv_stop.status = p_data->free_scn.status; + btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m); + } + break; + case BTA_JV_DISABLE_EVT: + param.uninit.status = ESP_SPP_SUCCESS; + BTA_JvFree(); + osi_mutex_free(&spp_local_param.spp_slot_mutex); +#if SPP_DYNAMIC_MEMORY == TRUE + osi_free(spp_local_param_ptr); + spp_local_param_ptr = NULL; +#endif + btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, ¶m); + break; default: BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act); break; @@ -705,12 +869,16 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf) msg.act = BTA_JV_RFCOMM_DATA_IND_EVT; uint32_t id = (uintptr_t)user_data; + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return -1; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_id(id); if (!slot) { BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); - return 0; + return -1; } p_data.data_ind.handle = slot->rfc_handle; @@ -751,6 +919,10 @@ int bta_co_rfc_data_outgoing(void *user_data, uint8_t *buf, uint16_t size) static ssize_t spp_vfs_write(int fd, const void * data, size_t size) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return -1; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_fd(fd); if (!slot) { @@ -770,6 +942,10 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size) } static int spp_vfs_close(int fd) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return -1; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_fd(fd); if (!slot) { @@ -798,6 +974,10 @@ static bool incoming_list_2_ringbuf_read(spp_slot_t *slot) static ssize_t spp_vfs_read(int fd, void * dst, size_t size) { + if (!spp_local_param.spp_slot_mutex) { + BTC_TRACE_ERROR("%s SPP have not been init\n", __func__); + return -1; + } osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); spp_slot_t *slot = spp_find_slot_by_fd(fd); if (!slot) { diff --git a/components/bt/bluedroid/common/include/common/bt_target.h b/components/bt/bluedroid/common/include/common/bt_target.h index 4504e0cd8..d9f59fc73 100644 --- a/components/bt/bluedroid/common/include/common/bt_target.h +++ b/components/bt/bluedroid/common/include/common/bt_target.h @@ -96,6 +96,12 @@ #endif /* #if CONFIG_CLASSIC_BT_ENABLED */ +/* This is set to enable use of GAP L2CAP connections. */ +#if (VND_BT_JV_BTA_L2CAP == TRUE) +#define BTA_JV_L2CAP_INCLUDED TRUE +#define GAP_CONN_INCLUDED TRUE +#endif /* VND_BT_JV_BTA_L2CAP */ + #ifndef CLASSIC_BT_INCLUDED #define CLASSIC_BT_INCLUDED FALSE #endif /* CLASSIC_BT_INCLUDED */ @@ -293,6 +299,19 @@ #define BTA_SDP_INCLUDED FALSE #endif +/* This is set to enable use of GAP L2CAP connections. */ +#ifndef VND_BT_JV_BTA_L2CAP +#define VND_BT_JV_BTA_L2CAP FALSE +#endif + +#ifndef BTA_JV_L2CAP_INCLUDED +#define BTA_JV_L2CAP_INCLUDED FALSE +#endif + +#ifndef GAP_CONN_INCLUDED +#define GAP_CONN_INCLUDED FALSE +#endif + /****************************************************************************** ** ** Stack-layer components @@ -1341,7 +1360,7 @@ /* The maximum number of ports supported. */ #ifndef MAX_RFC_PORTS -#define MAX_RFC_PORTS 16 /*max is 30*/ +#define MAX_RFC_PORTS 8 /*max is 30*/ #endif /* The maximum simultaneous links to different devices. */ @@ -1710,15 +1729,6 @@ Range: 2 octets #define GAP_INCLUDED TRUE #endif -/* This is set to enable use of GAP L2CAP connections. */ -#ifndef GAP_CONN_INCLUDED -#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE) -#define GAP_CONN_INCLUDED TRUE -#else -#define GAP_CONN_INCLUDED FALSE -#endif -#endif - /* This is set to enable posting event for data write */ #ifndef GAP_CONN_POST_EVT_INCLUDED #define GAP_CONN_POST_EVT_INCLUDED FALSE diff --git a/components/bt/bluedroid/stack/btm/btm_acl.c b/components/bt/bluedroid/stack/btm/btm_acl.c index 8129e903a..4144b9d97 100644 --- a/components/bt/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/bluedroid/stack/btm/btm_acl.c @@ -231,7 +231,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, UINT8 xx; BTM_TRACE_DEBUG ("btm_acl_created hci_handle=%d link_role=%d transport=%d\n", - hci_handle, link_role, transport); + hci_handle, link_role, transport); /* Ensure we don't have duplicates */ p = btm_bda_to_acl(bda, transport); if (p != (tACL_CONN *)NULL) { @@ -241,7 +241,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, p->transport = transport; #endif BTM_TRACE_DEBUG ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x\n", - bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); + bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); BTM_SetLinkPolicy(p->remote_addr, &btm_cb.btm_def_link_policy); return; } @@ -269,13 +269,16 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, p->conn_addr_type = BLE_ADDR_PUBLIC; memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN); BTM_TRACE_DEBUG ("conn_addr: RemBdAddr: %02x%02x%02x%02x%02x%02x\n", - p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]); + p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]); #endif #endif p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE; btm_pm_sm_alloc(xx); +#if (CLASSIC_BT_INCLUDED == TRUE) + btm_sec_update_legacy_auth_state(p, BTM_ACL_LEGACY_AUTH_NONE); +#endif if (dc) { memcpy (p->remote_dc, dc, DEV_CLASS_LEN); @@ -299,28 +302,34 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, #endif if (p_dev_rec && !(transport == BT_TRANSPORT_LE)) { - /* If remote features already known, copy them and continue connection setup */ - if ((p_dev_rec->num_read_pages) && - (p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) { - memcpy (p->peer_lmp_features, p_dev_rec->features, - (HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages)); - p->num_read_pages = p_dev_rec->num_read_pages; + if (!p_dev_rec->remote_secure_connection_previous_state) { + /* If remote features already known, copy them and continue connection setup */ + if ((p_dev_rec->num_read_pages) && + (p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) { + memcpy (p->peer_lmp_features, p_dev_rec->features, + (HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages)); + p->num_read_pages = p_dev_rec->num_read_pages; #if (CLASSIC_BT_INCLUDED == TRUE) - const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); + const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); #endif ///CLASSIC_BT_INCLUDED == TRUE - /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ + /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ #if (SMP_INCLUDED == TRUE) - btm_sec_set_peer_sec_caps(p, p_dev_rec); + btm_sec_set_peer_sec_caps(p, p_dev_rec); #endif ///SMP_INCLUDED == TRUE #if (CLASSIC_BT_INCLUDED == TRUE) - BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); - if (req_pend) { - /* Request for remaining Security Features (if any) */ - l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); - } + BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); + if (req_pend) { + /* Request for remaining Security Features (if any) */ + l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr); + } #endif ///CLASSIC_BT_INCLUDED == TRUE - btm_establish_continue (p); - return; + btm_establish_continue (p); + return; + } + } else { + /* If remote features indicated secure connection (SC) mode, check the remote feautres again*/ + /* this is to prevent from BIAS attack where attacker can downgrade SC mode*/ + btm_read_remote_features (p->hci_handle); } } @@ -329,13 +338,13 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, if (p_dev_rec && transport == BT_TRANSPORT_LE) { #if BLE_PRIVACY_SPT == TRUE btm_ble_get_acl_remote_addr (p_dev_rec, p->active_remote_addr, - &p->active_remote_addr_type); + &p->active_remote_addr_type); #endif if (link_role == HCI_ROLE_MASTER) { btsnd_hcic_ble_read_remote_feat(p->hci_handle); } else if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) - && link_role == HCI_ROLE_SLAVE) { + && link_role == HCI_ROLE_SLAVE) { btsnd_hcic_rmt_ver_req (p->hci_handle); } else { btm_establish_continue(p); @@ -785,12 +794,28 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) BTM_TRACE_WARNING("btm_acl_encrypt_change -> Issuing delayed HCI_Disconnect!!!\n"); btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER); } - BTM_TRACE_ERROR("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n", + BTM_TRACE_WARNING("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n", (UINT32)p_dev_rec, p_dev_rec->rs_disc_pending); p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */ } #endif } +#if (CLASSIC_BT_INCLUDED == TRUE) + /* If authentication is done through legacy authentication and esp32 has + * not authenticated peer deivce yet, do not proceed for encrytion and + * first authenticate it. */ + else if ((BTM_BothEndsSupportSecureConnections(p->remote_addr) == 0) && + ((p->legacy_auth_state & BTM_ACL_LEGACY_AUTH_SELF) == 0)) { + if ((p_dev_rec = btm_find_dev (p->remote_addr)) != NULL) { + if (btm_sec_legacy_authentication_mutual(p_dev_rec)) { + btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_SELF); + } else { + BTM_TRACE_ERROR("%s failed, Resources not available for Authentication procedure", __FUNCTION__); + } + } + } +#endif + } /******************************************************************************* ** @@ -1115,7 +1140,6 @@ void btm_read_remote_ext_features_complete (UINT8 *p) if (max_page > HCI_EXT_FEATURES_PAGE_MAX) { BTM_TRACE_ERROR("btm_read_remote_ext_features_complete page=%d unknown", max_page); - return; } p_acl_cb = &btm_cb.acl_db[acl_idx]; @@ -1212,6 +1236,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb) evt_data.conn.p_bdn = p_acl_cb->remote_name; evt_data.conn.p_dc = p_acl_cb->remote_dc; evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]; + evt_data.conn.sc_downgrade = p_acl_cb->sc_downgrade; #if BLE_INCLUDED == TRUE evt_data.conn.handle = p_acl_cb->hci_handle; evt_data.conn.transport = p_acl_cb->transport; diff --git a/components/bt/bluedroid/stack/btm/btm_dev.c b/components/bt/bluedroid/stack/btm/btm_dev.c index 2e877a85e..95a2e27ff 100644 --- a/components/bt/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/bluedroid/stack/btm/btm_dev.c @@ -60,7 +60,7 @@ static tBTM_SEC_DEV_REC *btm_find_oldest_dev (void); BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *features, UINT32 trusted_mask[], LINK_KEY link_key, UINT8 key_type, tBTM_IO_CAP io_cap, - UINT8 pin_length) + UINT8 pin_length, UINT8 sc_support) { #if (SMP_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec; @@ -98,6 +98,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, p_dev_rec->bond_type = BOND_TYPE_UNKNOWN; /* Default value */ p_dev_rec->timestamp = btm_cb.dev_rec_count++; + p_dev_rec->remote_secure_connection_previous_state = sc_support; if (dev_class) { memcpy (p_dev_rec->dev_class, dev_class, DEV_CLASS_LEN); diff --git a/components/bt/bluedroid/stack/btm/btm_devctl.c b/components/bt/bluedroid/stack/btm/btm_devctl.c index f34165b3b..f7b32ce87 100644 --- a/components/bt/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/bluedroid/stack/btm/btm_devctl.c @@ -790,13 +790,24 @@ void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len) { UINT8 i; - BTM_TRACE_DEBUG ("BTM Event: Vendor Specific event from controller"); +#if (CLASSIC_BT_INCLUDED == TRUE) + UINT8 sub_event; + UINT8 *p_evt = p; + STREAM_TO_UINT8(sub_event, p_evt); + /* Check in subevent if authentication is through Legacy Authentication. */ + if (sub_event == ESP_VS_REM_LEGACY_AUTH_CMP) { + UINT16 hci_handle; + STREAM_TO_UINT16(hci_handle, p_evt); + btm_sec_handle_remote_legacy_auth_cmp(hci_handle); + } +#endif /// (CLASSIC_BT_INCLUDED == TRUE) for (i = 0; i < BTM_MAX_VSE_CALLBACKS; i++) { if (btm_cb.devcb.p_vend_spec_cb[i]) { (*btm_cb.devcb.p_vend_spec_cb[i])(evt_len, p); } } + BTM_TRACE_DEBUG ("BTM Event: Vendor Specific event from controller"); } diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index 877d3d6d2..a6fc87334 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -2257,7 +2257,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle } } else if (!(BTM_SM4_KNOWN & p_dev_rec->sm4)) { /* the remote features are not known yet */ - BTM_TRACE_DEBUG("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__, + BTM_TRACE_ERROR("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__, (is_originator) ? "initiator" : "acceptor", p_dev_rec->sec_flags); p_dev_rec->sm4 |= BTM_SM4_REQ_PEND; @@ -3917,10 +3917,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) (BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED))) { status = HCI_SUCCESS; } + /* Currently we do not notify user if it is a keyboard which connects */ - /* User probably Disabled the keyboard while it was asleap. Let her try */ + /* User probably Disabled the keyboard while it was asleep. Let her try */ if (btm_cb.api.p_auth_complete_callback) { - /* report the suthentication status */ + /* report the authentication status */ if (old_state != BTM_PAIR_STATE_IDLE) { (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, @@ -3930,6 +3931,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; +#if (CLASSIC_BT_INCLUDED == TRUE) + btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_SELF); +#endif /* If this is a bonding procedure can disconnect the link now */ if (are_bonding) { p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE; @@ -4657,12 +4661,24 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t /* If connection was made to do bonding restore link security if changed */ btm_restore_mode(); + /* Store the previous state of secure connection as current state. Since + * this is the first encounter with the remote device, whatever the remote + * device's SC state is, it cannot lower the SC level from this. */ + p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections; + if (p_dev_rec->remote_supports_secure_connections) { + BTM_TRACE_EVENT ("Remote device supports Secure Connection"); + } else { + BTM_TRACE_EVENT ("Remote device does not support Secure Connection"); + } if (key_type != BTM_LKEY_TYPE_CHANGED_COMB) { p_dev_rec->link_key_type = key_type; } p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_KNOWN; +#if (CLASSIC_BT_INCLUDED == TRUE) + btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_NONE); +#endif /* * Until this point in time, we do not know if MITM was enabled, hence we * add the extended security flag here. @@ -4695,7 +4711,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t __FUNCTION__, p_dev_rec->link_key_type); (*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, - p_link_key, p_dev_rec->link_key_type); + p_link_key, p_dev_rec->link_key_type, + p_dev_rec->remote_supports_secure_connections); } } else { if ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) || @@ -4752,7 +4769,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t } else { (*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, - p_link_key, p_dev_rec->link_key_type); + p_link_key, p_dev_rec->link_key_type, + p_dev_rec->remote_supports_secure_connections); } } } @@ -5543,7 +5561,9 @@ static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec) if (btm_cb.api.p_link_key_callback) { (*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, p_dev_rec->link_key, - p_dev_rec->link_key_type); + p_dev_rec->link_key_type, + p_dev_rec->remote_supports_secure_connections); + } } #endif ///SMP_INCLUDED == TRUE @@ -5894,6 +5914,29 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec) BTM_TRACE_API("%s: sm4: 0x%02x, rmt_support_for_secure_connections %d\n", __FUNCTION__, p_dev_rec->sm4, p_dev_rec->remote_supports_secure_connections); + /* Store previous state of remote device to check if peer device downgraded + * it's secure connection state. */ +#if (CLASSIC_BT_INCLUDED == TRUE) + if (p_dev_rec->remote_supports_secure_connections >= p_dev_rec->remote_secure_connection_previous_state) { + p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections; + } else { + BTM_TRACE_ERROR("Remote Device downgraded security from SC, deleting Link Key"); + + /* Mark in ACL packet that secure connection is downgraded. */ + p_acl_cb->sc_downgrade = 1; + p_dev_rec->remote_secure_connection_previous_state = 0; + + /* As peer device downgraded it's security, peer device is a suspicious + * device. Hence remove pairing information by removing link key + * information. */ + memset(p_dev_rec->link_key, 0, LINK_KEY_LEN); + p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED + | BTM_SEC_ENCRYPTED | BTM_SEC_NAME_KNOWN + | BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED + | BTM_SEC_ROLE_SWITCHED | BTM_SEC_16_DIGIT_PIN_AUTHED); + return; + } +#endif if (p_dev_rec->remote_features_needed) { BTM_TRACE_EVENT("%s: Now device in SC Only mode, waiting for peer remote features!\n", @@ -6156,5 +6199,62 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec) tACL_CONN *p = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); return (p && (p->link_role == BTM_ROLE_MASTER)); } -#endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) +/******************************************************************************* +** +** Function btm_sec_legacy_authentication_mutual +** +** Description This function is called when legacy authentication is used +** and only remote device has completed the authentication +** +** Returns TRUE if aunthentication command sent successfully +** +*******************************************************************************/ +BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec) +{ + return (btm_sec_start_authentication (p_dev_rec)); +} + +/******************************************************************************* +** +** Function btm_sec_update_legacy_auth_state +** +** Description This function updates the legacy authentication state +** +** Returns void +** +*******************************************************************************/ +void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_state) +{ + if (p_acl_cb) { + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (p_acl_cb->hci_handle); + if (p_dev_rec) { + if ((BTM_BothEndsSupportSecureConnections(p_dev_rec->bd_addr) == 0) && + (legacy_auth_state != BTM_ACL_LEGACY_AUTH_NONE)) { + p_acl_cb->legacy_auth_state |= legacy_auth_state; + } else { + p_acl_cb->legacy_auth_state = BTM_ACL_LEGACY_AUTH_NONE; + } + } + } +} + +/******************************************************************************* +** +** Function btm_sec_handle_remote_legacy_auth_cmp +** +** Description This function updates the legacy authneticaiton state +** to indicate that remote device has completed the authentication +** +** Returns void +** +*******************************************************************************/ +void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle) +{ + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); + tACL_CONN *p_acl_cb = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR); + btm_sec_update_legacy_auth_state(p_acl_cb, BTM_ACL_LEGACY_AUTH_REMOTE); +} +#endif /// (CLASSIC_BT_INCLUDED == TRUE) +#endif ///SMP_INCLUDED == TRUE diff --git a/components/bt/bluedroid/stack/btm/include/btm_int.h b/components/bt/bluedroid/stack/btm/include/btm_int.h index 99f5bc7a8..fb42a9987 100644 --- a/components/bt/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/bluedroid/stack/btm/include/btm_int.h @@ -40,6 +40,8 @@ #endif #endif +#define ESP_VS_REM_LEGACY_AUTH_CMP 0x03 + #if BTM_MAX_LOC_BD_NAME_LEN > 0 typedef char tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; #endif @@ -92,6 +94,13 @@ UINT8 lmp_version; BOOLEAN in_use; UINT8 link_role; BOOLEAN link_up_issued; /* True if busy_level link up has been issued */ +BOOLEAN sc_downgrade; /* Store if security is downgraded or not. */ + +#define BTM_ACL_LEGACY_AUTH_NONE (0) +#define BTM_ACL_LEGACY_AUTH_SELF (1<<0) +#define BTM_ACL_LEGACY_AUTH_REMOTE (1<<1) +#define BTM_ACL_LEGACY_AUTH_MUTUAL (1<<2) +UINT8 legacy_auth_state; #define BTM_ACL_SWKEY_STATE_IDLE 0 #define BTM_ACL_SWKEY_STATE_MODE_CHANGE 1 @@ -592,6 +601,8 @@ typedef struct { /* "Secure Connections Only" mode and it receives */ /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */ /* it knows peer's support for Secure Connections */ + BOOLEAN remote_secure_connection_previous_state; /* Stores if peer ever supported + secure connection. This will be helpful to know when peer device downgrades it's security. */ UINT16 ble_hci_handle; /* use in DUMO connection */ UINT8 enc_key_size; /* current link encryption key size */ @@ -1146,6 +1157,10 @@ void btm_sem_free(void); void btm_lock_free(void); +void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle); +void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_state); +BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec); + /* #ifdef __cplusplus } diff --git a/components/bt/bluedroid/stack/gatt/gatt_cl.c b/components/bt/bluedroid/stack/gatt/gatt_cl.c index daa911e8c..6fbd28bb3 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_cl.c +++ b/components/bt/bluedroid/stack/gatt/gatt_cl.c @@ -219,6 +219,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act) if (p_attr) { switch (p_clcb->op_subtype) { case GATT_WRITE_NO_RSP: + l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL); p_clcb->s_handle = p_attr->handle; op_code = (sec_act == GATT_SEC_SIGN_DATA) ? GATT_SIGN_CMD_WRITE : GATT_CMD_WRITE; rt = gatt_send_write_msg(p_tcb, diff --git a/components/bt/bluedroid/stack/include/stack/btm_api.h b/components/bt/bluedroid/stack/include/stack/btm_api.h index a997e6fa5..754a2b945 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_api.h @@ -825,14 +825,15 @@ typedef UINT16 tBTM_BL_EVENT_MASK; /* the data type associated with BTM_BL_CONN_EVT */ typedef struct { - tBTM_BL_EVENT event; /* The event reported. */ - BD_ADDR_PTR p_bda; /* The address of the newly connected device */ - DEV_CLASS_PTR p_dc; /* The device class */ - BD_NAME_PTR p_bdn; /* The device name */ - UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */ + tBTM_BL_EVENT event; /* The event reported. */ + BD_ADDR_PTR p_bda; /* The address of the newly connected device */ + DEV_CLASS_PTR p_dc; /* The device class */ + BD_NAME_PTR p_bdn; /* The device name */ + UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */ + BOOLEAN sc_downgrade; /* Secure connection downgrade state. */ #if BLE_INCLUDED == TRUE - UINT16 handle; /* connection handle */ - tBT_TRANSPORT transport; /* link is LE or not */ + UINT16 handle; /* connection handle */ + tBT_TRANSPORT transport; /* link is LE or not */ #endif } tBTM_BL_CONN_DATA; @@ -1352,7 +1353,7 @@ typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, */ typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, tBTM_BD_NAME bd_name, UINT8 *key, - UINT8 key_type); + UINT8 key_type, BOOLEAN sc_support); /* Remote Name Resolved. Parameters are @@ -3406,7 +3407,8 @@ UINT8 BTM_SecClrService (UINT8 service_id); BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *features, UINT32 trusted_mask[], LINK_KEY link_key, - UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length); + UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length, + UINT8 sc_support); /******************************************************************************* diff --git a/components/bt/bluedroid/stack/include/stack/l2c_api.h b/components/bt/bluedroid/stack/include/stack/l2c_api.h index 147ed6c74..ce3156738 100644 --- a/components/bt/bluedroid/stack/include/stack/l2c_api.h +++ b/components/bt/bluedroid/stack/include/stack/l2c_api.h @@ -29,6 +29,7 @@ #include "common/bt_target.h" #include "stack/l2cdefs.h" #include "stack/hcidefs.h" +#include "osi/fixed_queue.h" /***************************************************************************** ** Constants @@ -1227,6 +1228,21 @@ extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transp extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle); +#define L2CA_GET_ATT_NUM 0 +#define L2CA_ADD_BTC_NUM 1 +#define L2CA_DECREASE_BTC_NUM 2 +#define L2CA_ADD_BTU_NUM 3 +#define L2CA_DECREASE_BTU_NUM 4 +#define L2CA_BUFF_INI 5 +#define L2CA_BUFF_DEINIT 6 + +typedef struct { + UINT16 conn_id; + UINT16 * get_num; +} tl2c_buff_param_t; + + +extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param); #endif /* (BLE_INCLUDED == TRUE) */ diff --git a/components/bt/bluedroid/stack/l2cap/include/l2c_int.h b/components/bt/bluedroid/stack/l2cap/include/l2c_int.h index d24562e51..7cfbc2003 100644 --- a/components/bt/bluedroid/stack/l2cap/include/l2c_int.h +++ b/components/bt/bluedroid/stack/l2cap/include/l2c_int.h @@ -73,7 +73,7 @@ #define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */ #define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */ #define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */ - +#define L2CAP_CACHE_ATT_ACL_NUM 10 /* Define the possible L2CAP channel states. The names of ** the states may seem a bit strange, but they are taken from ** the Bluetooth specification. @@ -165,6 +165,10 @@ typedef enum { #define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */ +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK; typedef struct { diff --git a/components/bt/bluedroid/stack/l2cap/l2c_api.c b/components/bt/bluedroid/stack/l2cap/l2c_api.c index d9fcc6ded..a9f4b891f 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_api.c @@ -36,6 +36,8 @@ #include "stack/btu.h" #include "stack/btm_api.h" #include "osi/allocator.h" +#include "gatt_int.h" +#include "freertos/semphr.h" #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* @@ -1877,6 +1879,16 @@ UINT16 L2CA_GetFreePktBufferNum_LE(void) { return l2cb.controller_le_xmit_window; } +UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id) +{ + uint16_t num = 0; + tl2c_buff_param_t param; + param.conn_id = conn_id; + param.get_num = # + l2ble_update_att_acl_pkt_num(L2CA_GET_ATT_NUM, ¶m); + return num; +} + #endif /******************************************************************************* @@ -2265,3 +2277,111 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush) return (num_left); } +/****************************************************************************** +** +** Function update_acl_pkt_num +** +** Description Update the number of att acl packets to be sent in xmit_hold_q. +** +** Returns None +** +*******************************************************************************/ + +#if BLE_INCLUDED == TRUE +void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param) +{ + static SemaphoreHandle_t buff_semaphore = NULL ; + static INT16 btc_buf; + static INT16 btu_buf; + + if(buff_semaphore == NULL && type != L2CA_BUFF_INI){ + L2CAP_TRACE_ERROR("%s buff_semaphore not init", __func__); + return; + } + switch (type) + { + case L2CA_ADD_BTC_NUM:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + btc_buf ++; + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_DECREASE_BTC_NUM:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + btc_buf --; + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_ADD_BTU_NUM:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + btu_buf ++; + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_DECREASE_BTU_NUM:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + btu_buf --; + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_GET_ATT_NUM:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + INT16 att_acl_pkt_num = 0; + INT16 att_max_num = 0; + *(param->get_num) = 0; + UINT8 tcb_idx = param->conn_id; + tGATT_TCB * p_tcb = gatt_get_tcb_by_idx(tcb_idx); + if (p_tcb == NULL){ + L2CAP_TRACE_ERROR("%s not found p_tcb", __func__); + xSemaphoreGive(buff_semaphore); + break; + } + tL2C_LCB * p_lcb = l2cu_find_lcb_by_bd_addr (p_tcb->peer_bda, BT_TRANSPORT_LE); + if (p_lcb == NULL){ + L2CAP_TRACE_ERROR("%s not found p_lcb", __func__); + xSemaphoreGive(buff_semaphore); + break; + } + fixed_queue_t * queue = p_lcb->p_fixed_ccbs[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q; + att_max_num = MIN(p_lcb->link_xmit_quota, L2CAP_CACHE_ATT_ACL_NUM); + if (queue == NULL){ + L2CAP_TRACE_ERROR("%s not found queue", __func__); + xSemaphoreGive(buff_semaphore); + break; + } + att_acl_pkt_num = fixed_queue_length(queue); + if(att_acl_pkt_num < att_max_num){ + if(btc_buf + btu_buf < att_max_num - att_acl_pkt_num){ + *(param->get_num) = att_max_num - att_acl_pkt_num - (btc_buf + btu_buf); + } + } + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_BUFF_INI:{ + btc_buf = 0; + btu_buf = 0; + buff_semaphore = xSemaphoreCreateBinary(); + if (buff_semaphore == NULL) { + L2CAP_TRACE_ERROR("%s NO MEMORY", __func__); + break; + } + xSemaphoreGive(buff_semaphore); + break; + } + case L2CA_BUFF_DEINIT:{ + xSemaphoreTake(buff_semaphore, portMAX_DELAY); + btc_buf = 0; + btu_buf = 0; + xSemaphoreGive(buff_semaphore); + vSemaphoreDelete(buff_semaphore); + buff_semaphore = NULL; + break; + } + default: + break; + } +} +#endif + + diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index ea1990fc3..41a437c98 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -1127,6 +1127,12 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) #endif { + //need check flag: partial_segment_being_sent. + if ( (p_lcb->partial_segment_being_sent) + || (p_lcb->link_state != LST_CONNECTED) + || (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) { + break; + } //L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb)); if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) { break; diff --git a/components/bt/bluedroid/stack/l2cap/l2c_main.c b/components/bt/bluedroid/stack/l2cap/l2c_main.c index 1035b44c6..2f8034286 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_main.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_main.c @@ -880,6 +880,10 @@ void l2c_init (void) if (l2cb.rcv_pending_q == NULL) { L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__); } + +#if BLE_INCLUDED == TRUE + l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL); +#endif } void l2c_free(void) @@ -889,6 +893,9 @@ void l2c_free(void) #if L2C_DYNAMIC_MEMORY FREE_AND_RESET(l2c_cb_ptr); #endif +#if BLE_INCLUDED == TRUE + l2ble_update_att_acl_pkt_num(L2CA_BUFF_DEINIT, NULL); +#endif } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 8388df027..e6389413b 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -3657,7 +3657,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb) } else { tL2C_LCB *p_lcb = p_ccb->p_lcb; /* If this channel was not congested but it is congested now, tell the app */ - if ((q_count > p_ccb->buff_quota) || (p_lcb && (p_ccb->local_cid == L2CAP_ATT_CID) && (p_lcb->link_xmit_quota > 0) && (p_lcb->link_xmit_quota <= p_lcb->sent_not_acked))) { + if (q_count > p_ccb->buff_quota || (p_lcb && (p_lcb->link_xmit_data_q) && (list_length(p_lcb->link_xmit_data_q) + q_count) > p_ccb->buff_quota)) { p_ccb->cong_sent = TRUE; if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb) { L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u", diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 53f77629a..d20f9416a 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -164,6 +164,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout) return BT_STATUS_SUCCESS; } +/** + * transfer an message to another module in the different task. + * @param msg message + * @param arg paramter + * @param arg_len length of paramter + * @param copy_func deep copy function + * @return BT_STATUS_SUCCESS: success + * others: fail + */ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func) { btc_msg_t lmsg; @@ -192,6 +201,32 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg return btc_task_post(&lmsg, TASK_POST_BLOCKING); } +/** + * transfer an message to another module in tha same task. + * @param msg message + * @param arg paramter + * @return BT_STATUS_SUCCESS: success + * others: fail + */ +bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg) +{ + if (msg == NULL) { + return BT_STATUS_PARM_INVALID; + } + + msg->arg = arg; + switch (msg->sig) { + case BTC_SIG_API_CALL: + profile_tab[msg->pid].btc_call(msg); + break; + case BTC_SIG_API_CB: + profile_tab[msg->pid].btc_cb(msg); + break; + default: + break; + } + return BT_STATUS_SUCCESS; +} int btc_init(void) { diff --git a/components/bt/common/btc/include/btc/btc_task.h b/components/bt/common/btc/include/btc/btc_task.h index 00b63e55c..8e6cb6a67 100644 --- a/components/bt/common/btc/include/btc/btc_task.h +++ b/components/bt/common/btc/include/btc/btc_task.h @@ -92,8 +92,26 @@ typedef struct { typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src); +/** + * transfer an message to another module in the different task. + * @param msg message + * @param arg paramter + * @param arg_len length of paramter + * @param copy_func deep copy function + * @return BT_STATUS_SUCCESS: success + * others: fail + */ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func); +/** + * transfer an message to another module in tha same task. + * @param msg message + * @param arg paramter + * @return BT_STATUS_SUCCESS: success + * others: fail + */ +bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg); + int btc_init(void); void btc_deinit(void); bool btc_check_queue_is_congest(void); diff --git a/components/bt/common/osi/config.c b/components/bt/common/osi/config.c index 698c37be0..79ffded89 100644 --- a/components/bt/common/osi/config.c +++ b/components/bt/common/osi/config.c @@ -267,6 +267,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key) assert(config != NULL); assert(section != NULL); assert(key != NULL); + bool ret; section_t *sec = section_find(config, section); entry_t *entry = entry_find(config, section, key); @@ -274,7 +275,12 @@ bool config_remove_key(config_t *config, const char *section, const char *key) return false; } - return list_remove(sec->entries, entry); + ret = list_remove(sec->entries, entry); + if (list_length(sec->entries) == 0) { + OSI_TRACE_DEBUG("%s remove section name:%s",__func__, section); + ret &= config_remove_section(config, section); + } + return ret; } const config_section_node_t *config_section_begin(const config_t *config) diff --git a/components/bt/component.mk b/components/bt/component.mk index 04061b160..dcae29a6c 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -139,6 +139,7 @@ endif ifdef CONFIG_BLE_MESH COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \ + esp_ble_mesh/mesh_common/tinycrypt/include \ esp_ble_mesh/mesh_core \ esp_ble_mesh/mesh_core/include \ esp_ble_mesh/mesh_core/storage \ @@ -151,9 +152,11 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \ esp_ble_mesh/api COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \ + esp_ble_mesh/mesh_common/tinycrypt/src \ esp_ble_mesh/mesh_core \ esp_ble_mesh/mesh_core/storage \ esp_ble_mesh/btc \ + esp_ble_mesh/mesh_models/common \ esp_ble_mesh/mesh_models/client \ esp_ble_mesh/mesh_models/server \ esp_ble_mesh/api/core \ diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c index 832e03dbb..09e453a2a 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_common_api.c @@ -42,7 +42,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp // Create a semaphore if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) { - BT_ERR("%s, Failed to allocate memory for the semaphore", __func__); + BT_ERR("Failed to create semaphore"); return ESP_ERR_NO_MEM; } @@ -57,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) { vSemaphoreDelete(semaphore); - BT_ERR("%s, BLE Mesh initialise failed", __func__); + BT_ERR("Failed to start mesh init"); return ESP_FAIL; } diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c index 943c91bff..568b07992 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c @@ -32,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void) return btc_ble_mesh_get_primary_addr(); } -uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr) +uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, + uint16_t group_addr) { if (model == NULL) { return NULL; @@ -54,7 +55,7 @@ uint8_t esp_ble_mesh_get_element_count(void) } esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element, - uint16_t company_id, uint16_t model_id) + uint16_t company_id, uint16_t model_id) { if (element == NULL) { return NULL; @@ -62,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t * return btc_ble_mesh_model_find_vnd(element, company_id, model_id); } -esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id) +esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, + uint16_t model_id) { if (element == NULL) { return NULL; diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c index db6b6a144..f614798ca 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c @@ -23,12 +23,12 @@ #define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12) static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, - uint32_t opcode, - btc_ble_mesh_model_act_t act, - uint16_t length, uint8_t *data, - int32_t msg_timeout, bool need_rsp, - esp_ble_mesh_dev_role_t device_role) + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + btc_ble_mesh_model_act_t act, + uint16_t length, uint8_t *data, + int32_t msg_timeout, bool need_rsp, + esp_ble_mesh_dev_role_t device_role) { btc_ble_mesh_model_args_t arg = {0}; uint8_t op_len = 0, mic_len = 0; @@ -39,12 +39,12 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) { - BT_ERR("%s, Invalid destination address 0x0000", __func__); + BT_ERR("Invalid destination address 0x0000"); return ESP_ERR_INVALID_ARG; } if (device_role > ROLE_FAST_PROV) { - BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role); + BT_ERR("Invalid device role 0x%02x", device_role); return ESP_ERR_INVALID_ARG; } @@ -63,7 +63,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) { if (op_len + length > model->pub->msg->size) { - BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size); + BT_ERR("Too small publication msg size %d", model->pub->msg->size); return ESP_ERR_INVALID_ARG; } } @@ -75,7 +75,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, } if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) { - BT_ERR("%s, Data length %d is too large", __func__, length); + BT_ERR("Too large data length %d", length); return ESP_ERR_INVALID_ARG; } @@ -176,8 +176,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model) } esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, - uint16_t length, uint8_t *data) + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + uint16_t length, uint8_t *data) { if (model == NULL || ctx == NULL || ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED || @@ -190,9 +191,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, } esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, - uint16_t length, uint8_t *data, int32_t msg_timeout, - bool need_rsp, esp_ble_mesh_dev_role_t device_role) + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + uint16_t length, uint8_t *data, + int32_t msg_timeout, bool need_rsp, + esp_ble_mesh_dev_role_t device_role) { if (model == NULL || ctx == NULL || ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED || @@ -218,8 +221,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod } esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model, - esp_ble_mesh_server_state_type_t type, - esp_ble_mesh_server_state_value_t *value) + esp_ble_mesh_server_state_type_t type, + esp_ble_mesh_server_state_value_t *value) { btc_ble_mesh_model_args_t arg = {0}; btc_msg_t msg = {0}; @@ -294,7 +297,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name) return bt_mesh_provisioner_get_node_index(name); } -esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length) +esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, + uint8_t *data, uint16_t length) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -334,6 +338,25 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicas return btc_ble_mesh_provisioner_get_node_with_addr(unicast_addr); } +esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name) +{ + if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) { + return NULL; + } + + return btc_ble_mesh_provisioner_get_node_with_name(name); +} + +uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void) +{ + return btc_ble_mesh_provisioner_get_prov_node_count(); +} + +const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void) +{ + return btc_ble_mesh_provisioner_get_node_table_entry(); +} + esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]) { btc_ble_mesh_prov_args_t arg = {0}; @@ -377,7 +400,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr) } esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], - uint16_t net_idx, uint16_t app_idx) + uint16_t net_idx, uint16_t app_idx) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -400,7 +423,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], } esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16], - uint16_t net_idx, uint16_t app_idx) + uint16_t net_idx, uint16_t app_idx) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -428,7 +451,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint } esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx, - uint16_t model_id, uint16_t company_id) + uint16_t model_id, uint16_t company_id) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -501,12 +524,6 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx) { return bt_mesh_provisioner_local_net_key_get(net_idx); } - -uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void) -{ - return btc_ble_mesh_provisioner_get_prov_node_count(); -} - #endif /* CONFIG_BLE_MESH_PROVISIONER */ #if (CONFIG_BLE_MESH_FAST_PROV) diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c index 9fbbd6b59..c34b9a4f0 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c @@ -35,11 +35,29 @@ bool esp_ble_mesh_node_is_provisioned(void) return bt_mesh_is_provisioned(); } +static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers) +{ + if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) || + (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && + !IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && + !(bearers & ESP_BLE_MESH_PROV_ADV)) || + (!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && + !(bearers & ESP_BLE_MESH_PROV_GATT))) { + return false; + } + return true; +} + esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; + if (prov_bearers_valid(bearers) == false) { + return ESP_ERR_INVALID_ARG; + } + ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); msg.sig = BTC_SIG_API_CALL; @@ -56,6 +74,10 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers) btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; + if (prov_bearers_valid(bearers) == false) { + return ESP_ERR_INVALID_ARG; + } + ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); msg.sig = BTC_SIG_API_CALL; @@ -68,7 +90,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers) } esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32], - uint8_t private_key[32]) + uint8_t private_key[32]) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -157,7 +179,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name) #if (CONFIG_BLE_MESH_PROVISIONER) esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32], - uint8_t pub_key_y[32]) + uint8_t pub_key_y[32]) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -232,6 +254,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; + if (prov_bearers_valid(bearers) == false) { + return ESP_ERR_INVALID_ARG; + } + ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); msg.sig = BTC_SIG_API_CALL; @@ -249,6 +275,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; + if (prov_bearers_valid(bearers) == false) { + return ESP_ERR_INVALID_ARG; + } + ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); msg.sig = BTC_SIG_API_CALL; @@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare } esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev, - esp_ble_mesh_dev_add_flag_t flags) + esp_ble_mesh_dev_add_flag_t flags) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -288,8 +318,10 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t } esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], - esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type, - esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr) + esp_ble_mesh_bd_addr_t addr, + esp_ble_mesh_addr_type_t addr_type, + esp_ble_mesh_prov_bearer_t bearer, + uint16_t oob_info, uint16_t unicast_addr) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -347,7 +379,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_ } esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len, - uint8_t offset, bool prov_after_match) + uint8_t offset, bool prov_after_match) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c index 31a3aa9ab..75d5519cd 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c @@ -60,7 +60,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void) } esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr, - esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx) + esp_ble_mesh_addr_type_t addr_type, + uint16_t net_idx) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -100,8 +101,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, - uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type) +esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx, + esp_ble_mesh_proxy_filter_type_t filter_type) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -124,8 +125,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num) +esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx, + uint16_t *addr, uint16_t addr_num) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -149,8 +150,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num) +esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx, + uint16_t *addr, uint16_t addr_num) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h index 0cd702e69..7dd4f7a54 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h @@ -55,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void); * to 0x0000 in order to unsubscribe the model from the group. * */ -uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr); +uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, + uint16_t group_addr); /** * @brief Find the BLE Mesh element pointer via the element address. @@ -87,7 +88,7 @@ uint8_t esp_ble_mesh_get_element_count(void); * */ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element, - uint16_t company_id, uint16_t model_id); + uint16_t company_id, uint16_t model_id); /** * @brief Find the SIG model with the given element and Model id. @@ -98,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t * * @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found. * */ -esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id); +esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, + uint16_t model_id); /** * @brief Get the Composition data which has been registered. diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h index c2def986f..86db8a1da 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h @@ -23,7 +23,7 @@ extern "C" { /** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */ typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event, - esp_ble_mesh_model_cb_param_t *param); + esp_ble_mesh_model_cb_param_t *param); /** * @brief Register BLE Mesh callback for user-defined models' operations. @@ -104,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model); * */ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, - uint16_t length, uint8_t *data); + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + uint16_t length, uint8_t *data); /** * @brief Send client model message (such as model get, set, etc). @@ -123,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model, * */ esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, - uint16_t length, uint8_t *data, int32_t msg_timeout, - bool need_rsp, esp_ble_mesh_dev_role_t device_role); + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + uint16_t length, uint8_t *data, + int32_t msg_timeout, bool need_rsp, + esp_ble_mesh_dev_role_t device_role); /** * @brief Send a model publication message. @@ -166,8 +169,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod * */ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model, - esp_ble_mesh_server_state_type_t type, - esp_ble_mesh_server_state_value_t *value); + esp_ble_mesh_server_state_type_t type, + esp_ble_mesh_server_state_value_t *value); /** * @brief Reset the provisioning procedure of the local BLE Mesh node. @@ -226,7 +229,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name); * @return ESP_OK on success or error code otherwise. * */ -esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length); +esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, + uint8_t *data, uint16_t length); /** * @brief This function is called to get the provisioned node information @@ -250,6 +254,48 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t u */ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); +/** + * @brief This function is called to get the provisioned node information + * with the node name. + * + * @param[in] name: Name of the node (end by '\0'). + * + * @return Pointer of the node info struct or NULL on failure. + * + */ +esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name); + +/** + * @brief This function is called by Provisioner to get provisioned node count. + * + * @return Number of the provisioned nodes. + * + */ +uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void); + +/** + * @brief This function is called by Provisioner to get the entry of the node table. + * + * @note After invoking the function to get the entry of nodes, users can use the "for" + * loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's + * information. Before trying to read the node's information, users need to check + * if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL. + * For example: + * ``` + * const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry(); + * for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) { + * const esp_ble_mesh_node_t *node = entry[i]; + * if (node) { + * ...... + * } + * } + * ``` + * + * @return Pointer to the start of the node table. + * + */ +const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void); + /** * @brief This function is called to delete the provisioned node information * with the node device uuid. @@ -287,7 +333,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr); * @return ESP_OK on success or error code otherwise. * */ -esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx); +esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], + uint16_t net_idx, uint16_t app_idx); /** * @brief This function is used to update a local AppKey for Provisioner. @@ -300,7 +347,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], * */ esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16], - uint16_t net_idx, uint16_t app_idx); + uint16_t net_idx, uint16_t app_idx); /** * @brief This function is called by Provisioner to get the local app key value. @@ -328,7 +375,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint * */ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx, - uint16_t model_id, uint16_t company_id); + uint16_t model_id, uint16_t company_id); /** * @brief This function is called by Provisioner to add local network key. @@ -366,14 +413,6 @@ esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16 */ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx); -/** - * @brief This function is called by Provisioner to get provisioned node count. - * - * @return Number of the provisioned nodes. - * - */ -uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void); - /** * @brief This function is called to get fast provisioning application key. * diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h index 1df936390..9add289a1 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h @@ -76,7 +76,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers); * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32], - uint8_t private_key[32]); + uint8_t private_key[32]); /** * @brief Provide provisioning input OOB number. @@ -128,7 +128,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name); * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32], - uint8_t pub_key_y[32]); + uint8_t pub_key_y[32]); /** * @brief Provide provisioning input OOB string. @@ -232,7 +232,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare * */ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev, - esp_ble_mesh_dev_add_flag_t flags); + esp_ble_mesh_dev_add_flag_t flags); /** @brief Provision an unprovisioned device with fixed unicast address. * @@ -257,16 +257,17 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t * and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner. */ esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], - esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type, - esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr); + esp_ble_mesh_bd_addr_t addr, + esp_ble_mesh_addr_type_t addr_type, + esp_ble_mesh_prov_bearer_t bearer, + uint16_t oob_info, uint16_t unicast_addr); /** - * @brief Delete device from queue, reset current provisioning link and reset the node. + * @brief Delete device from queue, and reset current provisioning link with the device. * - * @note If the device is in the queue, remove it from the queue; if the device is being - * provisioned, terminate the provisioning procedure; if the device has already - * been provisioned, reset the device. And either one of the addr or device UUID - * can be input. + * @note If the device is in the queue, remove it from the queue; if the device is + * being provisioned, terminate the provisioning procedure. Either one of the + * device address or device UUID can be used as input. * * @param[in] del_dev: Pointer to a struct containing the device information. * @@ -290,8 +291,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_ * */ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type, - const uint8_t adv_type, const uint8_t *dev_uuid, - uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer); + const uint8_t adv_type, const uint8_t *dev_uuid, + uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer); /** * @brief This function is called by Provisioner to set the part of the device UUID @@ -307,7 +308,7 @@ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, co * */ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len, - uint8_t offset, bool prov_after_match); + uint8_t offset, bool prov_after_match); /** * @brief This function is called by Provisioner to set provisioning data information diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h index 00537558c..6f6f4d0c1 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h @@ -65,7 +65,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void); * */ esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr, - esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx); + esp_ble_mesh_addr_type_t addr_type, + uint16_t net_idx); /** * @brief Proxy Client terminates a connection with the Proxy Server. @@ -87,8 +88,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle); * @return ESP_OK on success or error code otherwise. * */ -esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, - uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type); +esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx, + esp_ble_mesh_proxy_filter_type_t filter_type); /** * @brief Proxy Client adds address to the Proxy Server filter list. @@ -101,8 +102,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, * @return ESP_OK on success or error code otherwise. * */ -esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num); +esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx, + uint16_t *addr, uint16_t addr_num); /** * @brief Proxy Client removes address from the Proxy Server filter list. @@ -115,8 +116,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, * @return ESP_OK on success or error code otherwise. * */ -esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num); +esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx, + uint16_t *addr, uint16_t addr_num); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h index 046e1e135..8992ce17e 100644 --- a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h +++ b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -61,6 +61,12 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN]; /*!< Invalid Company ID */ #define ESP_BLE_MESH_CID_NVAL 0xFFFF +/*!< Special TTL value to request using configured default TTL */ +#define ESP_BLE_MESH_TTL_DEFAULT 0xFF + +/*!< Maximum allowed TTL value */ +#define ESP_BLE_MESH_TTL_MAX 0x7F + #define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000 #define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF #define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC @@ -265,7 +271,7 @@ typedef enum { #define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1)) #define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid)) -/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */ +/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */ #define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \ { \ .model_id = (_id), \ @@ -278,7 +284,7 @@ typedef enum { .user_data = _user_data, \ } -/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */ +/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */ #define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \ { \ .vnd.company_id = (_company), \ @@ -455,6 +461,17 @@ typedef struct { */ #define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0} +/** Abstraction that describes a model callback structure. + * This structure is associated with struct bt_mesh_model_cb in mesh_access.h. + */ +typedef struct { + /** Callback used during model initialization. Initialized by the stack. */ + esp_ble_mesh_cb_t init_cb; + + /** Callback used during model deinitialization. Initialized by the stack. */ + esp_ble_mesh_cb_t deinit_cb; +} esp_ble_mesh_model_cbs_t; + /** Abstraction that describes a Mesh Model instance. * This structure is associated with struct bt_mesh_model in mesh_access.h */ @@ -488,6 +505,9 @@ struct esp_ble_mesh_model { /** Model operation context */ esp_ble_mesh_model_op_t *op; + /** Model callback structure */ + esp_ble_mesh_model_cbs_t *cb; + /** Model-specific user data */ void *user_data; }; @@ -522,7 +542,7 @@ typedef struct { /** Force sending reliably by using segment acknowledgement */ uint8_t send_rel: 1; - /** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */ + /** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */ uint8_t send_ttl; /** Opcode of a received message. Not used for sending message. */ @@ -809,7 +829,7 @@ typedef enum { ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */ ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */ ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */ - ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device if it exists and remove the device from network completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */ ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */ ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */ ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */ @@ -1112,6 +1132,7 @@ typedef union { */ struct ble_mesh_provisioner_add_local_app_key_comp_param { int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ uint16_t app_idx; /*!< AppKey Index */ } provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */ /** @@ -1156,14 +1177,14 @@ typedef union { /** * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */ - struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_comp_param { + struct ble_mesh_provisioner_delete_node_with_uuid_comp_param { int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */ uint8_t uuid[16]; /*!< Node device uuid */ } provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */ /** * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */ - struct ble_mesh_provisioner_delete_node_with_addr_comp_data_comp_param { + struct ble_mesh_provisioner_delete_node_with_addr_comp_param { int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */ uint16_t unicast_addr; /*!< Node unicast address */ } provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */ @@ -1954,8 +1975,8 @@ typedef struct { int64_t timestamp; /*!< Time when the last message is received */ } esp_ble_mesh_last_msg_info_t; -#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response will be sent internally */ -#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response need to be sent in the application */ +#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */ +#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */ /** Parameters of the Server Model response control */ typedef struct { diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c index c41933984..e0807815c 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c @@ -53,7 +53,7 @@ static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode) } esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_get_state_t *get_state) + esp_ble_mesh_cfg_client_get_state_t *get_state) { btc_ble_mesh_config_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -78,7 +78,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_ } esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_set_state_t *set_state) + esp_ble_mesh_cfg_client_set_state_t *set_state) { btc_ble_mesh_config_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c index b93a1f97f..27a55cbb8 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c @@ -40,7 +40,7 @@ static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode) } esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_generic_client_get_state_t *get_state) + esp_ble_mesh_generic_client_get_state_t *get_state) { btc_ble_mesh_generic_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -66,7 +66,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param } esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_generic_client_set_state_t *set_state) + esp_ble_mesh_generic_client_set_state_t *set_state) { btc_ble_mesh_generic_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c index 7c3b666f6..dd6029411 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c @@ -34,7 +34,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve } esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_get_state_t *get_state) + esp_ble_mesh_health_client_get_state_t *get_state) { btc_ble_mesh_health_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -60,7 +60,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_ } esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_set_state_t *set_state) + esp_ble_mesh_health_client_set_state_t *set_state) { btc_ble_mesh_health_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c index 127941b41..02262f8cf 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c @@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_ } esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_light_client_get_state_t *get_state) + esp_ble_mesh_light_client_get_state_t *get_state) { btc_ble_mesh_lighting_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t } esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_light_client_set_state_t *set_state) + esp_ble_mesh_light_client_set_state_t *set_state) { btc_ble_mesh_lighting_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c index 8bf77b385..45ee3863d 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c @@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien } esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_sensor_client_get_state_t *get_state) + esp_ble_mesh_sensor_client_get_state_t *get_state) { btc_ble_mesh_sensor_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -52,7 +52,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_ } esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_sensor_client_set_state_t *set_state) + esp_ble_mesh_sensor_client_set_state_t *set_state) { btc_ble_mesh_sensor_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c index bd71ea7cd..5df12d965 100644 --- a/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c +++ b/components/bt/esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c @@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce } esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_time_scene_client_get_state_t *get_state) + esp_ble_mesh_time_scene_client_get_state_t *get_state) { btc_ble_mesh_time_scene_client_args_t arg = {0}; btc_msg_t msg = {0}; @@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa } esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_time_scene_client_set_state_t *set_state) + esp_ble_mesh_time_scene_client_set_state_t *set_state) { btc_ble_mesh_time_scene_client_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h index 06d45e9bb..2d5c6d45a 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h @@ -756,7 +756,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event, - esp_ble_mesh_cfg_client_cb_param_t *param); + esp_ble_mesh_cfg_client_cb_param_t *param); /** * @brief Configuration Server Model callback function type @@ -764,7 +764,7 @@ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event, - esp_ble_mesh_cfg_server_cb_param_t *param); + esp_ble_mesh_cfg_server_cb_param_t *param); /** * @brief Register BLE Mesh Config Client Model callback. @@ -800,7 +800,7 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c * */ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_get_state_t *get_state); + esp_ble_mesh_cfg_client_get_state_t *get_state); /** * @brief Set the value of the Configuration Server Model states using the Config Client Model set messages. @@ -816,7 +816,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_ * */ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_cfg_client_set_state_t *set_state); + esp_ble_mesh_cfg_client_set_state_t *set_state); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h index e1758e179..db908edbb 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h @@ -483,7 +483,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event, - esp_ble_mesh_generic_client_cb_param_t *param); + esp_ble_mesh_generic_client_cb_param_t *param); /** * @brief Register BLE Mesh Generic Client Model callback. @@ -509,7 +509,7 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli * */ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_generic_client_get_state_t *get_state); + esp_ble_mesh_generic_client_get_state_t *get_state); /** * @brief Set the value of Generic Server Model states using the Generic Client Model set messages. @@ -525,7 +525,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param * */ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_generic_client_set_state_t *set_state); + esp_ble_mesh_generic_client_set_state_t *set_state); /** * @brief Generic Server Models related context. @@ -1285,7 +1285,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event, - esp_ble_mesh_generic_server_cb_param_t *param); + esp_ble_mesh_generic_server_cb_param_t *param); /** * @brief Register BLE Mesh Generic Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h index e46ae79e3..69a642900 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h @@ -335,7 +335,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event, - esp_ble_mesh_health_client_cb_param_t *param); + esp_ble_mesh_health_client_cb_param_t *param); /** * @brief Health Server Model callback function type @@ -343,7 +343,7 @@ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_e * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event, - esp_ble_mesh_health_server_cb_param_t *param); + esp_ble_mesh_health_server_cb_param_t *param); /** * @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events. @@ -379,7 +379,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve * */ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_get_state_t *get_state); + esp_ble_mesh_health_client_get_state_t *get_state); /** * @brief This function is called to set the Health Server states using the Health Client Model set messages. @@ -395,7 +395,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_ * */ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_health_client_set_state_t *set_state); + esp_ble_mesh_health_client_set_state_t *set_state); /** * @brief This function is called by the Health Server Model to update the context of its Health Current status. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h index 4180eb914..a0377ca06 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h @@ -539,7 +539,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event, - esp_ble_mesh_light_client_cb_param_t *param); + esp_ble_mesh_light_client_cb_param_t *param); /** * @brief Register BLE Mesh Light Client Model callback. @@ -565,7 +565,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_ * */ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_light_client_get_state_t *get_state); + esp_ble_mesh_light_client_get_state_t *get_state); /** * @brief Set the value of Light Server Model states using the Light Client Model set messages. @@ -581,7 +581,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t * */ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_light_client_set_state_t *set_state); + esp_ble_mesh_light_client_set_state_t *set_state); /** * @brief Lighting Server Models related context. @@ -1663,7 +1663,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event, - esp_ble_mesh_lighting_server_cb_param_t *param); + esp_ble_mesh_lighting_server_cb_param_t *param); /** * @brief Register BLE Mesh Lighting Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h index 5c43efe18..0c4343a8c 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h @@ -215,7 +215,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event, - esp_ble_mesh_sensor_client_cb_param_t *param); + esp_ble_mesh_sensor_client_cb_param_t *param); /** * @brief Register BLE Mesh Sensor Client Model callback. @@ -241,7 +241,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien * */ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_sensor_client_get_state_t *get_state); + esp_ble_mesh_sensor_client_get_state_t *get_state); /** * @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages. @@ -257,7 +257,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_ * */ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_sensor_client_set_state_t *set_state); + esp_ble_mesh_sensor_client_set_state_t *set_state); /** * @brief Sensor Server Models related context. @@ -698,7 +698,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event, - esp_ble_mesh_sensor_server_cb_param_t *param); + esp_ble_mesh_sensor_server_cb_param_t *param); /** * @brief Register BLE Mesh Sensor Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h index f6414b709..690cab718 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h @@ -276,7 +276,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event, - esp_ble_mesh_time_scene_client_cb_param_t *param); + esp_ble_mesh_time_scene_client_cb_param_t *param); /** * @brief Register BLE Mesh Time Scene Client Model callback. @@ -301,7 +301,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_time_scene_client_get_state_t *get_state); + esp_ble_mesh_time_scene_client_get_state_t *get_state); /** * @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages. @@ -316,7 +316,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params, - esp_ble_mesh_time_scene_client_set_state_t *set_state); + esp_ble_mesh_time_scene_client_set_state_t *set_state); /** * @brief Time Scene Server Models related context. @@ -900,7 +900,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event, - esp_ble_mesh_time_scene_server_cb_param_t *param); + esp_ble_mesh_time_scene_server_cb_param_t *param); /** * @brief Register BLE Mesh Time and Scenes Server Model callback. diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 5c15b1148..170ed4ff1 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -20,12 +20,10 @@ #include "cfg_cli.h" #include "esp_ble_mesh_config_model_api.h" -extern s32_t config_msg_timeout; - /* Configuration Client Model related functions */ static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event, - esp_ble_mesh_cfg_client_cb_param_t *param) + esp_ble_mesh_cfg_client_cb_param_t *param) { esp_ble_mesh_cfg_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_CLIENT); @@ -51,7 +49,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->cfg_client_get_state.get_state) { @@ -60,7 +58,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state, sizeof(esp_ble_mesh_cfg_client_get_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -71,7 +69,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->cfg_client_set_state.set_state) { @@ -80,13 +78,13 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state, sizeof(esp_ble_mesh_cfg_client_set_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -138,7 +136,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -157,7 +155,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.comp_data_status.composition_data->len; p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.comp_data_status.composition_data) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data, @@ -173,7 +171,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.model_sub_list.sub_addr->len; p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.model_sub_list.sub_addr) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr, @@ -187,7 +185,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.netkey_list.net_idx->len; p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.netkey_list.net_idx) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx, @@ -201,7 +199,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.appkey_list.app_idx->len; p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.appkey_list.app_idx) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx, @@ -217,7 +215,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.model_app_list.app_idx->len; p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.model_app_list.app_idx) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx, @@ -306,18 +304,17 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param msg.pid = BTC_PID_CONFIG_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t), + btc_ble_mesh_config_client_copy_req_data); } void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_cfg_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -339,7 +336,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown config client event type %d", __func__, evt_type); + BT_ERR("Unknown Config client event type %d", evt_type); return; } @@ -351,38 +348,38 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_config_client_callback(&cb_params, act); return; } -void btc_ble_mesh_config_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_config_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_get_state_t *get) { - struct bt_mesh_msg_ctx ctx = {0}; + bt_mesh_client_common_param_t param = {0}; if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); @@ -401,7 +398,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET: case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET: if (get == NULL) { - BT_ERR("%s, Invalid config client get", __func__); + BT_ERR("Invalid Configuration Get"); return -EINVAL; } break; @@ -409,63 +406,65 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param break; } - ctx.net_idx = params->ctx.net_idx; - ctx.app_idx = BLE_MESH_KEY_DEV; - ctx.addr = params->ctx.addr; - ctx.send_rel = params->ctx.send_rel; - ctx.send_ttl = params->ctx.send_ttl; + param.opcode = params->opcode; + param.model = (struct bt_mesh_model *)params->model; + param.ctx.net_idx = params->ctx.net_idx; + param.ctx.app_idx = BLE_MESH_KEY_DEV; + param.ctx.addr = params->ctx.addr; + param.ctx.send_rel = params->ctx.send_rel; + param.ctx.send_ttl = params->ctx.send_ttl; + param.msg_timeout = params->msg_timeout; + param.msg_role = params->msg_role; - config_msg_timeout = params->msg_timeout; - - switch (params->opcode) { + switch (param.opcode) { case ESP_BLE_MESH_MODEL_OP_BEACON_GET: - return bt_mesh_cfg_beacon_get(&ctx); + return bt_mesh_cfg_beacon_get(¶m); case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET: - return bt_mesh_cfg_ttl_get(&ctx); + return bt_mesh_cfg_ttl_get(¶m); case ESP_BLE_MESH_MODEL_OP_FRIEND_GET: - return bt_mesh_cfg_friend_get(&ctx); + return bt_mesh_cfg_friend_get(¶m); case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET: - return bt_mesh_cfg_gatt_proxy_get(&ctx); + return bt_mesh_cfg_gatt_proxy_get(¶m); case ESP_BLE_MESH_MODEL_OP_RELAY_GET: - return bt_mesh_cfg_relay_get(&ctx); + return bt_mesh_cfg_relay_get(¶m); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET: - return bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr, + return bt_mesh_cfg_mod_pub_get(¶m, get->model_pub_get.element_addr, get->model_pub_get.model_id, get->model_pub_get.company_id); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET: - return bt_mesh_cfg_hb_pub_get(&ctx); + return bt_mesh_cfg_hb_pub_get(¶m); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET: - return bt_mesh_cfg_hb_sub_get(&ctx); + return bt_mesh_cfg_hb_sub_get(¶m); case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET: - return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page); + return bt_mesh_cfg_comp_data_get(¶m, get->comp_data_get.page); case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET: - return bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr, + return bt_mesh_cfg_mod_sub_get(¶m, get->sig_model_sub_get.element_addr, get->sig_model_sub_get.model_id); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET: - return bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr, + return bt_mesh_cfg_mod_sub_get_vnd(¶m, get->vnd_model_sub_get.element_addr, get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id); case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET: - return bt_mesh_cfg_net_key_get(&ctx); + return bt_mesh_cfg_net_key_get(¶m); case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET: - return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx); + return bt_mesh_cfg_app_key_get(¶m, get->app_key_get.net_idx); case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET: - return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx); + return bt_mesh_cfg_node_identity_get(¶m, get->node_identity_get.net_idx); case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET: - return bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr, + return bt_mesh_cfg_mod_app_get(¶m, get->sig_model_app_get.element_addr, get->sig_model_app_get.model_id); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET: - return bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr, + return bt_mesh_cfg_mod_app_get_vnd(¶m, get->vnd_model_app_get.element_addr, get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET: - return bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx); + return bt_mesh_cfg_kr_phase_get(¶m, get->kr_phase_get.net_idx); case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET: - return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr); + return bt_mesh_cfg_lpn_timeout_get(¶m, get->lpn_pollto_get.lpn_addr); case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET: - return bt_mesh_cfg_net_transmit_get(&ctx); + return bt_mesh_cfg_net_transmit_get(¶m); default: - BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); + BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode); return -EINVAL; } @@ -475,7 +474,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_set_state_t *set) { - struct bt_mesh_msg_ctx ctx = {0}; + bt_mesh_client_common_param_t param = {0}; if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); @@ -483,39 +482,41 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param } if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) { - BT_ERR("%s, Invalid config client set", __func__); + BT_ERR("Invalid Configuration Set"); return -EINVAL; } - ctx.net_idx = params->ctx.net_idx; - ctx.app_idx = BLE_MESH_KEY_DEV; - ctx.addr = params->ctx.addr; - ctx.send_rel = params->ctx.send_rel; - ctx.send_ttl = params->ctx.send_ttl; + param.opcode = params->opcode; + param.model = (struct bt_mesh_model *)params->model; + param.ctx.net_idx = params->ctx.net_idx; + param.ctx.app_idx = BLE_MESH_KEY_DEV; + param.ctx.addr = params->ctx.addr; + param.ctx.send_rel = params->ctx.send_rel; + param.ctx.send_ttl = params->ctx.send_ttl; + param.msg_timeout = params->msg_timeout; + param.msg_role = params->msg_role; - config_msg_timeout = params->msg_timeout; - - switch (params->opcode) { + switch (param.opcode) { case ESP_BLE_MESH_MODEL_OP_BEACON_SET: - return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon); + return bt_mesh_cfg_beacon_set(¶m, set->beacon_set.beacon); case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET: - return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl); + return bt_mesh_cfg_ttl_set(¶m, set->default_ttl_set.ttl); case ESP_BLE_MESH_MODEL_OP_FRIEND_SET: - return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state); + return bt_mesh_cfg_friend_set(¶m, set->friend_set.friend_state); case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET: - return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy); + return bt_mesh_cfg_gatt_proxy_set(¶m, set->gatt_proxy_set.gatt_proxy); case ESP_BLE_MESH_MODEL_OP_RELAY_SET: - return bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, + return bt_mesh_cfg_relay_set(¶m, set->relay_set.relay, set->relay_set.relay_retransmit); case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD: - return bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx, + return bt_mesh_cfg_net_key_add(¶m, set->net_key_add.net_idx, &set->net_key_add.net_key[0]); case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD: - return bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx, + return bt_mesh_cfg_app_key_add(¶m, set->app_key_add.net_idx, set->app_key_add.app_idx, &set->app_key_add.app_key[0]); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND: - return bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr, + return bt_mesh_cfg_mod_app_bind(¶m, set->model_app_bind.element_addr, set->model_app_bind.model_app_idx, set->model_app_bind.model_id, set->model_app_bind.company_id); @@ -528,46 +529,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param .period = set->model_pub_set.publish_period, .transmit = set->model_pub_set.publish_retransmit, }; - return bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr, + return bt_mesh_cfg_mod_pub_set(¶m, set->model_pub_set.element_addr, set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: - return bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr, + return bt_mesh_cfg_mod_sub_add(¶m, set->model_sub_add.element_addr, set->model_sub_add.sub_addr, set->model_sub_add.model_id, set->model_sub_add.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE: - return bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr, + return bt_mesh_cfg_mod_sub_del(¶m, set->model_sub_delete.element_addr, set->model_sub_delete.sub_addr, set->model_sub_delete.model_id, set->model_sub_delete.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE: - return bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr, + return bt_mesh_cfg_mod_sub_overwrite(¶m, set->model_sub_overwrite.element_addr, set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id, set->model_sub_overwrite.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD: - return bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr, + return bt_mesh_cfg_mod_sub_va_add(¶m, set->model_sub_va_add.element_addr, &set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id, set->model_sub_va_add.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE: - return bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr, + return bt_mesh_cfg_mod_sub_va_overwrite(¶m, set->model_sub_va_overwrite.element_addr, &set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id, set->model_sub_va_overwrite.company_id); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE: - return bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr, + return bt_mesh_cfg_mod_sub_va_del(¶m, set->model_sub_va_delete.element_addr, &set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id, set->model_sub_va_delete.company_id); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET: - return bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set); + return bt_mesh_cfg_hb_sub_set(¶m, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET: - return bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set); + return bt_mesh_cfg_hb_pub_set(¶m, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set); case ESP_BLE_MESH_MODEL_OP_NODE_RESET: - return bt_mesh_cfg_node_reset(&ctx); + return bt_mesh_cfg_node_reset(¶m); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: { struct bt_mesh_cfg_mod_pub model_pub = { .app_idx = set->model_pub_va_set.publish_app_idx, @@ -576,42 +577,42 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param .period = set->model_pub_va_set.publish_period, .transmit = set->model_pub_va_set.publish_retransmit, }; - return bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr, + return bt_mesh_cfg_mod_pub_va_set(¶m, set->model_pub_va_set.element_addr, set->model_pub_va_set.model_id, set->model_pub_va_set.company_id, set->model_pub_va_set.label_uuid, &model_pub); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL: - return bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr, + return bt_mesh_cfg_mod_sub_del_all(¶m, set->model_sub_delete_all.element_addr, set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id); case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE: - return bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx, + return bt_mesh_cfg_net_key_update(¶m, set->net_key_update.net_idx, set->net_key_update.net_key); case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE: - return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx); + return bt_mesh_cfg_net_key_delete(¶m, set->net_key_delete.net_idx); case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE: - return bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx, + return bt_mesh_cfg_app_key_update(¶m, set->app_key_update.net_idx, set->app_key_update.app_idx, set->app_key_update.app_key); case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE: - return bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx, + return bt_mesh_cfg_app_key_delete(¶m, set->app_key_delete.net_idx, set->app_key_delete.app_idx); case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET: - return bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx, + return bt_mesh_cfg_node_identity_set(¶m, set->node_identity_set.net_idx, set->node_identity_set.identity); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND: - return bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr, + return bt_mesh_cfg_mod_app_unbind(¶m, set->model_app_unbind.element_addr, set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id, set->model_app_unbind.company_id); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET: - return bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx, + return bt_mesh_cfg_kr_phase_set(¶m, set->kr_phase_set.net_idx, set->kr_phase_set.transition); case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET: - return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit); + return bt_mesh_cfg_net_transmit_set(¶m, set->net_transmit_set.net_transmit); default: - BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); + BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode); return -EINVAL; } @@ -622,7 +623,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) { btc_ble_mesh_config_client_args_t *arg = NULL; esp_ble_mesh_cfg_client_cb_param_t cb = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -634,12 +634,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: { cb.params = arg->cfg_client_get_state.params; - role_param.model = (struct bt_mesh_model *)cb.params->model; - role_param.role = cb.params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params, arg->cfg_client_get_state.get_state); if (cb.error_code) { @@ -649,12 +643,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: { cb.params = arg->cfg_client_set_state.params; - role_param.model = (struct bt_mesh_model *)cb.params->model; - role_param.role = cb.params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params, arg->cfg_client_set_state.set_state); if (cb.error_code) { @@ -684,7 +672,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) { btc_ble_mesh_config_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_config_client_free_req_data(msg); @@ -694,7 +682,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg) /* Configuration Server Model related functions */ static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event, - esp_ble_mesh_cfg_server_cb_param_t *param) + esp_ble_mesh_cfg_server_cb_param_t *param) { esp_ble_mesh_cfg_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_SERVER); @@ -721,13 +709,11 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL); } -void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) +void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_cfg_server_cb_param_t cb_params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -740,7 +726,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT; break; default: - BT_ERR("%s, Unknown config server event type %d", __func__, evt_type); + BT_ERR("Unknown Config server event type %d", evt_type); return; } @@ -751,10 +737,11 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, cb_params.ctx.recv_ttl = ctx->recv_ttl; cb_params.ctx.recv_op = ctx->recv_op; cb_params.ctx.recv_dst = ctx->recv_dst; + cb_params.ctx.recv_rssi = ctx->recv_rssi; + cb_params.ctx.send_ttl = ctx->send_ttl; if (val && len) { - length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value); - memcpy(&cb_params.value, val, length); + memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value))); } btc_ble_mesh_config_server_callback(&cb_params, act); @@ -775,6 +762,6 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) { btc_ble_mesh_config_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index 7a9c5348f..15b729a5a 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -22,7 +22,7 @@ /* Generic Client Models related functions */ static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event, - esp_ble_mesh_generic_client_cb_param_t *param) + esp_ble_mesh_generic_client_cb_param_t *param) { esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT); @@ -49,7 +49,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->generic_client_get_state.get_state) { @@ -58,7 +58,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state, sizeof(esp_ble_mesh_generic_client_get_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -78,7 +78,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi length = src->generic_client_set_state.set_state->user_property_set.property_value->len; dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length); if (!dst->generic_client_set_state.set_state->user_property_set.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value, @@ -91,7 +91,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi length = src->generic_client_set_state.set_state->admin_property_set.property_value->len; dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length); if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value, @@ -103,12 +103,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi break; } } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -172,7 +172,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -191,7 +191,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.user_properties_status.property_ids->len; p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.user_properties_status.property_ids) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids, @@ -206,7 +206,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.user_property_status.property_value->len; p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.user_property_status.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value, @@ -220,7 +220,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.admin_properties_status.property_ids->len; p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.admin_properties_status.property_ids) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids, @@ -235,7 +235,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.admin_property_status.property_value->len; p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.admin_property_status.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value, @@ -249,7 +249,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len; p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids, @@ -264,7 +264,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.manufacturer_property_status.property_value->len; p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.manufacturer_property_status.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value, @@ -278,7 +278,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->status_cb.client_properties_status.property_ids->len; p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.client_properties_status.property_ids) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids, @@ -374,18 +374,17 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_ msg.pid = BTC_PID_GENERIC_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t), + btc_ble_mesh_generic_client_copy_req_data); } void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_generic_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -407,7 +406,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type); + BT_ERR("Unknown Generic client event type %d", evt_type); return; } @@ -419,31 +418,31 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_generic_client_callback(&cb_params, act); return; } -void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_generic_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } @@ -453,7 +452,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) btc_ble_mesh_generic_client_args_t *arg = NULL; esp_ble_mesh_generic_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -465,12 +463,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: { params = arg->generic_client_get_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -479,10 +471,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->generic_client_get_state.params; - cb.error_code = bt_mesh_generic_client_get_state(&common, - (void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT); @@ -491,12 +483,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: { params = arg->generic_client_set_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -505,10 +491,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->generic_client_set_state.params; - cb.error_code = bt_mesh_generic_client_set_state(&common, - (void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT); @@ -537,7 +523,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) { btc_ble_mesh_generic_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_generic_client_free_req_data(msg); @@ -546,9 +532,8 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg) /* Generic Server Models related functions */ -static inline void btc_ble_mesh_generic_server_cb_to_app( - esp_ble_mesh_generic_server_cb_event_t event, - esp_ble_mesh_generic_server_cb_param_t *param) +static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event, + esp_ble_mesh_generic_server_cb_param_t *param) { esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER); @@ -577,7 +562,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->value.state_change.user_property_set.value->len; p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.user_property_set.value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value, @@ -591,7 +576,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->value.state_change.admin_property_set.value->len; p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.admin_property_set.value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value, @@ -611,7 +596,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->value.set.user_property.property_value->len; p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.set.user_property.property_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value, @@ -625,7 +610,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de length = p_src_data->value.set.admin_property.property_value->len; p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.set.admin_property.property_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value, @@ -702,17 +687,15 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_ msg.pid = BTC_PID_GENERIC_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t), + btc_ble_mesh_generic_server_copy_req_data); } -void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) +void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_generic_server_cb_param_t cb_params = {0}; - size_t length = 0U; uint8_t act = 0U; if (model == NULL || ctx == NULL) { @@ -731,7 +714,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT; break; default: - BT_ERR("%s, Unknown Generic Server event type", __func__); + BT_ERR("Unknown Generic Server event type %d", evt_type); return; } @@ -742,10 +725,11 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, cb_params.ctx.recv_ttl = ctx->recv_ttl; cb_params.ctx.recv_op = ctx->recv_op; cb_params.ctx.recv_dst = ctx->recv_dst; + cb_params.ctx.recv_rssi = ctx->recv_rssi; + cb_params.ctx.send_ttl = ctx->send_ttl; if (val && len) { - length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value); - memcpy(&cb_params.value, val, length); + memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value))); } btc_ble_mesh_generic_server_callback(&cb_params, act); @@ -766,7 +750,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) { btc_ble_mesh_generic_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_generic_server_free_req_data(msg); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index abb37bd2b..9e401446c 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -21,12 +21,10 @@ #include "health_cli.h" #include "esp_ble_mesh_health_model_api.h" -extern s32_t health_msg_timeout; - /* Health Client Model related functions */ static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event, - esp_ble_mesh_health_client_cb_param_t *param) + esp_ble_mesh_health_client_cb_param_t *param) { esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT); @@ -52,7 +50,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->health_client_get_state.params, src->health_client_get_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->health_client_get_state.get_state) { @@ -61,7 +59,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state, sizeof(esp_ble_mesh_health_client_get_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -75,12 +73,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state, sizeof(esp_ble_mesh_health_client_set_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -132,7 +130,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -150,7 +148,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.current_status.fault_array->len; p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.current_status.fault_array) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array, @@ -166,7 +164,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.fault_status.fault_array->len; p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.fault_status.fault_array) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array, @@ -240,18 +238,17 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa msg.pid = BTC_PID_HEALTH_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t), + btc_ble_mesh_health_client_copy_req_data); } void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, u16_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, u16_t len) { esp_ble_mesh_health_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -273,7 +270,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown health client event type %d", __func__, evt_type); + BT_ERR("Unknown Health client event type %d", evt_type); return; } @@ -285,38 +282,38 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_health_client_callback(&cb_params, act); return; } -void btc_ble_mesh_health_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_health_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_health_client_get_state_t *get) { - struct bt_mesh_msg_ctx ctx = {0}; + bt_mesh_client_common_param_t param = {0}; if (params == NULL) { BT_ERR("%s, Invalid parameter", __func__); @@ -324,27 +321,29 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param } if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) { - BT_ERR("%s, Invalid health client get", __func__); + BT_ERR("Invalid Health Get"); return -EINVAL; } - ctx.net_idx = params->ctx.net_idx; - ctx.app_idx = params->ctx.app_idx; - ctx.addr = params->ctx.addr; - ctx.send_rel = params->ctx.send_rel; - ctx.send_ttl = params->ctx.send_ttl; + param.opcode = params->opcode; + param.model = (struct bt_mesh_model *)params->model; + param.ctx.net_idx = params->ctx.net_idx; + param.ctx.app_idx = params->ctx.app_idx; + param.ctx.addr = params->ctx.addr; + param.ctx.send_rel = params->ctx.send_rel; + param.ctx.send_ttl = params->ctx.send_ttl; + param.msg_timeout = params->msg_timeout; + param.msg_role = params->msg_role; - health_msg_timeout = params->msg_timeout; - - switch (params->opcode) { + switch (param.opcode) { case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET: - return bt_mesh_health_attention_get(&ctx); + return bt_mesh_health_attention_get(¶m); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET: - return bt_mesh_health_period_get(&ctx); + return bt_mesh_health_period_get(¶m); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET: - return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id); + return bt_mesh_health_fault_get(¶m, get->fault_get.company_id); default: - BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); + BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode); return -EINVAL; } @@ -354,40 +353,42 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_health_client_set_state_t *set) { - struct bt_mesh_msg_ctx ctx = {0}; + bt_mesh_client_common_param_t param = {0}; if (params == NULL || set == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } - ctx.net_idx = params->ctx.net_idx; - ctx.app_idx = params->ctx.app_idx; - ctx.addr = params->ctx.addr; - ctx.send_rel = params->ctx.send_rel; - ctx.send_ttl = params->ctx.send_ttl; + param.opcode = params->opcode; + param.model = (struct bt_mesh_model *)params->model; + param.ctx.net_idx = params->ctx.net_idx; + param.ctx.app_idx = params->ctx.app_idx; + param.ctx.addr = params->ctx.addr; + param.ctx.send_rel = params->ctx.send_rel; + param.ctx.send_ttl = params->ctx.send_ttl; + param.msg_timeout = params->msg_timeout; + param.msg_role = params->msg_role; - health_msg_timeout = params->msg_timeout; - - switch (params->opcode) { + switch (param.opcode) { case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET: - return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true); + return bt_mesh_health_attention_set(¶m, set->attention_set.attention, true); case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK: - return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false); + return bt_mesh_health_attention_set(¶m, set->attention_set.attention, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET: - return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true); + return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK: - return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false); + return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST: - return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true); + return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK: - return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false); + return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, false); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR: - return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true); + return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, true); case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK: - return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false); + return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, false); default: - BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode); + BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode); return -EINVAL; } @@ -398,7 +399,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) { btc_ble_mesh_health_client_args_t *arg = NULL; esp_ble_mesh_health_client_cb_param_t cb = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -410,12 +410,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: { cb.params = arg->health_client_get_state.params; - role_param.model = (struct bt_mesh_model *)cb.params->model; - role_param.role = cb.params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params, arg->health_client_get_state.get_state); if (cb.error_code) { @@ -426,12 +420,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: { cb.params = arg->health_client_set_state.params; - role_param.model = (struct bt_mesh_model *)cb.params->model; - role_param.role = cb.params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params, arg->health_client_set_state.set_state); if (cb.error_code) { @@ -462,7 +450,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) { btc_ble_mesh_health_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_health_client_free_req_data(msg); @@ -472,7 +460,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg) /* Health Server Model related functions */ static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event, - esp_ble_mesh_health_server_cb_param_t *param) + esp_ble_mesh_health_server_cb_param_t *param) { esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER); @@ -556,8 +544,8 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa msg.pid = BTC_PID_HEALTH_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t), + btc_ble_mesh_health_server_copy_req_data); } void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg) @@ -601,7 +589,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) { btc_ble_mesh_health_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_health_server_free_req_data(msg); @@ -618,7 +606,8 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT); } -void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id) +void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, + u8_t test_id, u16_t company_id) { esp_ble_mesh_health_server_cb_param_t param = {0}; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index 881693144..bd3480805 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -22,7 +22,7 @@ /* Lighting Client Models related functions */ static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event, - esp_ble_mesh_light_client_cb_param_t *param) + esp_ble_mesh_light_client_cb_param_t *param) { esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT); @@ -48,7 +48,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo memcpy(dst->light_client_get_state.params, src->light_client_get_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->light_client_get_state.get_state) { @@ -57,7 +57,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state, sizeof(esp_ble_mesh_light_client_get_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -71,12 +71,12 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state, sizeof(esp_ble_mesh_light_client_set_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -128,7 +128,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -148,7 +148,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d length = p_src_data->status_cb.lc_property_status.property_value->len; p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.lc_property_status.property_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value, @@ -218,18 +218,17 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p msg.pid = BTC_PID_LIGHTING_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t), + btc_ble_mesh_lighting_client_copy_req_data); } void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_light_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -251,7 +250,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown lighting client event type", __func__); + BT_ERR("Unknown Lighting client event type %d", evt_type); return; } @@ -263,31 +262,31 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_lighting_client_callback(&cb_params, act); return; } -void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_lighting_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } @@ -297,7 +296,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) btc_ble_mesh_lighting_client_args_t *arg = NULL; esp_ble_mesh_light_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -309,12 +307,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: { params = arg->light_client_get_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -323,10 +315,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->light_client_get_state.params; - cb.error_code = bt_mesh_light_client_get_state(&common, - (void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT); @@ -335,12 +327,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: { params = arg->light_client_set_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -349,10 +335,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->light_client_set_state.params; - cb.error_code = bt_mesh_light_client_set_state(&common, - (void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT); @@ -381,7 +367,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) { btc_ble_mesh_lighting_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_lighting_client_free_req_data(msg); @@ -390,9 +376,8 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg) /* Lighting Server Models related functions */ -static inline void btc_ble_mesh_lighting_server_cb_to_app( - esp_ble_mesh_lighting_server_cb_event_t event, - esp_ble_mesh_lighting_server_cb_param_t *param) +static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event, + esp_ble_mesh_lighting_server_cb_param_t *param) { esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER); @@ -420,7 +405,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d length = p_src_data->value.state_change.lc_property_set.property_value->len; p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value, @@ -436,7 +421,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d length = p_src_data->value.set.lc_property.property_value->len; p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.set.lc_property.property_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value, @@ -451,7 +436,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d length = p_src_data->value.status.sensor_status.data->len; p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length); if (p_dest_data->value.status.sensor_status.data == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data, @@ -514,17 +499,15 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c msg.pid = BTC_PID_LIGHTING_SERVER; msg.act = act; - btc_transfer_context( - &msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), + btc_ble_mesh_lighting_server_copy_req_data); } -void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) +void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_lighting_server_cb_param_t cb_params = {0}; - size_t length = 0U; uint8_t act = 0U; if (model == NULL || ctx == NULL) { @@ -546,7 +529,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT; break; default: - BT_ERR("%s, Unknown Lighting Server event type", __func__); + BT_ERR("Unknown Lighting server event type %d", evt_type); return; } @@ -557,10 +540,11 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, cb_params.ctx.recv_ttl = ctx->recv_ttl; cb_params.ctx.recv_op = ctx->recv_op; cb_params.ctx.recv_dst = ctx->recv_dst; + cb_params.ctx.recv_rssi = ctx->recv_rssi; + cb_params.ctx.send_ttl = ctx->send_ttl; if (val && len) { - length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value); - memcpy(&cb_params.value, val, length); + memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value))); } btc_ble_mesh_lighting_server_callback(&cb_params, act); @@ -581,7 +565,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) { btc_ble_mesh_lighting_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_lighting_server_free_req_data(msg); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index f0d4ea066..6bd601665 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -51,7 +51,7 @@ #include "esp_ble_mesh_networking_api.h" static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t event, - esp_ble_mesh_prov_cb_param_t *param) + esp_ble_mesh_prov_cb_param_t *param) { esp_ble_mesh_prov_cb_t btc_ble_mesh_cb = (esp_ble_mesh_prov_cb_t)btc_profile_cb_get(BTC_PID_PROV); @@ -61,7 +61,7 @@ static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t even } static inline void btc_ble_mesh_model_cb_to_app(esp_ble_mesh_model_cb_event_t event, - esp_ble_mesh_model_cb_param_t *param) + esp_ble_mesh_model_cb_param_t *param) { esp_ble_mesh_model_cb_t btc_ble_mesh_cb = (esp_ble_mesh_model_cb_t)btc_profile_cb_get(BTC_PID_MODEL); @@ -82,36 +82,33 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) switch (msg->act) { case BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR: - BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR", __func__); dst->proxy_client_add_filter_addr.addr = (uint16_t *)bt_mesh_calloc(src->proxy_client_add_filter_addr.addr_num << 1); if (dst->proxy_client_add_filter_addr.addr) { memcpy(dst->proxy_client_add_filter_addr.addr, src->proxy_client_add_filter_addr.addr, src->proxy_client_add_filter_addr.addr_num << 1); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; case BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR: - BT_DBG("%s, BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR", __func__); dst->proxy_client_remove_filter_addr.addr = bt_mesh_calloc(src->proxy_client_remove_filter_addr.addr_num << 1); if (dst->proxy_client_remove_filter_addr.addr) { memcpy(dst->proxy_client_remove_filter_addr.addr, src->proxy_client_remove_filter_addr.addr, src->proxy_client_remove_filter_addr.addr_num << 1); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; case BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA: - BT_DBG("%s, BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA", __func__); dst->store_node_comp_data.data = bt_mesh_calloc(src->store_node_comp_data.length); if (dst->store_node_comp_data.data) { memcpy(dst->store_node_comp_data.data, src->store_node_comp_data.data, src->store_node_comp_data.length); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -161,35 +158,33 @@ void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) switch (msg->act) { case BTC_BLE_MESH_ACT_SERVER_MODEL_SEND: case BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND: { - BT_DBG("%s, BTC_BLE_MESH_ACT_MODEL_SEND, src->model_send.length = %d", __func__, src->model_send.length); dst->model_send.data = src->model_send.length ? (uint8_t *)bt_mesh_malloc(src->model_send.length) : NULL; dst->model_send.ctx = bt_mesh_malloc(sizeof(esp_ble_mesh_msg_ctx_t)); if (src->model_send.length) { if (dst->model_send.data) { memcpy(dst->model_send.data, src->model_send.data, src->model_send.length); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } if (dst->model_send.ctx) { memcpy(dst->model_send.ctx, src->model_send.ctx, sizeof(esp_ble_mesh_msg_ctx_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE: - BT_DBG("%s, BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE", __func__); dst->model_update_state.value = bt_mesh_malloc(sizeof(esp_ble_mesh_server_state_value_t)); if (dst->model_update_state.value) { memcpy(dst->model_update_state.value, src->model_update_state.value, sizeof(esp_ble_mesh_server_state_value_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -245,13 +240,13 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void if (p_dest_data->model_operation.ctx) { memcpy(p_dest_data->model_operation.ctx, p_src_data->model_operation.ctx, sizeof(esp_ble_mesh_msg_ctx_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } if (p_src_data->model_operation.length) { if (p_dest_data->model_operation.msg) { memcpy(p_dest_data->model_operation.msg, p_src_data->model_operation.msg, p_src_data->model_operation.length); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } } @@ -264,13 +259,13 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void if (p_dest_data->client_recv_publish_msg.ctx) { memcpy(p_dest_data->client_recv_publish_msg.ctx, p_src_data->client_recv_publish_msg.ctx, sizeof(esp_ble_mesh_msg_ctx_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } if (p_src_data->client_recv_publish_msg.length) { if (p_dest_data->client_recv_publish_msg.msg) { memcpy(p_dest_data->client_recv_publish_msg.msg, p_src_data->client_recv_publish_msg.msg, p_src_data->client_recv_publish_msg.length); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } } @@ -282,7 +277,7 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void if (p_dest_data->model_send_comp.ctx) { memcpy(p_dest_data->model_send_comp.ctx, p_src_data->model_send_comp.ctx, sizeof(esp_ble_mesh_msg_ctx_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -293,7 +288,7 @@ static void btc_ble_mesh_model_copy_req_data(btc_msg_t *msg, void *p_dest, void if (p_dest_data->client_send_timeout.ctx) { memcpy(p_dest_data->client_send_timeout.ctx, p_src_data->client_send_timeout.ctx, sizeof(esp_ble_mesh_msg_ctx_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -366,17 +361,17 @@ static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *pa msg.pid = BTC_PID_MODEL; msg.act = act; - ret = btc_transfer_context(&msg, param, - sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data); + ret = btc_transfer_context(&msg, param, sizeof(esp_ble_mesh_model_cb_param_t), + btc_ble_mesh_model_copy_req_data); if (ret != BT_STATUS_SUCCESS) { - BT_ERR("%s, btc_transfer_context failed", __func__); + BT_ERR("btc_transfer_context failed"); } return ret; } static void btc_ble_mesh_server_model_op_cb(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; @@ -391,8 +386,8 @@ static void btc_ble_mesh_server_model_op_cb(struct bt_mesh_model *model, } static void btc_ble_mesh_client_model_op_cb(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; bt_mesh_client_node_t *node = NULL; @@ -455,7 +450,9 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work) return; } -static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, u32_t opcode, int err) +static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model, + esp_ble_mesh_msg_ctx_t *ctx, + u32_t opcode, int err) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; @@ -493,7 +490,8 @@ static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod) } static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t *model, - esp_ble_mesh_server_state_type_t type, int err) + esp_ble_mesh_server_state_type_t type, + int err) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; @@ -523,7 +521,7 @@ static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *para ret = btc_transfer_context(&msg, param, sizeof(esp_ble_mesh_prov_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { - BT_ERR("%s, btc_transfer_context failed", __func__); + BT_ERR("btc_transfer_context failed"); } return ret; } @@ -603,7 +601,8 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer) return; } -static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index) +static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], + u16_t addr, u8_t flags, u32_t iv_index) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -649,10 +648,10 @@ static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *para } #if CONFIG_BLE_MESH_PROVISIONER -static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb( - const u8_t addr[6], const u8_t addr_type, - const u8_t adv_type, const u8_t dev_uuid[16], - u16_t oob_info, bt_mesh_prov_bearer_t bearer, s8_t rssi) +static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_t addr_type, + const u8_t adv_type, const u8_t dev_uuid[16], + u16_t oob_info, bt_mesh_prov_bearer_t bearer, + s8_t rssi) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -689,8 +688,8 @@ static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx) return (ret == BT_STATUS_SUCCESS) ? 0 : -1; } -static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, - bt_mesh_output_action_t act, u8_t size, u8_t link_idx) +static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, bt_mesh_output_action_t act, + u8_t size, u8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -706,8 +705,8 @@ static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, return (ret == BT_STATUS_SUCCESS) ? 0 : -1; } -static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, - bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx) +static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, bt_mesh_input_action_t act, + void *data, u8_t size, u8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -753,10 +752,9 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, return; } -static void btc_ble_mesh_provisioner_prov_complete_cb( - u16_t node_idx, const u8_t device_uuid[16], - u16_t unicast_addr, u8_t element_num, - u16_t netkey_idx) +static void btc_ble_mesh_provisioner_prov_complete_cb(u16_t node_idx, const u8_t device_uuid[16], + u16_t unicast_addr, u8_t element_num, + u16_t netkey_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -782,6 +780,20 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicas return (esp_ble_mesh_node_t *)bt_mesh_provisioner_get_node_with_addr(unicast_addr); } +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name) +{ + return (esp_ble_mesh_node_t *)bt_mesh_provisioner_get_node_with_name(name); +} + +u16_t btc_ble_mesh_provisioner_get_prov_node_count(void) +{ + return bt_mesh_provisioner_get_node_count(); +} + +const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void) +{ + return (const esp_ble_mesh_node_t **)bt_mesh_provisioner_get_node_table_entry(); +} #endif /* CONFIG_BLE_MESH_PROVISIONER */ static void btc_ble_mesh_heartbeat_msg_recv_cb(u8_t hops, u16_t feature) @@ -827,7 +839,7 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) BT_DBG("%s", __func__); if (!BLE_MESH_ADDR_IS_UNICAST(lpn_addr)) { - BT_ERR("%s, Not a unicast address", __func__); + BT_ERR("Not a unicast lpn address 0x%04x", lpn_addr); return; } @@ -846,8 +858,8 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) #endif /* CONFIG_BLE_MESH_FRIEND */ #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT -static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, - u8_t type, bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi) +static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -869,7 +881,7 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, } static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx) + u8_t conn_handle, u16_t net_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -889,8 +901,8 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, return; } -static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx, u8_t reason) +static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, u8_t conn_handle, + u16_t net_idx, u8_t reason) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -911,8 +923,8 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, return; } -static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, - u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size) +static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, u16_t src, u16_t net_idx, + u8_t filter_type, u16_t list_size) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -936,6 +948,11 @@ static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model) { + if (!bt_mesh_is_initialized()) { + BT_ERR("Mesh stack is not initialized!"); + return -EINVAL; + } + __ASSERT(model && model->op, "%s, Invalid parameter", __func__); esp_ble_mesh_model_op_t *op = model->op; while (op != NULL && op->opcode != 0) { @@ -976,7 +993,7 @@ uint8_t btc_ble_mesh_elem_count(void) } esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem, - uint16_t company, uint16_t id) + uint16_t company, uint16_t id) { return (esp_ble_mesh_model_t *)bt_mesh_model_find_vnd((struct bt_mesh_elem *)elem, company, id); } @@ -991,82 +1008,118 @@ const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void) return (const esp_ble_mesh_comp_t *)bt_mesh_comp_get(); } -u16_t btc_ble_mesh_provisioner_get_prov_node_count(void) -{ - return bt_mesh_provisioner_get_node_count(); -} - /* Configuration Models */ extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[]; extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; /* Health Models */ extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; extern const struct bt_mesh_model_op bt_mesh_health_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; /* Generic Client Models */ -extern const struct bt_mesh_model_op gen_onoff_cli_op[]; -extern const struct bt_mesh_model_op gen_level_cli_op[]; -extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[]; -extern const struct bt_mesh_model_op gen_power_onoff_cli_op[]; -extern const struct bt_mesh_model_op gen_power_level_cli_op[]; -extern const struct bt_mesh_model_op gen_battery_cli_op[]; -extern const struct bt_mesh_model_op gen_location_cli_op[]; -extern const struct bt_mesh_model_op gen_property_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb; /* Lighting Client Models */ -extern const struct bt_mesh_model_op light_lightness_cli_op[]; -extern const struct bt_mesh_model_op light_ctl_cli_op[]; -extern const struct bt_mesh_model_op light_hsl_cli_op[]; -extern const struct bt_mesh_model_op light_xyl_cli_op[]; -extern const struct bt_mesh_model_op light_lc_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb; /* Sensor Client Models */ -extern const struct bt_mesh_model_op sensor_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb; /* Time and Scenes Client Models */ -extern const struct bt_mesh_model_op time_cli_op[]; -extern const struct bt_mesh_model_op scene_cli_op[]; -extern const struct bt_mesh_model_op scheduler_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_time_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb; /* Generic Server Models */ -extern const struct bt_mesh_model_op gen_onoff_srv_op[]; -extern const struct bt_mesh_model_op gen_level_srv_op[]; -extern const struct bt_mesh_model_op gen_def_trans_time_srv_op[]; -extern const struct bt_mesh_model_op gen_power_onoff_srv_op[]; -extern const struct bt_mesh_model_op gen_power_onoff_setup_srv_op[]; -extern const struct bt_mesh_model_op gen_power_level_srv_op[]; -extern const struct bt_mesh_model_op gen_power_level_setup_srv_op[]; -extern const struct bt_mesh_model_op gen_battery_srv_op[]; -extern const struct bt_mesh_model_op gen_location_srv_op[]; -extern const struct bt_mesh_model_op gen_location_setup_srv_op[]; -extern const struct bt_mesh_model_op gen_user_prop_srv_op[]; -extern const struct bt_mesh_model_op gen_admin_prop_srv_op[]; -extern const struct bt_mesh_model_op gen_manu_prop_srv_op[]; -extern const struct bt_mesh_model_op gen_client_prop_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_onoff_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_level_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_battery_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_location_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_location_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_user_prop_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_admin_prop_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_manu_prop_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_client_prop_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_gen_onoff_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_level_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_def_trans_time_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_power_level_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_power_level_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_battery_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_location_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_location_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb; /* Lighting Server Models */ -extern const struct bt_mesh_model_op light_lightness_srv_op[]; -extern const struct bt_mesh_model_op light_lightness_setup_srv_op[]; -extern const struct bt_mesh_model_op light_ctl_srv_op[]; -extern const struct bt_mesh_model_op light_ctl_setup_srv_op[]; -extern const struct bt_mesh_model_op light_ctl_temp_srv_op[]; -extern const struct bt_mesh_model_op light_hsl_srv_op[]; -extern const struct bt_mesh_model_op light_hsl_hue_srv_op[]; -extern const struct bt_mesh_model_op light_hsl_sat_srv_op[]; -extern const struct bt_mesh_model_op light_hsl_setup_srv_op[]; -extern const struct bt_mesh_model_op light_xyl_srv_op[]; -extern const struct bt_mesh_model_op light_xyl_setup_srv_op[]; -extern const struct bt_mesh_model_op light_lc_srv_op[]; -extern const struct bt_mesh_model_op light_lc_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lightness_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lightness_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_ctl_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_ctl_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_ctl_temp_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_hue_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_sat_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_xyl_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_xyl_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_ctl_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_ctl_temp_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_hsl_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_hsl_hue_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb; /* Time and Scenes Server Models */ -extern const struct bt_mesh_model_op time_srv_op[]; -extern const struct bt_mesh_model_op time_setup_srv_op[]; -extern const struct bt_mesh_model_op scene_srv_op[]; -extern const struct bt_mesh_model_op scene_setup_srv_op[]; -extern const struct bt_mesh_model_op scheduler_srv_op[]; -extern const struct bt_mesh_model_op scheduler_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_time_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_time_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_scene_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_scene_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_scheduler_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_scheduler_setup_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_time_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_time_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_scene_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb; /* Sensor Server Models */ -extern const struct bt_mesh_model_op sensor_srv_op[]; -extern const struct bt_mesh_model_op sensor_setup_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_sensor_srv_op[]; +extern const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb; +extern const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb; -static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) +static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model) { - esp_ble_mesh_model_op_t *op = NULL; - if (!model) { BT_ERR("%s, Invalid parameter", __func__); return; @@ -1075,13 +1128,14 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) /* For SIG client and server models, model->op will be NULL and initialized here. * For vendor models whose opcode is 3 bytes, model->op will be initialized here. */ - if ((model->op != NULL) && (model->op->opcode >= 0x10000)) { - goto add_model_op; + if (model->op && BLE_MESH_MODEL_OP_LEN(model->op->opcode) == 3) { + goto set_vnd_op; } switch (model->model_id) { case BLE_MESH_MODEL_ID_CFG_SRV: { model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_srv_cb; struct bt_mesh_cfg_srv *srv = (struct bt_mesh_cfg_srv *)model->user_data; if (srv) { srv->hb_sub.func = btc_ble_mesh_heartbeat_msg_recv_cb; @@ -1090,6 +1144,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_CFG_CLI: { model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_cli_cb; bt_mesh_config_client_t *cli = (bt_mesh_config_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_config_client_publish_callback; @@ -1098,6 +1153,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_HEALTH_SRV: { model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_srv_cb; struct bt_mesh_health_srv *srv = (struct bt_mesh_health_srv *)model->user_data; if (srv) { srv->cb.fault_clear = btc_ble_mesh_health_server_fault_clear; @@ -1109,6 +1165,7 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) } case BLE_MESH_MODEL_ID_HEALTH_CLI: { model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_cli_cb; bt_mesh_health_client_t *cli = (bt_mesh_health_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_health_publish_callback; @@ -1116,7 +1173,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_ONOFF_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_onoff_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_onoff_client_t *cli = (bt_mesh_gen_onoff_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1124,7 +1182,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_LEVEL_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_level_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_level_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_level_client_t *cli = (bt_mesh_gen_level_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1132,7 +1191,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_def_trans_time_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_def_trans_time_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_def_trans_time_client_t *cli = (bt_mesh_gen_def_trans_time_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1140,7 +1200,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_power_onoff_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_power_onoff_client_t *cli = (bt_mesh_gen_power_onoff_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1148,7 +1209,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_power_level_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_power_level_client_t *cli = (bt_mesh_gen_power_level_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1156,7 +1218,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_BATTERY_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_battery_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_battery_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_battery_client_t *cli = (bt_mesh_gen_battery_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1164,7 +1227,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_LOCATION_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_location_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_location_client_t *cli = (bt_mesh_gen_location_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1172,7 +1236,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_PROP_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)gen_property_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_property_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb; bt_mesh_gen_property_client_t *cli = (bt_mesh_gen_property_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_generic_client_publish_callback; @@ -1180,7 +1245,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)light_lightness_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb; bt_mesh_light_lightness_client_t *cli = (bt_mesh_light_lightness_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_lighting_client_publish_callback; @@ -1188,7 +1254,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_LIGHT_CTL_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)light_ctl_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb; bt_mesh_light_ctl_client_t *cli = (bt_mesh_light_ctl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_lighting_client_publish_callback; @@ -1196,7 +1263,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_LIGHT_HSL_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)light_hsl_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb; bt_mesh_light_hsl_client_t *cli = (bt_mesh_light_hsl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_lighting_client_publish_callback; @@ -1204,7 +1272,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_LIGHT_XYL_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)light_xyl_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb; bt_mesh_light_xyl_client_t *cli = (bt_mesh_light_xyl_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_lighting_client_publish_callback; @@ -1212,7 +1281,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_LIGHT_LC_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)light_lc_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb; bt_mesh_light_lc_client_t *cli = (bt_mesh_light_lc_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_lighting_client_publish_callback; @@ -1220,7 +1290,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_SENSOR_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)sensor_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_client_cb; bt_mesh_sensor_client_t *cli = (bt_mesh_sensor_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_sensor_client_publish_callback; @@ -1228,7 +1299,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_TIME_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)time_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb; bt_mesh_time_client_t *cli = (bt_mesh_time_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback; @@ -1236,7 +1308,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_SCENE_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)scene_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb; bt_mesh_scene_client_t *cli = (bt_mesh_scene_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback; @@ -1244,7 +1317,8 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_SCHEDULER_CLI: { - model->op = ((esp_ble_mesh_model_op_t *)scheduler_cli_op); + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_cli_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb; bt_mesh_scheduler_client_t *cli = (bt_mesh_scheduler_client_t *)model->user_data; if (cli != NULL) { cli->publish_status = btc_ble_mesh_time_scene_client_publish_callback; @@ -1252,227 +1326,262 @@ static void btc_ble_mesh_model_op_add(esp_ble_mesh_model_t *model) break; } case BLE_MESH_MODEL_ID_GEN_ONOFF_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_onoff_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_onoff_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_LEVEL_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_level_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_level_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_level_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_def_trans_time_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_def_trans_time_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_def_trans_time_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_power_onoff_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_onoff_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_power_onoff_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_onoff_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_onoff_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_power_level_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_level_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_power_level_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_power_level_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_power_level_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_BATTERY_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_battery_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_battery_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_battery_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_LOCATION_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_location_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_location_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_user_prop_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_user_prop_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_user_prop_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_admin_prop_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_admin_prop_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_admin_prop_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_manu_prop_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_manu_prop_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_manu_prop_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_client_prop_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_client_prop_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_client_prop_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)gen_location_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_location_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_location_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_lightness_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lightness_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_lightness_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lightness_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_ctl_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_ctl_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_ctl_temp_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_ctl_temp_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_ctl_temp_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_hsl_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_hsl_hue_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_hue_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_hue_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_hsl_sat_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_sat_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_sat_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_hsl_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_hsl_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_hsl_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_XYL_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_xyl_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_xyl_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_xyl_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_xyl_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_xyl_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_LC_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_lc_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lc_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)light_lc_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lc_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lc_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_TIME_SRV: - model->op = (esp_ble_mesh_model_op_t *)time_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_TIME_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)time_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_setup_srv_cb; if (model->pub) { /* Time Setup Server model does not support subscribing nor publishing. */ - BT_ERR("%s, Time Setup Server shall not support publication", __func__); + BT_ERR("Time Setup Server shall not support publication"); return; } break; case BLE_MESH_MODEL_ID_SCENE_SRV: - model->op = (esp_ble_mesh_model_op_t *)scene_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scene_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_SCENE_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)scene_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scene_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scene_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_SCHEDULER_SRV: - model->op = (esp_ble_mesh_model_op_t *)scheduler_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scheduler_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)scheduler_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_scheduler_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_scheduler_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_SENSOR_SRV: - model->op = (esp_ble_mesh_model_op_t *)sensor_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; case BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV: - model->op = (esp_ble_mesh_model_op_t *)sensor_setup_srv_op; + model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_setup_srv_op; + model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_setup_srv_cb; if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } break; default: - goto add_model_op; + goto set_vnd_op; } return; -add_model_op: +set_vnd_op: if (model->pub) { model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update; } - op = model->op; + esp_ble_mesh_model_op_t *op = model->op; while (op != NULL && op->opcode != 0) { op->param_cb = (esp_ble_mesh_cb_t)btc_ble_mesh_server_model_op_cb; op++; @@ -1495,30 +1604,27 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_MESH_INIT: { - int err_code = 0; for (int i = 0; i < arg->mesh_init.comp->element_count; i++) { esp_ble_mesh_elem_t *elem = &arg->mesh_init.comp->elements[i]; - /* For SIG models */ + for (int j = 0; j < elem->sig_model_count; j++) { esp_ble_mesh_model_t *sig_model = &elem->sig_models[j]; - /* The opcode of sig model should be 1 or 2 bytes. */ - if (sig_model && sig_model->op && (sig_model->op->opcode >= 0x10000)) { - err_code = -EINVAL; - btc_ble_mesh_prov_register_complete_cb(err_code); + if (sig_model->op && BLE_MESH_MODEL_OP_LEN(sig_model->op->opcode) == 3) { + /* Opcode of SIG model must be 1 or 2 bytes. */ + btc_ble_mesh_prov_register_complete_cb(-EINVAL); return; } - btc_ble_mesh_model_op_add(sig_model); + btc_ble_mesh_model_op_set(sig_model); } - /* For vendor models */ + for (int k = 0; k < elem->vnd_model_count; k++) { esp_ble_mesh_model_t *vnd_model = &elem->vnd_models[k]; - /* The opcode of vendor model should be 3 bytes. */ - if (vnd_model && vnd_model->op && vnd_model->op->opcode < 0x10000) { - err_code = -EINVAL; - btc_ble_mesh_prov_register_complete_cb(err_code); + if (vnd_model->op && BLE_MESH_MODEL_OP_LEN(vnd_model->op->opcode) < 3) { + /* Opcode of vendor model must be 3 bytes. */ + btc_ble_mesh_prov_register_complete_cb(-EINVAL); return; } - btc_ble_mesh_model_op_add(vnd_model); + btc_ble_mesh_model_op_set(vnd_model); } } #if CONFIG_BLE_MESH_NODE @@ -1552,8 +1658,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) bt_mesh_proxy_client_set_disconn_cb(btc_ble_mesh_proxy_client_disconnect_cb); bt_mesh_proxy_client_set_filter_status_cb(btc_ble_mesh_proxy_client_filter_status_recv_cb); #endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */ - err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov, - (struct bt_mesh_comp *)arg->mesh_init.comp); + int err_code = bt_mesh_init((struct bt_mesh_prov *)arg->mesh_init.prov, + (struct bt_mesh_comp *)arg->mesh_init.comp); /* Give the semaphore when BLE Mesh initialization is finished. */ xSemaphoreGive(arg->mesh_init.semaphore); btc_ble_mesh_prov_register_complete_cb(err_code); @@ -1561,17 +1667,14 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) } #if CONFIG_BLE_MESH_NODE case BTC_BLE_MESH_ACT_PROV_ENABLE: - BT_DBG("%s, BTC_BLE_MESH_ACT_PROV_ENABLE, bearers = %d", __func__, arg->node_prov_enable.bearers); act = ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT; param.node_prov_enable_comp.err_code = bt_mesh_prov_enable(arg->node_prov_enable.bearers); break; case BTC_BLE_MESH_ACT_PROV_DISABLE: - BT_DBG("%s, BTC_BLE_MESH_ACT_PROV_DISABLE, bearers = %d", __func__, arg->node_prov_disable.bearers); act = ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT; param.node_prov_disable_comp.err_code = bt_mesh_prov_disable(arg->node_prov_disable.bearers); break; case BTC_BLE_MESH_ACT_NODE_RESET: - BT_DBG("%s, BTC_BLE_MESH_ACT_NODE_RESET", __func__); bt_mesh_node_reset(); return; case BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY: @@ -1603,11 +1706,11 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) break; case BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE: act = ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT; - param.node_proxy_gatt_enable_comp.err_code = bt_mesh_proxy_gatt_enable(); + param.node_proxy_gatt_enable_comp.err_code = bt_mesh_proxy_server_gatt_enable(); break; case BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE: act = ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT; - param.node_proxy_gatt_disable_comp.err_code = bt_mesh_proxy_gatt_disable(); + param.node_proxy_gatt_disable_comp.err_code = bt_mesh_proxy_server_gatt_disable(); break; #endif /* CONFIG_BLE_MESH_GATT_PROXY_SERVER */ #endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */ @@ -1720,10 +1823,11 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) app_key = arg->add_local_app_key.app_key; } act = ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT; - param.provisioner_add_app_key_comp.app_idx = arg->add_local_app_key.app_idx; param.provisioner_add_app_key_comp.err_code = bt_mesh_provisioner_local_app_key_add(app_key, arg->add_local_app_key.net_idx, &arg->add_local_app_key.app_idx); + param.provisioner_add_app_key_comp.net_idx = arg->add_local_app_key.net_idx; + param.provisioner_add_app_key_comp.app_idx = arg->add_local_app_key.app_idx; break; } case BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY: @@ -1753,9 +1857,9 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) net_key = arg->add_local_net_key.net_key; } act = ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT; - param.provisioner_add_net_key_comp.net_idx = arg->add_local_net_key.net_idx; param.provisioner_add_net_key_comp.err_code = bt_mesh_provisioner_local_net_key_add(net_key, &arg->add_local_net_key.net_idx); + param.provisioner_add_net_key_comp.net_idx = arg->add_local_net_key.net_idx; break; } case BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY: @@ -1846,7 +1950,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_set_filter_type_comp.conn_handle = arg->proxy_client_set_filter_type.conn_handle; param.proxy_client_set_filter_type_comp.net_idx = arg->proxy_client_set_filter_type.net_idx; param.proxy_client_set_filter_type_comp.err_code = - bt_mesh_proxy_client_send_cfg(arg->proxy_client_set_filter_type.conn_handle, + bt_mesh_proxy_client_cfg_send(arg->proxy_client_set_filter_type.conn_handle, arg->proxy_client_set_filter_type.net_idx, &pdu); break; } @@ -1860,7 +1964,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_add_filter_addr_comp.conn_handle = arg->proxy_client_add_filter_addr.conn_handle; param.proxy_client_add_filter_addr_comp.net_idx = arg->proxy_client_add_filter_addr.net_idx; param.proxy_client_add_filter_addr_comp.err_code = - bt_mesh_proxy_client_send_cfg(arg->proxy_client_add_filter_addr.conn_handle, + bt_mesh_proxy_client_cfg_send(arg->proxy_client_add_filter_addr.conn_handle, arg->proxy_client_add_filter_addr.net_idx, &pdu); break; } @@ -1874,7 +1978,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_remove_filter_addr_comp.conn_handle = arg->proxy_client_remove_filter_addr.conn_handle; param.proxy_client_remove_filter_addr_comp.net_idx = arg->proxy_client_remove_filter_addr.net_idx; param.proxy_client_remove_filter_addr_comp.err_code = - bt_mesh_proxy_client_send_cfg(arg->proxy_client_remove_filter_addr.conn_handle, + bt_mesh_proxy_client_cfg_send(arg->proxy_client_remove_filter_addr.conn_handle, arg->proxy_client_remove_filter_addr.net_idx, &pdu); break; } @@ -1928,7 +2032,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param); break; default: - BT_WARN("%s, Invalid msg->act %d", __func__, msg->act); + BT_WARN("%s, Unknown act %d", __func__, msg->act); return; } @@ -1955,7 +2059,7 @@ void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_PROV_EVT_MAX) { btc_ble_mesh_prov_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } } @@ -1974,11 +2078,12 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_MODEL_PUBLISH: { if (arg->model_publish.device_role == PROVISIONER) { - bt_mesh_role_param_t common = {0}; - common.model = (struct bt_mesh_model *)(arg->model_publish.model); - common.role = arg->model_publish.device_role; - if (bt_mesh_set_client_model_role(&common)) { - BT_ERR("%s, Failed to set model role", __func__); + /* Currently Provisioner only supports client model */ + err = bt_mesh_set_client_model_role((struct bt_mesh_model *)arg->model_publish.model, + arg->model_publish.device_role); + if (err) { + BT_ERR("Failed to set client role"); + btc_ble_mesh_model_publish_comp_cb(arg->model_publish.model, err); break; } } @@ -1990,11 +2095,15 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) /* arg->model_send.length contains opcode & payload, plus extra 4-bytes TransMIC */ struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + BLE_MESH_MIC_SHORT); if (!buf) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); + btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, + arg->model_send.opcode, -ENOMEM); break; } + net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length); arg->model_send.ctx->srv_send = true; + err = bt_mesh_model_send((struct bt_mesh_model *)arg->model_send.model, (struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf, NULL, NULL); @@ -2004,26 +2113,30 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) break; } case BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND: { - bt_mesh_role_param_t common = {0}; /* arg->model_send.length contains opcode & message, plus extra 4-bytes TransMIC */ struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + BLE_MESH_MIC_SHORT); if (!buf) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); + btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, + arg->model_send.opcode, -ENOMEM); break; } + net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length); - arg->model_send.ctx->srv_send = false; - common.model = (struct bt_mesh_model *)(arg->model_send.model); - common.role = arg->model_send.device_role; - if (bt_mesh_set_client_model_role(&common)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } - err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model, - arg->model_send.opcode, - (struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf, - btc_ble_mesh_client_model_timeout_cb, arg->model_send.msg_timeout, - arg->model_send.need_rsp, NULL, NULL); + bt_mesh_client_common_param_t param = { + .opcode = arg->model_send.opcode, + .model = (struct bt_mesh_model *)arg->model_send.model, + .ctx.net_idx = arg->model_send.ctx->net_idx, + .ctx.app_idx = arg->model_send.ctx->app_idx, + .ctx.addr = arg->model_send.ctx->addr, + .ctx.send_rel = arg->model_send.ctx->send_rel, + .ctx.send_ttl = arg->model_send.ctx->send_ttl, + .ctx.srv_send = false, + .msg_timeout = arg->model_send.msg_timeout, + .msg_role = arg->model_send.device_role, + }; + err = bt_mesh_client_send_msg(¶m, buf, arg->model_send.need_rsp, + btc_ble_mesh_client_model_timeout_cb); bt_mesh_free_buf(buf); btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, arg->model_send.opcode, err); @@ -2037,7 +2150,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) arg->model_update_state.type, err); break; default: - BT_WARN("%s, Unknown msg->act %d", __func__, msg->act); + BT_WARN("%s, Unknown act %d", __func__, msg->act); break; } @@ -2059,7 +2172,7 @@ void btc_ble_mesh_model_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_MODEL_EVT_MAX) { btc_ble_mesh_model_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_model_free_req_data(msg); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 2021f81a0..048d9ddb6 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -22,7 +22,7 @@ /* Sensor Client Models related functions */ static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event, - esp_ble_mesh_sensor_client_cb_param_t *param) + esp_ble_mesh_sensor_client_cb_param_t *param) { esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT); @@ -58,7 +58,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len; dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length); if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x, @@ -71,7 +71,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len; dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length); if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1, @@ -82,7 +82,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len; dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length); if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2, @@ -94,7 +94,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void break; } } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } @@ -113,7 +113,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len; dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length); if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down, @@ -124,7 +124,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len; dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length); if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up, @@ -135,7 +135,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len; dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length); if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low, @@ -146,7 +146,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len; dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length); if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high, @@ -159,7 +159,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len; dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length); if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw, @@ -171,12 +171,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void break; } } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -256,7 +256,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -275,7 +275,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.descriptor_status.descriptor->len; p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.descriptor_status.descriptor) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor, @@ -290,7 +290,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len; p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value, @@ -304,7 +304,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len; p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids, @@ -319,7 +319,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.setting_status.sensor_setting_raw->len; p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw, @@ -333,7 +333,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len; p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data, @@ -347,7 +347,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.column_status.sensor_column_value->len; p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.column_status.sensor_column_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value, @@ -361,7 +361,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->status_cb.series_status.sensor_series_value->len; p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.series_status.sensor_series_value) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value, @@ -456,18 +456,17 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa msg.pid = BTC_PID_SENSOR_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t), + btc_ble_mesh_sensor_client_copy_req_data); } void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_sensor_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -489,7 +488,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type); + BT_ERR("Unknown Sensor client event type %d", evt_type); return; } @@ -501,31 +500,31 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_sensor_client_callback(&cb_params, act); return; } -void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_sensor_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } @@ -535,7 +534,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) btc_ble_mesh_sensor_client_args_t *arg = NULL; esp_ble_mesh_sensor_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -547,12 +545,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: { params = arg->sensor_client_get_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -561,10 +553,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->sensor_client_get_state.params; - cb.error_code = bt_mesh_sensor_client_get_state(&common, - (void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT); @@ -573,12 +565,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: { params = arg->sensor_client_set_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -587,10 +573,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->sensor_client_set_state.params; - cb.error_code = bt_mesh_sensor_client_set_state(&common, - (void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT); @@ -619,7 +605,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) { btc_ble_mesh_sensor_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_sensor_client_free_req_data(msg); @@ -628,9 +614,8 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg) /* Sensor Server Models related functions */ -static inline void btc_ble_mesh_sensor_server_cb_to_app( - esp_ble_mesh_sensor_server_cb_event_t event, - esp_ble_mesh_sensor_server_cb_param_t *param) +static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event, + esp_ble_mesh_sensor_server_cb_param_t *param) { esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER); @@ -658,7 +643,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len; p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down, @@ -669,7 +654,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len; p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up, @@ -680,7 +665,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len; p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low, @@ -691,7 +676,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len; p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high, @@ -704,7 +689,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.state_change.sensor_setting_set.setting_value->len; p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value, @@ -719,7 +704,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.get.sensor_column.raw_value_x->len; p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length); if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x, @@ -731,7 +716,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.get.sensor_series.raw_value->len; p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length); if (p_dest_data->value.get.sensor_series.raw_value == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value, @@ -747,7 +732,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.set.sensor_cadence.cadence->len; p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length); if (p_dest_data->value.set.sensor_cadence.cadence == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence, @@ -760,7 +745,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des length = p_src_data->value.set.sensor_setting.setting_raw->len; p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length); if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw, @@ -834,17 +819,15 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa msg.pid = BTC_PID_SENSOR_SERVER; msg.act = act; - btc_transfer_context( - &msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), + btc_ble_mesh_sensor_server_copy_req_data); } -void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) +void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_sensor_server_cb_param_t cb_params = {0}; - size_t length = 0U; uint8_t act = 0U; if (model == NULL || ctx == NULL) { @@ -863,7 +846,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT; break; default: - BT_ERR("%s, Unknown Sensor Server event type", __func__); + BT_ERR("Unknown Sensor server event type %d", evt_type); return; } @@ -874,10 +857,11 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, cb_params.ctx.recv_ttl = ctx->recv_ttl; cb_params.ctx.recv_op = ctx->recv_op; cb_params.ctx.recv_dst = ctx->recv_dst; + cb_params.ctx.recv_rssi = ctx->recv_rssi; + cb_params.ctx.send_ttl = ctx->send_ttl; if (val && len) { - length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value); - memcpy(&cb_params.value, val, length); + memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value))); } btc_ble_mesh_sensor_server_callback(&cb_params, act); @@ -898,7 +882,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) { btc_ble_mesh_sensor_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_sensor_server_free_req_data(msg); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 6dd93b31a..8fd1b4810 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -22,7 +22,7 @@ /* Time and Scenes Client Models related functions */ static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event, - esp_ble_mesh_time_scene_client_cb_param_t *param) + esp_ble_mesh_time_scene_client_cb_param_t *param) { esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb = (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT); @@ -48,7 +48,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params, sizeof(esp_ble_mesh_client_common_param_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); break; } if (src->time_scene_client_get_state.get_state) { @@ -57,7 +57,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state, sizeof(esp_ble_mesh_time_scene_client_get_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } } break; @@ -71,12 +71,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state, sizeof(esp_ble_mesh_time_scene_client_set_state_t)); } else { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); } break; } default: - BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act); + BT_DBG("%s, Unknown act %d", __func__, msg->act); break; } } @@ -128,7 +128,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p if (p_src_data->params) { p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t)); if (!p_dest_data->params) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } @@ -149,7 +149,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p length = p_src_data->status_cb.scene_register_status.scenes->len; p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length); if (!p_dest_data->status_cb.scene_register_status.scenes) { - BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act); + BT_ERR("%s, Out of memory, act %d", __func__, msg->act); return; } net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes, @@ -220,18 +220,17 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie msg.pid = BTC_PID_TIME_SCENE_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t), + btc_ble_mesh_time_scene_client_copy_req_data); } void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; - size_t length = 0U; uint8_t act = 0U; if (!model || !ctx) { @@ -253,7 +252,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT; break; default: - BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type); + BT_ERR("Unknown Time Scene client event type %d", evt_type); return; } @@ -265,31 +264,31 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, params.ctx.recv_ttl = ctx->recv_ttl; params.ctx.recv_op = ctx->recv_op; params.ctx.recv_dst = ctx->recv_dst; + params.ctx.recv_rssi = ctx->recv_rssi; + params.ctx.send_ttl = ctx->send_ttl; cb_params.error_code = 0; cb_params.params = ¶ms; if (val && len) { - length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb); - memcpy(&cb_params.status_cb, val, length); + memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb))); } btc_ble_mesh_time_scene_client_callback(&cb_params, act); return; } -void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); return; } - bt_mesh_time_scene_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, + model, ctx, buf->data, buf->len); return; } @@ -299,7 +298,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) esp_ble_mesh_client_common_param_t *params = NULL; esp_ble_mesh_time_scene_client_cb_param_t cb = {0}; bt_mesh_client_common_param_t common = {0}; - bt_mesh_role_param_t role_param = {0}; if (!msg || !msg->arg) { BT_ERR("%s, Invalid parameter", __func__); @@ -311,12 +309,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) switch (msg->act) { case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: { params = arg->time_scene_client_get_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -325,10 +317,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->time_scene_client_get_state.params; - cb.error_code = bt_mesh_time_scene_client_get_state(&common, - (void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT); @@ -337,12 +329,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: { params = arg->time_scene_client_set_state.params; - role_param.model = (struct bt_mesh_model *)params->model; - role_param.role = params->msg_role; - if (bt_mesh_set_client_model_role(&role_param)) { - BT_ERR("%s, Failed to set model role", __func__); - break; - } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; common.ctx.net_idx = params->ctx.net_idx; @@ -351,10 +337,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) common.ctx.send_rel = params->ctx.send_rel; common.ctx.send_ttl = params->ctx.send_ttl; common.msg_timeout = params->msg_timeout; + common.msg_role = params->msg_role; cb.params = arg->time_scene_client_set_state.params; - cb.error_code = bt_mesh_time_scene_client_set_state(&common, - (void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb); + cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT); @@ -383,7 +369,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) { btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } btc_ble_mesh_time_scene_client_free_req_data(msg); @@ -392,9 +378,8 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg) /* Time and Scenes Server Models related functions */ -static inline void btc_ble_mesh_time_scene_server_cb_to_app( - esp_ble_mesh_time_scene_server_cb_event_t event, - esp_ble_mesh_time_scene_server_cb_param_t *param) +static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event, + esp_ble_mesh_time_scene_server_cb_param_t *param) { esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER); @@ -418,17 +403,14 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv msg.pid = BTC_PID_TIME_SCENE_SERVER; msg.act = act; - btc_transfer_context( - &msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL); + btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL); } -void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) +void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len) { esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0}; - size_t length = 0U; uint8_t act = 0U; if (model == NULL || ctx == NULL) { @@ -450,7 +432,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT; break; default: - BT_ERR("%s, Unknown Time Scene Server event type", __func__); + BT_ERR("Unknown Time Scene server event type %d", evt_type); return; } @@ -461,10 +443,11 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, cb_params.ctx.recv_ttl = ctx->recv_ttl; cb_params.ctx.recv_op = ctx->recv_op; cb_params.ctx.recv_dst = ctx->recv_dst; + cb_params.ctx.recv_rssi = ctx->recv_rssi; + cb_params.ctx.send_ttl = ctx->send_ttl; if (val && len) { - length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value); - memcpy(&cb_params.value, val, length); + memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value))); } btc_ble_mesh_time_scene_server_callback(&cb_params, act); @@ -485,7 +468,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg) if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) { btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param); } else { - BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act); + BT_ERR("%s, Unknown act %d", __func__, msg->act); } return; diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h index db37bec69..bee77fa74 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_config_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg); @@ -70,10 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX, } btc_ble_mesh_config_server_evt_t; -void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); +void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h index d87421dad..9840961b4 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, @@ -70,10 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX, } btc_ble_mesh_generic_server_evt_t; -void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); +void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h index 91a775511..bf12d051e 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg); void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg); -void btc_ble_mesh_health_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, u16_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, u16_t len); typedef enum { BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE, @@ -82,7 +81,8 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id); -void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id); +void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, + u8_t test_id, u16_t company_id); void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h index 453f2ee2c..0173c15e4 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, @@ -71,10 +70,9 @@ typedef enum { BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX, } btc_ble_mesh_lighting_server_evt_t; -void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); +void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h index e56425f15..dffba81de 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h @@ -18,6 +18,7 @@ #include "btc/btc_manage.h" #include "mesh_byteorder.h" #include "mesh_main.h" +#include "fast_prov.h" #include "provisioner_prov.h" #include "esp_ble_mesh_defs.h" @@ -298,6 +299,12 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t u esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name); + +u16_t btc_ble_mesh_provisioner_get_prov_node_count(void); + +const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void); + int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model); int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model); @@ -313,15 +320,12 @@ esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr); uint8_t btc_ble_mesh_elem_count(void); esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem, - uint16_t company, uint16_t id); + uint16_t company, uint16_t id); -esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, - uint16_t id); +esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id); const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void); -u16_t btc_ble_mesh_provisioner_get_prov_node_count(void); - void btc_ble_mesh_model_call_handler(btc_msg_t *msg); void btc_ble_mesh_model_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h index 65a2af4f7..6e7e0659a 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, @@ -70,10 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX, } btc_ble_mesh_sensor_server_evt_t; -void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); +void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h index 7db8764b5..c021aa52d 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h @@ -53,15 +53,14 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf); +void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, @@ -71,10 +70,9 @@ typedef enum { BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX, } btc_ble_mesh_time_scene_server_evt_t; -void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); +void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const u8_t *val, size_t len); void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h index ad968dd0e..f78a55776 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h @@ -22,6 +22,7 @@ #include #include +#include "esp_attr.h" #include "esp_heap_caps.h" #include "mesh_byteorder.h" @@ -34,14 +35,11 @@ extern "C" { #endif -#if CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST -#define bt_mesh_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#define bt_mesh_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#else -#define bt_mesh_malloc(size) malloc((size)) -#define bt_mesh_calloc(size) calloc(1, (size)) -#endif /* CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST */ -#define bt_mesh_free(p) free((p)) +IRAM_ATTR void *bt_mesh_malloc(size_t size); + +IRAM_ATTR void *bt_mesh_calloc(size_t size); + +IRAM_ATTR void bt_mesh_free(void *ptr); /** * @brief This function allocates memory to store outgoing message. diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h index 1a6baee71..eef953eb3 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h @@ -13,6 +13,7 @@ #include "freertos/queue.h" #include "freertos/semphr.h" +#include "sdkconfig.h" #include "mesh_types.h" #ifdef __cplusplus @@ -36,6 +37,8 @@ extern "C" { #endif #define BLE_MESH_ADV_TASK_STACK_SIZE 3072 +#define BLE_MESH_ADV_TASK_NAME "mesh_adv_task" +#define BLE_MESH_ADV_TASK_PRIO (configMAX_PRIORITIES - 5) /** * @brief Put the current thread to sleep. diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h index 488e010fa..faded20d3 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h @@ -25,7 +25,7 @@ extern "C" { typedef struct { SemaphoreHandle_t mutex; -#if CONFIG_SPIRAM_USE_MALLOC +#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC StaticQueue_t *buffer; #endif } bt_mesh_mutex_t; diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h index 5a189630c..61cddba0d 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h @@ -28,18 +28,6 @@ typedef unsigned long long u64_t; typedef int bt_mesh_atomic_t; -#ifndef bool -#define bool int8_t -#endif - -#ifndef false -#define false 0 -#endif - -#ifndef true -#define true 1 -#endif - #ifndef PRIu64 #define PRIu64 "llu" #endif diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h index 7eebe71b4..2690adde7 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h @@ -186,15 +186,6 @@ const char *bt_hex(const void *buf, size_t len); void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len); -unsigned int _copy(uint8_t *to, unsigned int to_len, - const uint8_t *from, unsigned int from_len); - -void _set(void *to, uint8_t val, unsigned int len); - -uint8_t _double_byte(uint8_t a); - -int _compare(const uint8_t *a, const uint8_t *b, size_t size); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c index 10a9e6566..21f3394d1 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c @@ -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("%s, pool %p, avail_count %d, uninit_count %d", __func__, + NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d", 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("%s, pool %p, uninit_count %d, buf_count %d", __func__, + NET_BUF_DBG("Alloc, pool %p, uninit_count %d, buf_count %d", 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("%s, Failed to get free buffer", __func__); + NET_BUF_ERR("Out of free buffer, pool %p", pool); return NULL; success: @@ -579,11 +579,11 @@ success: if (size) { buf->__buf = data_alloc(buf, &size, timeout); if (!buf->__buf) { - NET_BUF_ERR("%s, Failed to allocate data", __func__); + NET_BUF_ERR("Out of data, buf %p", buf); return NULL; } } else { - NET_BUF_WARN("%s, Zero data size", __func__); + NET_BUF_WARN("Zero data size, buf %p", buf); buf->__buf = NULL; } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_common.c b/components/bt/esp_ble_mesh/mesh_common/mesh_common.c index 8ab86266e..369b73637 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_common.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_common.c @@ -19,6 +19,37 @@ #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; @@ -26,7 +57,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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return NULL; } @@ -52,7 +83,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("%s, Message is sent by a server model", __func__); + BT_DBG("Message is sent by a server model"); return NODE; } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c b/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c index 1bd6a2358..5cee41e4f 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_mutex.c @@ -22,32 +22,36 @@ static bt_mesh_mutex_t atomic_lock; void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex) { if (!mutex) { - BT_ERR("%s, Invalid mutex", __func__); + BT_ERR("Create, invalid mutex"); return; } -#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, "%s, Failed to create static mutex", __func__); -#else - mutex->mutex = xSemaphoreCreateMutex(); - __ASSERT(mutex->mutex, "%s, Failed to create mutex", __func__); +#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"); + mutex->mutex = xSemaphoreCreateMutexStatic(mutex->buffer); + __ASSERT(mutex->mutex, "Failed to create static mutex"); +#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */ + mutex->mutex = xSemaphoreCreateMutex(); + __ASSERT(mutex->mutex, "Failed to create mutex"); +#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */ } void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex) { if (!mutex) { - BT_ERR("%s, Invalid mutex", __func__); + BT_ERR("Free, invalid mutex"); return; } if (mutex->mutex) { vSemaphoreDelete(mutex->mutex); mutex->mutex = NULL; -#if CONFIG_SPIRAM_USE_MALLOC +#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC heap_caps_free(mutex->buffer); mutex->buffer = NULL; #endif @@ -57,7 +61,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("%s, Invalid mutex", __func__); + BT_ERR("Lock, invalid mutex"); return; } @@ -69,7 +73,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("%s, Invalid mutex", __func__); + BT_ERR("Unlock, invalid mutex"); return; } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c index 50fe7813e..0f7bcfe19 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c @@ -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, "%s, Failed to create hash map", __func__); + __ASSERT(bm_alarm_hash_map, "Failed to create hash map"); } 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("%s, Alarm not created", __func__); + BT_ERR("Alarm not created"); bt_mesh_alarm_unlock(); return -EIO; } if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) { - BT_ERR("%s, Alarm not set", __func__); + BT_ERR("Alarm not set"); 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("%s, Alarm not found", __func__); + BT_ERR("Init, alarm not found"); 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("%s, Alarm not found", __func__); + BT_WARN("Submit, alarm not found"); 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("%s, Alarm not found", __func__); + BT_WARN("Submit, alarm not found"); 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("%s, Alarm not found", __func__); + BT_WARN("Cancel, alarm not found"); 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("%s, Alarm not found", __func__); + BT_WARN("Free, alarm not found"); 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("%s, Alarm not found", __func__); + BT_WARN("Get time, alarm not found"); bt_mesh_alarm_unlock(); return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_util.c b/components/bt/esp_ble_mesh/mesh_common/mesh_util.c index 83949594b..af7a32f7e 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_util.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_util.c @@ -10,18 +10,20 @@ #include "mesh_types.h" #include "mesh_util.h" -#include "mesh_aes_encrypt.h" - -#define MASK_TWENTY_SEVEN 0x1b const char *bt_hex(const void *buf, size_t len) { static const char hex[] = "0123456789abcdef"; - static char str[129]; + static char hexbufs[2][129]; + static u8_t curbuf; const u8_t *b = buf; + char *str = NULL; int i; - len = MIN(len, (sizeof(str) - 1) / 2); + str = hexbufs[curbuf++]; + curbuf %= ARRAY_SIZE(hexbufs); + + len = MIN(len, (sizeof(hexbufs[0]) - 1) / 2); for (i = 0; i < len; i++) { str[i * 2] = hex[b[i] >> 4]; @@ -40,39 +42,3 @@ void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len) *dst++ = *--src; } } - -unsigned int _copy(uint8_t *to, unsigned int to_len, - const uint8_t *from, unsigned int from_len) -{ - if (from_len <= to_len) { - (void)memcpy(to, from, from_len); - return from_len; - } else { - return TC_CRYPTO_FAIL; - } -} - -void _set(void *to, uint8_t val, unsigned int len) -{ - (void)memset(to, val, len); -} - -/* - * Doubles the value of a byte for values up to 127. - */ -uint8_t _double_byte(uint8_t a) -{ - return ((a << 1) ^ ((a >> 7) * MASK_TWENTY_SEVEN)); -} - -int _compare(const uint8_t *a, const uint8_t *b, size_t size) -{ - const uint8_t *tempa = a; - const uint8_t *tempb = b; - uint8_t result = 0; - - for (unsigned int i = 0; i < size; i++) { - result |= tempa[i] ^ tempb[i]; - } - return result; -} diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h similarity index 78% rename from components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h rename to components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h index afaa6b27d..aa636c7d4 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h @@ -46,11 +46,10 @@ * 2) call tc_aes_encrypt/decrypt to process the data. */ -#ifndef _BLE_MESH_AES_ENCRYPT_H_ -#define _BLE_MESH_AES_ENCRYPT_H_ +#ifndef __BLE_MESH_TC_AES_H__ +#define __BLE_MESH_TC_AES_H__ #include -#include #ifdef __cplusplus extern "C" { @@ -59,41 +58,13 @@ extern "C" { #define Nb (4) /* number of columns (32-bit words) comprising the state */ #define Nk (4) /* number of 32-bit words comprising the key */ #define Nr (10) /* number of rounds */ -#define TC_AES_BLOCK_SIZE (Nb*Nk) -#define TC_AES_KEY_SIZE (Nb*Nk) - -#define TC_CRYPTO_SUCCESS 1 -#define TC_CRYPTO_FAIL 0 - -#define TC_ZERO_BYTE 0x00 - -/* padding for last message block */ -#define TC_CMAC_PADDING 0x80 +#define TC_AES_BLOCK_SIZE (Nb*Nk) +#define TC_AES_KEY_SIZE (Nb*Nk) typedef struct tc_aes_key_sched_struct { unsigned int words[Nb * (Nr + 1)]; } *TCAesKeySched_t; -/* struct tc_cmac_struct represents the state of a CMAC computation */ -typedef struct tc_cmac_struct { - /* initialization vector */ - uint8_t iv[TC_AES_BLOCK_SIZE]; - /* used if message length is a multiple of block_size bytes */ - uint8_t K1[TC_AES_BLOCK_SIZE]; - /* used if message length isn't a multiple block_size bytes */ - uint8_t K2[TC_AES_BLOCK_SIZE]; - /* where to put bytes that didn't fill a block */ - uint8_t leftover[TC_AES_BLOCK_SIZE]; - /* identifies the encryption key */ - unsigned int keyid; - /* next available leftover location */ - unsigned int leftover_offset; - /* AES key schedule */ - TCAesKeySched_t sched; - /* calls to tc_cmac_update left before re-key */ - uint64_t countdown; -} *TCCmacState_t; - /** * @brief Set AES-128 encryption key * Uses key k to initialize s @@ -152,20 +123,8 @@ int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k); int tc_aes_decrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s); -int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, TCAesKeySched_t sched); - -void gf_double(uint8_t *out, uint8_t *in); - -int tc_cmac_init(TCCmacState_t s); - -int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t data_length); - -int tc_cmac_final(uint8_t *tag, TCCmacState_t s); - -int tc_cmac_erase(TCCmacState_t s); - #ifdef __cplusplus } #endif -#endif /* _BLE_MESH_AES_ENCRYPT_H_ */ +#endif /* __BLE_MESH_TC_AES_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h new file mode 100644 index 000000000..4be3d95e5 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h @@ -0,0 +1,151 @@ +/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CBC mode implementation. + * + * Overview: CBC (for "cipher block chaining") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any block + * cipher to provide confidentiality of strings whose lengths are + * multiples of the block_size of the underlying block cipher. + * TinyCrypt hard codes AES as the block cipher. + * + * Security: CBC mode provides data confidentiality given that the maximum + * number q of blocks encrypted under a single key satisfies + * q < 2^63, which is not a practical constraint (it is considered a + * good practice to replace the encryption when q == 2^56). CBC mode + * provides NO data integrity. + * + * CBC mode assumes that the IV value input into the + * tc_cbc_mode_encrypt is randomly generated. The TinyCrypt library + * provides HMAC-PRNG module, which generates suitable IVs. Other + * methods for generating IVs are acceptable, provided that the + * values of the IVs generated appear random to any adversary, + * including someone with complete knowledge of the system design. + * + * The randomness property on which CBC mode's security depends is + * the unpredictability of the IV. Since it is unpredictable, this + * means in practice that CBC mode requires that the IV is stored + * somehow with the ciphertext in order to recover the plaintext. + * + * TinyCrypt CBC encryption prepends the IV to the ciphertext, + * because this affords a more efficient (few buffers) decryption. + * Hence tc_cbc_mode_encrypt assumes the ciphertext buffer is always + * 16 bytes larger than the plaintext buffer. + * + * Requires: AES-128 + * + * Usage: 1) call tc_cbc_mode_encrypt to encrypt data. + * + * 2) call tc_cbc_mode_decrypt to decrypt data. + * + */ + +#ifndef __BLE_MESH_TC_CBC_MODE_H__ +#define __BLE_MESH_TC_CBC_MODE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CBC encryption procedure + * CBC encrypts inlen bytes of the in buffer into the out buffer + * using the encryption key schedule provided, prepends iv to out + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes: - sched has been configured by aes_set_encrypt_key + * - iv contains a 16 byte random string + * - out buffer is large enough to hold the ciphertext + iv + * - out buffer is a contiguous buffer + * - in holds the plaintext and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive the ciphertext + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- plaintext to encrypt + * @param inlen IN -- length of plaintext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this encrypt + */ +int tc_cbc_mode_encrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +/** + * @brief CBC decryption procedure + * CBC decrypts inlen bytes of the in buffer into the out buffer + * using the provided encryption key schedule + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes:- in == iv + ciphertext, i.e. the iv and the ciphertext are + * contiguous. This allows for a very efficient decryption + * algorithm that would not otherwise be possible + * - sched was configured by aes_set_decrypt_key + * - out buffer is large enough to hold the decrypted plaintext + * and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive decrypted data + * @param outlen IN -- length of plaintext buffer in bytes + * @param in IN -- ciphertext to decrypt, including IV + * @param inlen IN -- length of ciphertext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this decrypt + * + */ +int tc_cbc_mode_decrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CBC_MODE_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h new file mode 100644 index 000000000..1f85c76e6 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h @@ -0,0 +1,211 @@ +/* ccm_mode.h - TinyCrypt interface to a CCM mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CCM mode implementation. + * + * Overview: CCM (for "Counter with CBC-MAC") mode is a NIST approved mode of + * operation defined in SP 800-38C. + * + * TinyCrypt CCM implementation accepts: + * + * 1) Both non-empty payload and associated data (it encrypts and + * authenticates the payload and also authenticates the associated + * data); + * 2) Non-empty payload and empty associated data (it encrypts and + * authenticates the payload); + * 3) Non-empty associated data and empty payload (it degenerates to + * an authentication mode on the associated data). + * + * TinyCrypt CCM implementation accepts associated data of any length + * between 0 and (2^16 - 2^8) bytes. + * + * Security: The mac length parameter is an important parameter to estimate the + * security against collision attacks (that aim at finding different + * messages that produce the same authentication tag). TinyCrypt CCM + * implementation accepts any even integer between 4 and 16, as + * suggested in SP 800-38C. + * + * RFC-3610, which also specifies CCM, presents a few relevant + * security suggestions, such as: it is recommended for most + * applications to use a mac length greater than 8. Besides, the + * usage of the same nonce for two different messages which are + * encrypted with the same key destroys the security of CCM mode. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ccm_config to configure. + * + * 2) call tc_ccm_mode_encrypt to encrypt data and generate tag. + * + * 3) call tc_ccm_mode_decrypt to decrypt data and verify tag. + */ + +#ifndef __BLE_MESH_TC_CCM_MODE_H__ +#define __BLE_MESH_TC_CCM_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* max additional authenticated size in bytes: 2^16 - 2^8 = 65280 */ +#define TC_CCM_AAD_MAX_BYTES 0xff00 + +/* max message size in bytes: 2^(8L) = 2^16 = 65536 */ +#define TC_CCM_PAYLOAD_MAX_BYTES 0x10000 + +/* struct tc_ccm_mode_struct represents the state of a CCM computation */ +typedef struct tc_ccm_mode_struct { + TCAesKeySched_t sched; /* AES key schedule */ + uint8_t *nonce; /* nonce required by CCM */ + unsigned int mlen; /* mac length in bytes (parameter t in SP-800 38C) */ +} *TCCcmMode_t; + +/** + * @brief CCM configuration procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * c == NULL or + * sched == NULL or + * nonce == NULL or + * mlen != {4, 6, 8, 10, 12, 16} + * @param c -- CCM state + * @param sched IN -- AES key schedule + * @param nonce IN - nonce + * @param nlen -- nonce length in bytes + * @param mlen -- mac length in bytes (parameter t in SP-800 38C) + */ +int tc_ccm_config(TCCcmMode_t c, TCAesKeySched_t sched, uint8_t *nonce, + unsigned int nlen, unsigned int mlen); + +/** + * @brief CCM tag generation and encryption procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen + maclength) + * + * @param out OUT -- encrypted data + * @param olen IN -- output length in bytes + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen + c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_generation_encryption(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, + unsigned int plen, TCCcmMode_t c); + +/** + * @brief CCM decryption and tag verification procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen - c->mlen) + * + * @param out OUT -- decrypted data + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen - c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_decryption_verification(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, unsigned int plen, + TCCcmMode_t c); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CCM_MODE_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h new file mode 100644 index 000000000..cf0b3601b --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h @@ -0,0 +1,194 @@ +/* cmac_mode.h -- interface to a CMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CMAC implementation. + * + * Overview: CMAC is defined NIST in SP 800-38B, and is the standard algorithm + * for computing a MAC using a block cipher. It can compute the MAC + * for a byte string of any length. It is distinguished from CBC-MAC + * in the processing of the final message block; CMAC uses a + * different technique to compute the final message block is full + * size or only partial, while CBC-MAC uses the same technique for + * both. This difference permits CMAC to be applied to variable + * length messages, while all messages authenticated by CBC-MAC must + * be the same length. + * + * Security: AES128-CMAC mode of operation offers 64 bits of security against + * collision attacks. Note however that an external attacker cannot + * generate the tags him/herself without knowing the MAC key. In this + * sense, to attack the collision property of AES128-CMAC, an + * external attacker would need the cooperation of the legal user to + * produce an exponentially high number of tags (e.g. 2^64) to + * finally be able to look for collisions and benefit from them. As + * an extra precaution, the current implementation allows to at most + * 2^48 calls to the tc_cmac_update function before re-calling + * tc_cmac_setup (allowing a new key to be set), as suggested in + * Appendix B of SP 800-38B. + * + * Requires: AES-128 + * + * Usage: This implementation provides a "scatter-gather" interface, so that + * the CMAC value can be computed incrementally over a message + * scattered in different segments throughout memory. Experience shows + * this style of interface tends to minimize the burden of programming + * correctly. Like all symmetric key operations, it is session + * oriented. + * + * To begin a CMAC session, use tc_cmac_setup to initialize a struct + * tc_cmac_struct with encryption key and buffer. Our implementation + * always assume that the AES key to be the same size as the block + * cipher block size. Once setup, this data structure can be used for + * many CMAC computations. + * + * Once the state has been setup with a key, computing the CMAC of + * some data requires three steps: + * + * (1) first use tc_cmac_init to initialize a new CMAC computation. + * (2) next mix all of the data into the CMAC computation state using + * tc_cmac_update. If all of the data resides in a single data + * segment then only one tc_cmac_update call is needed; if data + * is scattered throughout memory in n data segments, then n calls + * will be needed. CMAC IS ORDER SENSITIVE, to be able to detect + * attacks that swap bytes, so the order in which data is mixed + * into the state is critical! + * (3) Once all of the data for a message has been mixed, use + * tc_cmac_final to compute the CMAC tag value. + * + * Steps (1)-(3) can be repeated as many times as you want to CMAC + * multiple messages. A practical limit is 2^48 1K messages before you + * have to change the key. + * + * Once you are done computing CMAC with a key, it is a good idea to + * destroy the state so an attacker cannot recover the key; use + * tc_cmac_erase to accomplish this. + */ + +#ifndef __BLE_MESH_TC_CMAC_MODE_H__ +#define __BLE_MESH_TC_CMAC_MODE_H__ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* padding for last message block */ +#define TC_CMAC_PADDING 0x80 + +/* struct tc_cmac_struct represents the state of a CMAC computation */ +typedef struct tc_cmac_struct { + /* initialization vector */ + uint8_t iv[TC_AES_BLOCK_SIZE]; + /* used if message length is a multiple of block_size bytes */ + uint8_t K1[TC_AES_BLOCK_SIZE]; + /* used if message length isn't a multiple block_size bytes */ + uint8_t K2[TC_AES_BLOCK_SIZE]; + /* where to put bytes that didn't fill a block */ + uint8_t leftover[TC_AES_BLOCK_SIZE]; + /* identifies the encryption key */ + unsigned int keyid; + /* next available leftover location */ + unsigned int leftover_offset; + /* AES key schedule */ + TCAesKeySched_t sched; + /* calls to tc_cmac_update left before re-key */ + uint64_t countdown; +} *TCCmacState_t; + +/** + * @brief Configures the CMAC state to use the given AES key + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * key == NULL + * + * @param s IN/OUT -- the state to set up + * @param key IN -- the key to use + * @param sched IN -- AES key schedule + */ +int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, + TCAesKeySched_t sched); + +/** + * @brief Erases the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to erase + */ +int tc_cmac_erase(TCCmacState_t s); + +/** + * @brief Initializes a new CMAC computation + * @return returns TC_CRYPTO_SUCCESS (1) after having initialized the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to initialize + */ +int tc_cmac_init(TCCmacState_t s); + +/** + * @brief Incrementally computes CMAC over the next data segment + * @return returns TC_CRYPTO_SUCCESS (1) after successfully updating the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * if data == NULL when dlen > 0 + * + * @param s IN/OUT -- the CMAC state + * @param data IN -- the next data segment to MAC + * @param dlen IN -- the length of data in bytes + */ +int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t dlen); + +/** + * @brief Generates the tag from the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after successfully generating the tag + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * s == NULL + * + * @param tag OUT -- the CMAC tag + * @param s IN -- CMAC state + */ +int tc_cmac_final(uint8_t *tag, TCCmacState_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CMAC_MODE_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h new file mode 100644 index 000000000..0abb01a15 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h @@ -0,0 +1,61 @@ +/* constants.h - TinyCrypt interface to constants */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to constants. + * + */ + +#ifndef __BLE_MESH_TC_CONSTANTS_H__ +#define __BLE_MESH_TC_CONSTANTS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define TC_CRYPTO_SUCCESS 1 +#define TC_CRYPTO_FAIL 0 + +#define TC_ZERO_BYTE 0x00 + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CONSTANTS_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h new file mode 100644 index 000000000..039f58c86 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h @@ -0,0 +1,108 @@ +/* ctr_mode.h - TinyCrypt interface to CTR mode */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to CTR mode. + * + * Overview: CTR (pronounced "counter") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any + * block cipher to provide confidentiality of strings of any + * length. TinyCrypt hard codes AES128 as the block cipher. + * + * Security: CTR mode achieves confidentiality only if the counter value is + * never reused with a same encryption key. If the counter is + * repeated, than an adversary might be able to defeat the scheme. + * + * A usual method to ensure different counter values refers to + * initialize the counter in a given value (0, for example) and + * increases it every time a new block is enciphered. This naturally + * leaves to a limitation on the number q of blocks that can be + * enciphered using a same key: q < 2^(counter size). + * + * TinyCrypt uses a counter of 32 bits. This means that after 2^32 + * block encryptions, the counter will be reused (thus losing CBC + * security). 2^32 block encryptions should be enough for most of + * applications targeting constrained devices. Applications intended + * to encrypt a larger number of blocks must replace the key after + * 2^32 block encryptions. + * + * CTR mode provides NO data integrity. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ctr_mode to process the data to encrypt/decrypt. + * + */ + +#ifndef __BLE_MESH_TC_CTR_MODE_H__ +#define __BLE_MESH_TC_CTR_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CTR mode encryption/decryption procedure. + * CTR mode encrypts (or decrypts) inlen bytes from in buffer into out buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * inlen != outlen + * @note Assumes:- The current value in ctr has NOT been used with sched + * - out points to inlen bytes + * - in points to inlen bytes + * - ctr is an integer counter in littleEndian format + * - sched was initialized by aes_set_encrypt_key + * @param out OUT -- produced ciphertext (plaintext) + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- data to encrypt (or decrypt) + * @param inlen IN -- length of input data in bytes + * @param ctr IN/OUT -- the current counter value + * @param sched IN -- an initialized AES key schedule + */ +int tc_ctr_mode(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_MODE_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h new file mode 100644 index 000000000..04e070d3e --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h @@ -0,0 +1,166 @@ +/* ctr_prng.h - TinyCrypt interface to a CTR-PRNG implementation */ + +/* + * Copyright (c) 2016, Chris Morrison + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CTR-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the CTR-PRNG one + * which is based on AES. TinyCrypt implements CTR-PRNG with + * AES-128. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (AES-128 + * in this instance). + * + * Requires: - AES-128 + * + * Usage: 1) call tc_ctr_prng_init to seed the prng context + * + * 2) call tc_ctr_prng_reseed to mix in additional entropy into + * the prng context + * + * 3) call tc_ctr_prng_generate to output the pseudo-random data + * + * 4) call tc_ctr_prng_uninstantiate to zero out the prng context + */ + +#ifndef __BLE_MESH_TC_CTR_PRNG_H__ +#define __BLE_MESH_TC_CTR_PRNG_H__ + +#include + +#define TC_CTR_PRNG_RESEED_REQ -1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + /* updated each time another BLOCKLEN_BYTES bytes are produced */ + uint8_t V[TC_AES_BLOCK_SIZE]; + + /* updated whenever the PRNG is reseeded */ + struct tc_aes_key_sched_struct key; + + /* number of requests since initialization/reseeding */ + uint64_t reseedCount; +} TCCtrPrng_t; + + +/** + * @brief CTR-PRNG initialization procedure + * Initializes prng context with entropy and personalization string (if any) + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropyLen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note Only the first (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) bytes of + * both the entropy and personalization inputs are used - + * supplying additional bytes has no effect. + * @param ctx IN/OUT -- the PRNG context to initialize + * @param entropy IN -- entropy used to seed the PRNG + * @param entropyLen IN -- entropy length in bytes + * @param personalization IN -- personalization string used to seed the PRNG + * (may be null) + * @param plen IN -- personalization length in bytes + * + */ +int tc_ctr_prng_init(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const personalization, + unsigned int pLen); + +/** + * @brief CTR-PRNG reseed procedure + * Mixes entropy and additional_input into the prng context + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropylen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note It is better to reseed an existing prng context rather than + * re-initialise, so that any existing entropy in the context is + * presereved. This offers some protection against undetected failures + * of the entropy source. + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG state + * @param entropy IN -- entropy to mix into the prng + * @param entropylen IN -- length of entropy in bytes + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + */ +int tc_ctr_prng_reseed(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const additional_input, + unsigned int additionallen); + +/** + * @brief CTR-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CTR_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * out == NULL, + * outlen >= 2^16 + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG context + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + */ +int tc_ctr_prng_generate(TCCtrPrng_t *const ctx, + uint8_t const *const additional_input, + unsigned int additionallen, + uint8_t *const out, + unsigned int outlen); + +/** + * @brief CTR-PRNG uninstantiate procedure + * Zeroes the internal state of the supplied prng context + * @return none + * @param ctx IN/OUT -- the PRNG context + */ +void tc_ctr_prng_uninstantiate(TCCtrPrng_t *const ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_PRNG_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h new file mode 100644 index 000000000..72ba652f2 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h @@ -0,0 +1,545 @@ +/* ecc.h - TinyCrypt interface to common ECC functions */ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to common ECC functions. + * + * Overview: This software is an implementation of common functions + * necessary to elliptic curve cryptography. This implementation uses + * curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + */ + +#ifndef __BLE_MESH_TC_UECC_H__ +#define __BLE_MESH_TC_UECC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Word size (4 bytes considering 32-bits architectures) */ +#define uECC_WORD_SIZE 4 + +/* setting max number of calls to prng: */ +#ifndef uECC_RNG_MAX_TRIES +#define uECC_RNG_MAX_TRIES 64 +#endif + +/* defining data types to store word and bit counts: */ +typedef int8_t wordcount_t; +typedef int16_t bitcount_t; +/* defining data type for comparison result: */ +typedef int8_t cmpresult_t; +/* defining data type to store ECC coordinate/point in 32bits words: */ +typedef unsigned int uECC_word_t; +/* defining data type to store an ECC coordinate/point in 64bits words: */ +typedef uint64_t uECC_dword_t; + +/* defining masks useful for ecc computations: */ +#define HIGH_BIT_SET 0x80000000 +#define uECC_WORD_BITS 32 +#define uECC_WORD_BITS_SHIFT 5 +#define uECC_WORD_BITS_MASK 0x01F + +/* Number of words of 32 bits to represent an element of the the curve p-256: */ +#define NUM_ECC_WORDS 8 +/* Number of bytes to represent an element of the the curve p-256: */ +#define NUM_ECC_BYTES (uECC_WORD_SIZE*NUM_ECC_WORDS) + +/* structure that represents an elliptic curve (e.g. p256):*/ +struct uECC_Curve_t; +typedef const struct uECC_Curve_t *uECC_Curve; +struct uECC_Curve_t { + wordcount_t num_words; + wordcount_t num_bytes; + bitcount_t num_n_bits; + uECC_word_t p[NUM_ECC_WORDS]; + uECC_word_t n[NUM_ECC_WORDS]; + uECC_word_t G[NUM_ECC_WORDS * 2]; + uECC_word_t b[NUM_ECC_WORDS]; + void (*double_jacobian)(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *Z1, + uECC_Curve curve); + void (*x_side)(uECC_word_t *result, const uECC_word_t *x, uECC_Curve curve); + void (*mmod_fast)(uECC_word_t *result, uECC_word_t *product); +}; + +/* + * @brief computes doubling of point ion jacobian coordinates, in place. + * @param X1 IN/OUT -- x coordinate + * @param Y1 IN/OUT -- y coordinate + * @param Z1 IN/OUT -- z coordinate + * @param curve IN -- elliptic curve + */ +void double_jacobian_default(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *Z1, uECC_Curve curve); + +/* + * @brief Computes x^3 + ax + b. result must not overlap x. + * @param result OUT -- x^3 + ax + b + * @param x IN -- value of x + * @param curve IN -- elliptic curve + */ +void x_side_default(uECC_word_t *result, const uECC_word_t *x, + uECC_Curve curve); + +/* + * @brief Computes result = product % curve_p + * from http://www.nsa.gov/ia/_files/nist-routines.pdf + * @param result OUT -- product % curve_p + * @param product IN -- value to be reduced mod curve_p + */ +void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product); + +/* Bytes to words ordering: */ +#define BYTES_TO_WORDS_8(a, b, c, d, e, f, g, h) 0x##d##c##b##a, 0x##h##g##f##e +#define BYTES_TO_WORDS_4(a, b, c, d) 0x##d##c##b##a +#define BITS_TO_WORDS(num_bits) \ + ((num_bits + ((uECC_WORD_SIZE * 8) - 1)) / (uECC_WORD_SIZE * 8)) +#define BITS_TO_BYTES(num_bits) ((num_bits + 7) / 8) + +/* definition of curve NIST p-256: */ +static const struct uECC_Curve_t curve_secp256r1 = { + NUM_ECC_WORDS, + NUM_ECC_BYTES, + 256, /* num_n_bits */ { + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(FF, FF, FF, FF, 00, 00, 00, 00), + BYTES_TO_WORDS_8(00, 00, 00, 00, 00, 00, 00, 00), + BYTES_TO_WORDS_8(01, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(51, 25, 63, FC, C2, CA, B9, F3), + BYTES_TO_WORDS_8(84, 9E, 17, A7, AD, FA, E6, BC), + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(00, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(96, C2, 98, D8, 45, 39, A1, F4), + BYTES_TO_WORDS_8(A0, 33, EB, 2D, 81, 7D, 03, 77), + BYTES_TO_WORDS_8(F2, 40, A4, 63, E5, E6, BC, F8), + BYTES_TO_WORDS_8(47, 42, 2C, E1, F2, D1, 17, 6B), + + BYTES_TO_WORDS_8(F5, 51, BF, 37, 68, 40, B6, CB), + BYTES_TO_WORDS_8(CE, 5E, 31, 6B, 57, 33, CE, 2B), + BYTES_TO_WORDS_8(16, 9E, 0F, 7C, 4A, EB, E7, 8E), + BYTES_TO_WORDS_8(9B, 7F, 1A, FE, E2, 42, E3, 4F) + }, { + BYTES_TO_WORDS_8(4B, 60, D2, 27, 3E, 3C, CE, 3B), + BYTES_TO_WORDS_8(F6, B0, 53, CC, B0, 06, 1D, 65), + BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3), + BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A) + }, + &double_jacobian_default, + &x_side_default, + &vli_mmod_fast_secp256r1 +}; + +uECC_Curve uECC_secp256r1(void); + +/* + * @brief Generates a random integer in the range 0 < random < top. + * Both random and top have num_words words. + * @param random OUT -- random integer in the range 0 < random < top + * @param top IN -- upper limit + * @param num_words IN -- number of words + * @return a random integer in the range 0 < random < top + */ +int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top, + wordcount_t num_words); + + +/* uECC_RNG_Function type + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A correctly functioning RNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a correctly functioning RNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct RNG function is set by default. If you are building on another + * POSIX-compliant system that supports /dev/random or /dev/urandom, you can + * define uECC_POSIX to use the predefined RNG. + */ +typedef int(*uECC_RNG_Function)(uint8_t *dest, unsigned int size); + +/* + * @brief Set the function that will be used to generate random bytes. The RNG + * function should return 1 if the random data was generated, or 0 if the random + * data could not be generated. + * + * @note On platforms where there is no predefined RNG function, this must be + * called before uECC_make_key() or uECC_sign() are used. + * + * @param rng_function IN -- function that will be used to generate random bytes + */ +void uECC_set_rng(uECC_RNG_Function rng_function); + +/* + * @brief provides current uECC_RNG_Function. + * @return Returns the function that will be used to generate random bytes. + */ +uECC_RNG_Function uECC_get_rng(void); + +/* + * @brief computes the size of a private key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return size of a private key for the curve in bytes. + */ +int uECC_curve_private_key_size(uECC_Curve curve); + +/* + * @brief computes the size of a public key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return the size of a public key for the curve in bytes. + */ +int uECC_curve_public_key_size(uECC_Curve curve); + +/* + * @brief Compute the corresponding public key for a private key. + * @param private_key IN -- The private key to compute the public key for + * @param public_key OUT -- Will be filled in with the corresponding public key + * @param curve + * @return Returns 1 if key was computed successfully, 0 if an error occurred. + */ +int uECC_compute_public_key(const uint8_t *private_key, + uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Compute public-key. + * @return corresponding public-key. + * @param result OUT -- public-key + * @param private_key IN -- private-key + * @param curve IN -- elliptic curve + */ +uECC_word_t EccPoint_compute_public_key(uECC_word_t *result, + uECC_word_t *private_key, uECC_Curve curve); + +/* + * @brief Regularize the bitcount for the private key so that attackers cannot + * use a side channel attack to learn the number of leading zeros. + * @return Regularized k + * @param k IN -- private-key + * @param k0 IN/OUT -- regularized k + * @param k1 IN/OUT -- regularized k + * @param curve IN -- elliptic curve + */ +uECC_word_t regularize_k(const uECC_word_t *const k, uECC_word_t *k0, + uECC_word_t *k1, uECC_Curve curve); + +/* + * @brief Point multiplication algorithm using Montgomery's ladder with co-Z + * coordinates. See http://eprint.iacr.org/2011/338.pdf. + * @note Result may overlap point. + * @param result OUT -- returns scalar*point + * @param point IN -- elliptic curve point + * @param scalar IN -- scalar + * @param initial_Z IN -- initial value for z + * @param num_bits IN -- number of bits in scalar + * @param curve IN -- elliptic curve + */ +void EccPoint_mult(uECC_word_t *result, const uECC_word_t *point, + const uECC_word_t *scalar, const uECC_word_t *initial_Z, + bitcount_t num_bits, uECC_Curve curve); + +/* + * @brief Constant-time comparison to zero - secure way to compare long integers + * @param vli IN -- very long integer + * @param num_words IN -- number of words in the vli + * @return 1 if vli == 0, 0 otherwise. + */ +uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief Check if 'point' is the point at infinity + * @param point IN -- elliptic curve point + * @param curve IN -- elliptic curve + * @return if 'point' is the point at infinity, 0 otherwise. + */ +uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief computes the sign of left - right, in constant time. + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief computes sign of left - right, not in constant time. + * @note should not be used if inputs are part of a secret + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes result = (left - right) % mod. + * @note Assumes that (left < mod) and (right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left - right) % mod + * @param left IN -- leftright term in modular subtraction + * @param right IN -- right term in modular subtraction + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes P' = (x1', y1', Z3), P + Q = (x3, y3, Z3) or + * P => P', Q => P + Q + * @note assumes Input P = (x1, y1, Z), Q = (x2, y2, Z) + * @param X1 IN -- x coordinate of P + * @param Y1 IN -- y coordinate of P + * @param X2 IN -- x coordinate of Q + * @param Y2 IN -- y coordinate of Q + * @param curve IN -- elliptic curve + */ +void XYcZ_add(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *X2, + uECC_word_t *Y2, uECC_Curve curve); + +/* + * @brief Computes (x1 * z^2, y1 * z^3) + * @param X1 IN -- previous x1 coordinate + * @param Y1 IN -- previous y1 coordinate + * @param Z IN -- z value + * @param curve IN -- elliptic curve + */ +void apply_z(uECC_word_t *X1, uECC_word_t *Y1, const uECC_word_t *const Z, + uECC_Curve curve); + +/* + * @brief Check if bit is set. + * @return Returns nonzero if bit 'bit' of vli is set. + * @warning It is assumed that the value provided in 'bit' is within the + * boundaries of the word-array 'vli'. + * @note The bit ordering layout assumed for vli is: {31, 30, ..., 0}, + * {63, 62, ..., 32}, {95, 94, ..., 64}, {127, 126,..., 96} for a vli consisting + * of 4 uECC_word_t elements. + */ +uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit); + +/* + * @brief Computes result = product % mod, where product is 2N words long. + * @param result OUT -- product % mod + * @param mod IN -- module + * @param num_words IN -- number of words + * @warning Currently only designed to work for curve_p or curve_n. + */ +void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Computes modular product (using curve->mmod_fast) + * @param result OUT -- (left * right) mod % curve_p + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param curve IN -- elliptic curve + */ +void uECC_vli_modMult_fast(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, uECC_Curve curve); + +/* + * @brief Computes result = left - right. + * @note Can modify in place. + * @param result OUT -- left - right + * @param left IN -- left term in subtraction + * @param right IN -- right term in subtraction + * @param num_words IN -- number of words + * @return borrow + */ +uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words); + +/* + * @brief Constant-time comparison function(secure way to compare long ints) + * @param left IN -- left term in comparison + * @param right IN -- right term in comparison + * @param num_words IN -- number of words + * @return Returns 0 if left == right, 1 otherwise. + */ +uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes (left * right) % mod + * @param result OUT -- (left * right) % mod + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes (1 / input) % mod + * @note All VLIs are the same size. + * @note See "Euclid's GCD to Montgomery Multiplication to the Great Divide" + * @param result OUT -- (1 / input) % mod + * @param input IN -- value to be modular inverted + * @param mod IN -- mod + * @param num_words -- number of words + */ +void uECC_vli_modInv(uECC_word_t *result, const uECC_word_t *input, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Sets dest = src. + * @param dest OUT -- destination buffer + * @param src IN -- origin buffer + * @param num_words IN -- number of words + */ +void uECC_vli_set(uECC_word_t *dest, const uECC_word_t *src, + wordcount_t num_words); + +/* + * @brief Computes (left + right) % mod. + * @note Assumes that (left < mod) and right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left + right) % mod. + * @param left IN -- left term in addition + * @param right IN -- right term in addition + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modAdd(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Counts the number of bits required to represent vli. + * @param vli IN -- very long integer + * @param max_words IN -- number of words + * @return number of bits in given vli + */ +bitcount_t uECC_vli_numBits(const uECC_word_t *vli, + const wordcount_t max_words); + +/* + * @brief Erases (set to 0) vli + * @param vli IN -- very long integer + * @param num_words IN -- number of words + */ +void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief check if it is a valid point in the curve + * @param point IN -- point to be checked + * @param curve IN -- elliptic curve + * @return 0 if point is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + */ +int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief Check if a public key is valid. + * @param public_key IN -- The public key to be checked. + * @return returns 0 if the public key is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + * @exception returns -4 if public key is the group generator. + * + * @note Note that you are not required to check for a valid public key before + * using any other uECC functions. However, you may wish to avoid spending CPU + * time computing a shared secret or verifying a signature using an invalid + * public key. + */ +int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Converts an integer in uECC native format to big-endian bytes. + * @param bytes OUT -- bytes representation + * @param num_bytes IN -- number of bytes + * @param native IN -- uECC native representation + */ +void uECC_vli_nativeToBytes(uint8_t *bytes, int num_bytes, + const unsigned int *native); + +/* + * @brief Converts big-endian bytes to an integer in uECC native format. + * @param native OUT -- uECC native representation + * @param bytes IN -- bytes representation + * @param num_bytes IN -- number of bytes + */ +void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes, + int num_bytes); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UECC_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h new file mode 100644 index 000000000..ba9a0ebb2 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h @@ -0,0 +1,131 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DH implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DH implementation. + * + * Overview: This software is an implementation of EC-DH. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + */ + +#ifndef __BLE_MESH_TC_ECC_DH_H__ +#define __BLE_MESH_TC_ECC_DH_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a public/private key pair. + * @return returns TC_CRYPTO_SUCCESS (1) if the key pair was generated successfully + * returns TC_CRYPTO_FAIL (0) if error while generating key pair + * + * @param p_public_key OUT -- Will be filled in with the public key. Must be at + * least 2 * the curve size (in bytes) long. For curve secp256r1, p_public_key + * must be 64 bytes long. + * @param p_private_key OUT -- Will be filled in with the private key. Must be as + * long as the curve order (for secp256r1, p_private_key must be 32 bytes long). + * + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_make_key(). + */ +int uECC_make_key(uint8_t *p_public_key, uint8_t *p_private_key, uECC_Curve curve); + +#ifdef ENABLE_TESTS + +/** + * @brief Create a public/private key pair given a specific d. + * + * @note THIS FUNCTION SHOULD BE CALLED ONLY FOR TEST PURPOSES. Refer to + * uECC_make_key() function for real applications. + */ +int uECC_make_key_with_d(uint8_t *p_public_key, uint8_t *p_private_key, + unsigned int *d, uECC_Curve curve); +#endif + +/** + * @brief Compute a shared secret given your secret key and someone else's + * public key. + * @return returns TC_CRYPTO_SUCCESS (1) if the shared secret was computed successfully + * returns TC_CRYPTO_FAIL (0) otherwise + * + * @param p_secret OUT -- Will be filled in with the shared secret value. Must be + * the same size as the curve size (for curve secp256r1, secret must be 32 bytes + * long. + * @param p_public_key IN -- The public key of the remote party. + * @param p_private_key IN -- Your private key. + * + * @warning It is recommended to use the output of uECC_shared_secret() as the + * input of a recommended Key Derivation Function (see NIST SP 800-108) in + * order to produce a cryptographically secure symmetric key. + */ +int uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key, + uint8_t *p_secret, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DH_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h new file mode 100644 index 000000000..cfada859d --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h @@ -0,0 +1,139 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DSA implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DSA implementation. + * + * Overview: This software is an implementation of EC-DSA. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + * Usage: - To sign: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to ecdsa_sign function along with your + * private key and a random number. You must use a new non-predictable + * random number to generate each new signature. + * - To verify a signature: Compute the hash of the signed data using + * the same hash as the signer and pass it to this function along with + * the signer's public key and the signature values (r and s). + */ + +#ifndef __BLE_MESH_TC_ECC_DSA_H__ +#define __BLE_MESH_TC_ECC_DSA_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Generate an ECDSA signature for a given hash value. + * @return returns TC_CRYPTO_SUCCESS (1) if the signature generated successfully + * returns TC_CRYPTO_FAIL (0) if an error occurred. + * + * @param p_private_key IN -- Your private key. + * @param p_message_hash IN -- The hash of the message to sign. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature OUT -- Will be filled in with the signature value. Must be + * at least 2 * curve size long (for secp256r1, signature must be 64 bytes long). + * + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_sign(). + * @note Usage: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to this function along with your private key. + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + */ +int uECC_sign(const uint8_t *p_private_key, const uint8_t *p_message_hash, + unsigned p_hash_size, uint8_t *p_signature, uECC_Curve curve); + +#ifdef ENABLE_TESTS +/* + * THIS FUNCTION SHOULD BE CALLED FOR TEST PURPOSES ONLY. + * Refer to uECC_sign() function for real applications. + */ +int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash, + unsigned int hash_size, uECC_word_t *k, uint8_t *signature, + uECC_Curve curve); +#endif + +/** + * @brief Verify an ECDSA signature. + * @return returns TC_SUCCESS (1) if the signature is valid + * returns TC_FAIL (0) if the signature is invalid. + * + * @param p_public_key IN -- The signer's public key. + * @param p_message_hash IN -- The hash of the signed data. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature IN -- The signature values. + * + * @note Usage: Compute the hash of the signed data using the same hash as the + * signer and pass it to this function along with the signer's public key and + * the signature values (hash_size and signature). + */ +int uECC_verify(const uint8_t *p_public_key, const uint8_t *p_message_hash, + unsigned int p_hash_size, const uint8_t *p_signature, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DSA_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h new file mode 100644 index 000000000..972e5f7fe --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h @@ -0,0 +1,81 @@ +/* uECC_platform_specific.h - Interface to platform specific functions*/ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE.*/ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * uECC_platform_specific.h -- Interface to platform specific functions + */ + +#ifndef __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ +#define __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ + +/* + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A cryptographically-secure PRNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a cryptographically-secure PRNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct PRNG function is set by default (default_RNG_defined = 1) and works + * for some platforms, such as Unix and Linux. For other platforms, you may need + * to provide another PRNG function. +*/ +#define default_RNG_defined 0 + +int default_CSPRNG(uint8_t *dest, unsigned int size); + +#endif /* __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h new file mode 100644 index 000000000..cb399d8d5 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h @@ -0,0 +1,139 @@ +/* hmac.h - TinyCrypt interface to an HMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC implementation. + * + * Overview: HMAC is a message authentication code based on hash functions. + * TinyCrypt hard codes SHA-256 as the hash function. A message + * authentication code based on hash functions is also called a + * keyed cryptographic hash function since it performs a + * transformation specified by a key in an arbitrary length data + * set into a fixed length data set (also called tag). + * + * Security: The security of the HMAC depends on the length of the key and + * on the security of the hash function. Note that HMAC primitives + * are much less affected by collision attacks than their + * corresponding hash functions. + * + * Requires: SHA-256 + * + * Usage: 1) call tc_hmac_set_key to set the HMAC key. + * + * 2) call tc_hmac_init to initialize a struct hash_state before + * processing the data. + * + * 3) call tc_hmac_update to process the next input segment; + * tc_hmac_update can be called as many times as needed to process + * all of the segments of the input; the order is important. + * + * 4) call tc_hmac_final to out put the tag. + */ + +#ifndef __BLE_MESH_TC_HMAC_H__ +#define __BLE_MESH_TC_HMAC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct tc_hmac_state_struct { + /* the internal state required by h */ + struct tc_sha256_state_struct hash_state; + /* HMAC key schedule */ + uint8_t key[2 * TC_SHA256_BLOCK_SIZE]; +}; +typedef struct tc_hmac_state_struct *TCHmacState_t; + +/** + * @brief HMAC set key procedure + * Configures ctx to use key + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if + * ctx == NULL or + * key == NULL or + * key_size == 0 + * @param ctx IN/OUT -- the struct tc_hmac_state_struct to initial + * @param key IN -- the HMAC key to configure + * @param key_size IN -- the HMAC key size + */ +int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, + unsigned int key_size); + +/** + * @brief HMAC init procedure + * Initializes ctx to begin the next HMAC operation + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @param ctx IN/OUT -- struct tc_hmac_state_struct buffer to init + */ +int tc_hmac_init(TCHmacState_t ctx); + +/** + * @brief HMAC update procedure + * Mixes data_length bytes addressed by data into state + * @return returns TC_CRYPTO_SUCCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @note Assumes state has been initialized by tc_hmac_init + * @param ctx IN/OUT -- state of HMAC computation so far + * @param data IN -- data to incorporate into state + * @param data_length IN -- size of data in bytes + */ +int tc_hmac_update(TCHmacState_t ctx, const void *data, + unsigned int data_length); + +/** + * @brief HMAC final procedure + * Writes the HMAC tag into the tag buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * ctx == NULL or + * key == NULL or + * taglen != TC_SHA256_DIGEST_SIZE + * @note ctx is erased before exiting. This should never be changed/removed. + * @note Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes + * state has been initialized by tc_hmac_init + * @param tag IN/OUT -- buffer to receive computed HMAC tag + * @param taglen IN -- size of tag in bytes + * @param ctx IN/OUT -- the HMAC state for computing tag + */ +int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx); + +#ifdef __cplusplus +} +#endif + +#endif /*__BLE_MESH_TC_HMAC_H__*/ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h new file mode 100644 index 000000000..f7f900102 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h @@ -0,0 +1,164 @@ +/* hmac_prng.h - TinyCrypt interface to an HMAC-PRNG implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the HMAC-PRNG one + * which is based on HMAC. TinyCrypt implements HMAC-PRNG with + * certain modifications from the NIST SP 800-90A spec. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (HMAC and + * SHA256, for TinyCrypt). + * + * The NIST SP 800-90A standard tolerates a null personalization, + * while TinyCrypt requires a non-null personalization. This is + * because a personalization string (the host name concatenated + * with a time stamp, for example) is easily computed and might be + * the last line of defense against failure of the entropy source. + * + * Requires: - SHA-256 + * - HMAC + * + * Usage: 1) call tc_hmac_prng_init to set the HMAC key and process the + * personalization data. + * + * 2) call tc_hmac_prng_reseed to process the seed and additional + * input. + * + * 3) call tc_hmac_prng_generate to out put the pseudo-random data. + */ + +#ifndef __BLE_MESH_TC_HMAC_PRNG_H__ +#define __BLE_MESH_TC_HMAC_PRNG_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_HMAC_PRNG_RESEED_REQ -1 + +struct tc_hmac_prng_struct { + /* the HMAC instance for this PRNG */ + struct tc_hmac_state_struct h; + /* the PRNG key */ + uint8_t key[TC_SHA256_DIGEST_SIZE]; + /* PRNG state */ + uint8_t v[TC_SHA256_DIGEST_SIZE]; + /* calls to tc_hmac_prng_generate left before re-seed */ + unsigned int countdown; +}; + +typedef struct tc_hmac_prng_struct *TCHmacPrng_t; + +/** + * @brief HMAC-PRNG initialization procedure + * Initializes prng with personalization, disables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * personalization == NULL, + * plen > MAX_PLEN + * @note Assumes: - personalization != NULL. + * The personalization is a platform unique string (e.g., the host + * name) and is the last line of defense against failure of the + * entropy source + * @warning NIST SP 800-90A specifies 3 items as seed material during + * initialization: entropy seed, personalization, and an optional + * nonce. TinyCrypts requires instead a non-null personalization + * (which is easily computed) and indirectly requires an entropy + * seed (since the reseed function is mandatorily called after + * init) + * @param prng IN/OUT -- the PRNG state to initialize + * @param personalization IN -- personalization string + * @param plen IN -- personalization length in bytes + */ +int tc_hmac_prng_init(TCHmacPrng_t prng, + const uint8_t *personalization, + unsigned int plen); + +/** + * @brief HMAC-PRNG reseed procedure + * Mixes seed into prng, enables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * seed == NULL, + * seedlen < MIN_SLEN, + * seendlen > MAX_SLEN, + * additional_input != (const uint8_t *) 0 && additionallen == 0, + * additional_input != (const uint8_t *) 0 && additionallen > MAX_ALEN + * @note Assumes:- tc_hmac_prng_init has been called for prng + * - seed has sufficient entropy. + * + * @param prng IN/OUT -- the PRNG state + * @param seed IN -- entropy to mix into the prng + * @param seedlen IN -- length of seed in bytes + * @param additional_input IN -- additional input to the prng + * @param additionallen IN -- additional input length in bytes + */ +int tc_hmac_prng_reseed(TCHmacPrng_t prng, const uint8_t *seed, + unsigned int seedlen, const uint8_t *additional_input, + unsigned int additionallen); + +/** + * @brief HMAC-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_HMAC_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL, + * prng == NULL, + * outlen == 0, + * outlen >= MAX_OUT + * @note Assumes tc_hmac_prng_init has been called for prng + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + * @param prng IN/OUT -- the PRNG state + */ +int tc_hmac_prng_generate(uint8_t *out, unsigned int outlen, TCHmacPrng_t prng); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_HMAC_PRNG_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h new file mode 100644 index 000000000..c57cb00ca --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h @@ -0,0 +1,129 @@ +/* sha256.h - TinyCrypt interface to a SHA-256 implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a SHA-256 implementation. + * + * Overview: SHA-256 is a NIST approved cryptographic hashing algorithm + * specified in FIPS 180. A hash algorithm maps data of arbitrary + * size to data of fixed length. + * + * Security: SHA-256 provides 128 bits of security against collision attacks + * and 256 bits of security against pre-image attacks. SHA-256 does + * NOT behave like a random oracle, but it can be used as one if + * the string being hashed is prefix-free encoded before hashing. + * + * Usage: 1) call tc_sha256_init to initialize a struct + * tc_sha256_state_struct before hashing a new string. + * + * 2) call tc_sha256_update to hash the next string segment; + * tc_sha256_update can be called as many times as needed to hash + * all of the segments of a string; the order is important. + * + * 3) call tc_sha256_final to out put the digest from a hashing + * operation. + */ + +#ifndef __BLE_MESH_TC_SHA256_H__ +#define __BLE_MESH_TC_SHA256_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_SHA256_BLOCK_SIZE (64) +#define TC_SHA256_DIGEST_SIZE (32) +#define TC_SHA256_STATE_BLOCKS (TC_SHA256_DIGEST_SIZE/4) + +struct tc_sha256_state_struct { + unsigned int iv[TC_SHA256_STATE_BLOCKS]; + uint64_t bits_hashed; + uint8_t leftover[TC_SHA256_BLOCK_SIZE]; + size_t leftover_offset; +}; + +typedef struct tc_sha256_state_struct *TCSha256State_t; + +/** + * @brief SHA256 initialization procedure + * Initializes s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if s == NULL + * @param s Sha256 state struct + */ +int tc_sha256_init(TCSha256State_t s); + +/** + * @brief SHA256 update procedure + * Hashes data_length bytes addressed by data into state s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * data == NULL + * @note Assumes s has been initialized by tc_sha256_init + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param s Sha256 state struct + * @param data message to hash + * @param datalen length of message to hash + */ +int tc_sha256_update (TCSha256State_t s, const uint8_t *data, size_t datalen); + +/** + * @brief SHA256 final procedure + * Inserts the completed hash computation into digest + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * digest == NULL + * @note Assumes: s has been initialized by tc_sha256_init + * digest points to at least TC_SHA256_DIGEST_SIZE bytes + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param digest unsigned eight bit integer + * @param Sha256 state struct + */ +int tc_sha256_final(uint8_t *digest, TCSha256State_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_SHA256_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h new file mode 100644 index 000000000..422892390 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h @@ -0,0 +1,121 @@ +/* utils.h - TinyCrypt interface to platform-dependent run-time operations */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to platform-dependent run-time operations. + * + */ + +#ifndef __BLE_MESH_TC_UTILS_H__ +#define __BLE_MESH_TC_UTILS_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Copy the the buffer 'from' to the buffer 'to'. + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * from_len > to_len. + * + * @param to OUT -- destination buffer + * @param to_len IN -- length of destination buffer + * @param from IN -- origin buffer + * @param from_len IN -- length of origin buffer + */ +unsigned int _copy(uint8_t *to, unsigned int to_len, + const uint8_t *from, unsigned int from_len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +void _set(void *to, uint8_t val, unsigned int len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times, in a way + * which does not risk getting optimized out by the compiler + * In cases where the compiler does not set __GNUC__ and where the + * optimization level removes the memset, it may be necessary to + * implement a _set_secure function and define the + * TINYCRYPT_ARCH_HAS_SET_SECURE, which then can ensure that the + * memset does not get optimized out. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +#ifdef TINYCRYPT_ARCH_HAS_SET_SECURE +extern void _set_secure(void *to, uint8_t val, unsigned int len); +#else /* ! TINYCRYPT_ARCH_HAS_SET_SECURE */ +static inline void _set_secure(void *to, uint8_t val, unsigned int len) +{ + (void) memset(to, val, len); +#ifdef __GNUC__ + __asm__ __volatile__("" :: "g"(to) : "memory"); +#endif /* __GNUC__ */ +} +#endif /* TINYCRYPT_ARCH_HAS_SET_SECURE */ + +/* + * @brief AES specific doubling function, which utilizes + * the finite field used by AES. + * @return Returns a^2 + * + * @param a IN/OUT -- value to be doubled + */ +uint8_t _double_byte(uint8_t a); + +/* + * @brief Constant-time algorithm to compare if two sequences of bytes are equal + * @return Returns 0 if equal, and non-zero otherwise + * + * @param a IN -- sequence of bytes a + * @param b IN -- sequence of bytes b + * @param size IN -- size of sequences a and b + */ +int _compare(const uint8_t *a, const uint8_t *b, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UTILS_H__ */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c new file mode 100644 index 000000000..897264342 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c @@ -0,0 +1,164 @@ +/* aes_decrypt.c - TinyCrypt implementation of AES decryption procedure */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +static const uint8_t inv_sbox[256] = { + 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, + 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, + 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, + 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, + 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, + 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, + 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, + 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, + 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, + 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, + 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, + 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, + 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, + 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, + 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, + 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, + 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, + 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, + 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, + 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, + 0x55, 0x21, 0x0c, 0x7d +}; + +int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k) +{ + return tc_aes128_set_encrypt_key(s, k); +} + +#define mult8(a)(_double_byte(_double_byte(_double_byte(a)))) +#define mult9(a)(mult8(a)^(a)) +#define multb(a)(mult8(a)^_double_byte(a)^(a)) +#define multd(a)(mult8(a)^_double_byte(_double_byte(a))^(a)) +#define multe(a)(mult8(a)^_double_byte(_double_byte(a))^_double_byte(a)) + +static inline void mult_row_column(uint8_t *out, const uint8_t *in) +{ + out[0] = multe(in[0]) ^ multb(in[1]) ^ multd(in[2]) ^ mult9(in[3]); + out[1] = mult9(in[0]) ^ multe(in[1]) ^ multb(in[2]) ^ multd(in[3]); + out[2] = multd(in[0]) ^ mult9(in[1]) ^ multe(in[2]) ^ multb(in[3]); + out[3] = multb(in[0]) ^ multd(in[1]) ^ mult9(in[2]) ^ multe(in[3]); +} + +static inline void inv_mix_columns(uint8_t *s) +{ + uint8_t t[Nb * Nk]; + + mult_row_column(t, s); + mult_row_column(&t[Nb], s + Nb); + mult_row_column(&t[2 * Nb], s + (2 * Nb)); + mult_row_column(&t[3 * Nb], s + (3 * Nb)); + (void)_copy(s, sizeof(t), t, sizeof(t)); +} + +static inline void add_round_key(uint8_t *s, const unsigned int *k) +{ + s[0] ^= (uint8_t)(k[0] >> 24); s[1] ^= (uint8_t)(k[0] >> 16); + s[2] ^= (uint8_t)(k[0] >> 8); s[3] ^= (uint8_t)(k[0]); + s[4] ^= (uint8_t)(k[1] >> 24); s[5] ^= (uint8_t)(k[1] >> 16); + s[6] ^= (uint8_t)(k[1] >> 8); s[7] ^= (uint8_t)(k[1]); + s[8] ^= (uint8_t)(k[2] >> 24); s[9] ^= (uint8_t)(k[2] >> 16); + s[10] ^= (uint8_t)(k[2] >> 8); s[11] ^= (uint8_t)(k[2]); + s[12] ^= (uint8_t)(k[3] >> 24); s[13] ^= (uint8_t)(k[3] >> 16); + s[14] ^= (uint8_t)(k[3] >> 8); s[15] ^= (uint8_t)(k[3]); +} + +static inline void inv_sub_bytes(uint8_t *s) +{ + unsigned int i; + + for (i = 0; i < (Nb * Nk); ++i) { + s[i] = inv_sbox[s[i]]; + } +} + +/* + * This inv_shift_rows also implements the matrix flip required for + * inv_mix_columns, but performs it here to reduce the number of memory + * operations. + */ +static inline void inv_shift_rows(uint8_t *s) +{ + uint8_t t[Nb * Nk]; + + t[0] = s[0]; t[1] = s[13]; t[2] = s[10]; t[3] = s[7]; + t[4] = s[4]; t[5] = s[1]; t[6] = s[14]; t[7] = s[11]; + t[8] = s[8]; t[9] = s[5]; t[10] = s[2]; t[11] = s[15]; + t[12] = s[12]; t[13] = s[9]; t[14] = s[6]; t[15] = s[3]; + (void)_copy(s, sizeof(t), t, sizeof(t)); +} + +int tc_aes_decrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s) +{ + uint8_t state[Nk * Nb]; + unsigned int i; + + if (out == (uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } else if (in == (const uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } else if (s == (TCAesKeySched_t) 0) { + return TC_CRYPTO_FAIL; + } + + (void)_copy(state, sizeof(state), in, sizeof(state)); + + add_round_key(state, s->words + Nb * Nr); + + for (i = Nr - 1; i > 0; --i) { + inv_shift_rows(state); + inv_sub_bytes(state); + add_round_key(state, s->words + Nb * i); + inv_mix_columns(state); + } + + inv_shift_rows(state); + inv_sub_bytes(state); + add_round_key(state, s->words); + + (void)_copy(out, sizeof(state), state, sizeof(state)); + + /*zeroing out the state buffer */ + _set(state, TC_ZERO_BYTE, sizeof(state)); + + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c new file mode 100644 index 000000000..33c570795 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c @@ -0,0 +1,191 @@ +/* aes_encrypt.c - TinyCrypt implementation of AES encryption procedure */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +static const uint8_t sbox[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, + 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, + 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, + 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, + 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, + 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, + 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, + 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, + 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, + 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, + 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, + 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, + 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, + 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, + 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, + 0xb0, 0x54, 0xbb, 0x16 +}; + +static inline unsigned int rotword(unsigned int a) +{ + return (((a) >> 24) | ((a) << 8)); +} + +#define subbyte(a, o)(sbox[((a) >> (o))&0xff] << (o)) +#define subword(a)(subbyte(a, 24)|subbyte(a, 16)|subbyte(a, 8)|subbyte(a, 0)) + +int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k) +{ + const unsigned int rconst[11] = { + 0x00000000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, + 0x20000000, 0x40000000, 0x80000000, 0x1b000000, 0x36000000 + }; + unsigned int i; + unsigned int t; + + if (s == (TCAesKeySched_t) 0) { + return TC_CRYPTO_FAIL; + } else if (k == (const uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } + + for (i = 0; i < Nk; ++i) { + s->words[i] = (k[Nb * i] << 24) | (k[Nb * i + 1] << 16) | + (k[Nb * i + 2] << 8) | (k[Nb * i + 3]); + } + + for (; i < (Nb * (Nr + 1)); ++i) { + t = s->words[i - 1]; + if ((i % Nk) == 0) { + t = subword(rotword(t)) ^ rconst[i / Nk]; + } + s->words[i] = s->words[i - Nk] ^ t; + } + + return TC_CRYPTO_SUCCESS; +} + +static inline void add_round_key(uint8_t *s, const unsigned int *k) +{ + s[0] ^= (uint8_t)(k[0] >> 24); s[1] ^= (uint8_t)(k[0] >> 16); + s[2] ^= (uint8_t)(k[0] >> 8); s[3] ^= (uint8_t)(k[0]); + s[4] ^= (uint8_t)(k[1] >> 24); s[5] ^= (uint8_t)(k[1] >> 16); + s[6] ^= (uint8_t)(k[1] >> 8); s[7] ^= (uint8_t)(k[1]); + s[8] ^= (uint8_t)(k[2] >> 24); s[9] ^= (uint8_t)(k[2] >> 16); + s[10] ^= (uint8_t)(k[2] >> 8); s[11] ^= (uint8_t)(k[2]); + s[12] ^= (uint8_t)(k[3] >> 24); s[13] ^= (uint8_t)(k[3] >> 16); + s[14] ^= (uint8_t)(k[3] >> 8); s[15] ^= (uint8_t)(k[3]); +} + +static inline void sub_bytes(uint8_t *s) +{ + unsigned int i; + + for (i = 0; i < (Nb * Nk); ++i) { + s[i] = sbox[s[i]]; + } +} + +#define triple(a)(_double_byte(a)^(a)) + +static inline void mult_row_column(uint8_t *out, const uint8_t *in) +{ + out[0] = _double_byte(in[0]) ^ triple(in[1]) ^ in[2] ^ in[3]; + out[1] = in[0] ^ _double_byte(in[1]) ^ triple(in[2]) ^ in[3]; + out[2] = in[0] ^ in[1] ^ _double_byte(in[2]) ^ triple(in[3]); + out[3] = triple(in[0]) ^ in[1] ^ in[2] ^ _double_byte(in[3]); +} + +static inline void mix_columns(uint8_t *s) +{ + uint8_t t[Nb * Nk]; + + mult_row_column(t, s); + mult_row_column(&t[Nb], s + Nb); + mult_row_column(&t[2 * Nb], s + (2 * Nb)); + mult_row_column(&t[3 * Nb], s + (3 * Nb)); + (void) _copy(s, sizeof(t), t, sizeof(t)); +} + +/* + * This shift_rows also implements the matrix flip required for mix_columns, but + * performs it here to reduce the number of memory operations. + */ +static inline void shift_rows(uint8_t *s) +{ + uint8_t t[Nb * Nk]; + + t[0] = s[0]; t[1] = s[5]; t[2] = s[10]; t[3] = s[15]; + t[4] = s[4]; t[5] = s[9]; t[6] = s[14]; t[7] = s[3]; + t[8] = s[8]; t[9] = s[13]; t[10] = s[2]; t[11] = s[7]; + t[12] = s[12]; t[13] = s[1]; t[14] = s[6]; t[15] = s[11]; + (void) _copy(s, sizeof(t), t, sizeof(t)); +} + +int tc_aes_encrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s) +{ + uint8_t state[Nk * Nb]; + unsigned int i; + + if (out == (uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } else if (in == (const uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } else if (s == (TCAesKeySched_t) 0) { + return TC_CRYPTO_FAIL; + } + + (void)_copy(state, sizeof(state), in, sizeof(state)); + add_round_key(state, s->words); + + for (i = 0; i < (Nr - 1); ++i) { + sub_bytes(state); + shift_rows(state); + mix_columns(state); + add_round_key(state, s->words + Nb * (i + 1)); + } + + sub_bytes(state); + shift_rows(state); + add_round_key(state, s->words + Nb * (i + 1)); + + (void)_copy(out, sizeof(state), state, sizeof(state)); + + /* zeroing out the state buffer */ + _set(state, TC_ZERO_BYTE, sizeof(state)); + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c new file mode 100644 index 000000000..674f9c5de --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c @@ -0,0 +1,114 @@ +/* cbc_mode.c - TinyCrypt implementation of CBC mode encryption & decryption */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +int tc_cbc_mode_encrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched) +{ + + uint8_t buffer[TC_AES_BLOCK_SIZE]; + unsigned int n, m; + + /* input sanity check: */ + if (out == (uint8_t *) 0 || + in == (const uint8_t *) 0 || + sched == (TCAesKeySched_t) 0 || + inlen == 0 || + outlen == 0 || + (inlen % TC_AES_BLOCK_SIZE) != 0 || + (outlen % TC_AES_BLOCK_SIZE) != 0 || + outlen != inlen + TC_AES_BLOCK_SIZE) { + return TC_CRYPTO_FAIL; + } + + /* copy iv to the buffer */ + (void)_copy(buffer, TC_AES_BLOCK_SIZE, iv, TC_AES_BLOCK_SIZE); + /* copy iv to the output buffer */ + (void)_copy(out, TC_AES_BLOCK_SIZE, iv, TC_AES_BLOCK_SIZE); + out += TC_AES_BLOCK_SIZE; + + for (n = m = 0; n < inlen; ++n) { + buffer[m++] ^= *in++; + if (m == TC_AES_BLOCK_SIZE) { + (void)tc_aes_encrypt(buffer, buffer, sched); + (void)_copy(out, TC_AES_BLOCK_SIZE, + buffer, TC_AES_BLOCK_SIZE); + out += TC_AES_BLOCK_SIZE; + m = 0; + } + } + + return TC_CRYPTO_SUCCESS; +} + +int tc_cbc_mode_decrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched) +{ + + uint8_t buffer[TC_AES_BLOCK_SIZE]; + const uint8_t *p; + unsigned int n, m; + + /* sanity check the inputs */ + if (out == (uint8_t *) 0 || + in == (const uint8_t *) 0 || + sched == (TCAesKeySched_t) 0 || + inlen == 0 || + outlen == 0 || + (inlen % TC_AES_BLOCK_SIZE) != 0 || + (outlen % TC_AES_BLOCK_SIZE) != 0 || + outlen != inlen) { + return TC_CRYPTO_FAIL; + } + + /* + * Note that in == iv + ciphertext, i.e. the iv and the ciphertext are + * contiguous. This allows for a very efficient decryption algorithm + * that would not otherwise be possible. + */ + p = iv; + for (n = m = 0; n < outlen; ++n) { + if ((n % TC_AES_BLOCK_SIZE) == 0) { + (void)tc_aes_decrypt(buffer, in, sched); + in += TC_AES_BLOCK_SIZE; + m = 0; + } + *out++ = buffer[m++] ^ *p++; + } + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c new file mode 100644 index 000000000..37f75cfa2 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c @@ -0,0 +1,266 @@ +/* ccm_mode.c - TinyCrypt implementation of CCM mode */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include + +int tc_ccm_config(TCCcmMode_t c, TCAesKeySched_t sched, uint8_t *nonce, + unsigned int nlen, unsigned int mlen) +{ + + /* input sanity check: */ + if (c == (TCCcmMode_t) 0 || + sched == (TCAesKeySched_t) 0 || + nonce == (uint8_t *) 0) { + return TC_CRYPTO_FAIL; + } else if (nlen != 13) { + return TC_CRYPTO_FAIL; /* The allowed nonce size is: 13. See documentation.*/ + } else if ((mlen < 4) || (mlen > 16) || (mlen & 1)) { + return TC_CRYPTO_FAIL; /* The allowed mac sizes are: 4, 6, 8, 10, 12, 14, 16.*/ + } + + c->mlen = mlen; + c->sched = sched; + c->nonce = nonce; + + return TC_CRYPTO_SUCCESS; +} + +/** + * Variation of CBC-MAC mode used in CCM. + */ +static void ccm_cbc_mac(uint8_t *T, const uint8_t *data, unsigned int dlen, + unsigned int flag, TCAesKeySched_t sched) +{ + + unsigned int i; + + if (flag > 0) { + T[0] ^= (uint8_t)(dlen >> 8); + T[1] ^= (uint8_t)(dlen); + dlen += 2; i = 2; + } else { + i = 0; + } + + while (i < dlen) { + T[i++ % (Nb * Nk)] ^= *data++; + if (((i % (Nb * Nk)) == 0) || dlen == i) { + (void) tc_aes_encrypt(T, T, sched); + } + } +} + +/** + * Variation of CTR mode used in CCM. + * The CTR mode used by CCM is slightly different than the conventional CTR + * mode (the counter is increased before encryption, instead of after + * encryption). Besides, it is assumed that the counter is stored in the last + * 2 bytes of the nonce. + */ +static int ccm_ctr_mode(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched) +{ + + uint8_t buffer[TC_AES_BLOCK_SIZE]; + uint8_t nonce[TC_AES_BLOCK_SIZE]; + uint16_t block_num; + unsigned int i; + + /* input sanity check: */ + if (out == (uint8_t *) 0 || + in == (uint8_t *) 0 || + ctr == (uint8_t *) 0 || + sched == (TCAesKeySched_t) 0 || + inlen == 0 || + outlen == 0 || + outlen != inlen) { + return TC_CRYPTO_FAIL; + } + + /* copy the counter to the nonce */ + (void) _copy(nonce, sizeof(nonce), ctr, sizeof(nonce)); + + /* select the last 2 bytes of the nonce to be incremented */ + block_num = (uint16_t) ((nonce[14] << 8) | (nonce[15])); + for (i = 0; i < inlen; ++i) { + if ((i % (TC_AES_BLOCK_SIZE)) == 0) { + block_num++; + nonce[14] = (uint8_t)(block_num >> 8); + nonce[15] = (uint8_t)(block_num); + if (!tc_aes_encrypt(buffer, nonce, sched)) { + return TC_CRYPTO_FAIL; + } + } + /* update the output */ + *out++ = buffer[i % (TC_AES_BLOCK_SIZE)] ^ *in++; + } + + /* update the counter */ + ctr[14] = nonce[14]; ctr[15] = nonce[15]; + + return TC_CRYPTO_SUCCESS; +} + +int tc_ccm_generation_encryption(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, + unsigned int plen, TCCcmMode_t c) +{ + + /* input sanity check: */ + if ((out == (uint8_t *) 0) || + (c == (TCCcmMode_t) 0) || + ((plen > 0) && (payload == (uint8_t *) 0)) || + ((alen > 0) && (associated_data == (uint8_t *) 0)) || + (alen >= TC_CCM_AAD_MAX_BYTES) || /* associated data size unsupported */ + (plen >= TC_CCM_PAYLOAD_MAX_BYTES) || /* payload size unsupported */ + (olen < (plen + c->mlen))) { /* invalid output buffer size */ + return TC_CRYPTO_FAIL; + } + + uint8_t b[Nb * Nk]; + uint8_t tag[Nb * Nk]; + unsigned int i; + + /* GENERATING THE AUTHENTICATION TAG: */ + + /* formatting the sequence b for authentication: */ + b[0] = ((alen > 0) ? 0x40 : 0) | (((c->mlen - 2) / 2 << 3)) | (1); + for (i = 1; i <= 13; ++i) { + b[i] = c->nonce[i - 1]; + } + b[14] = (uint8_t)(plen >> 8); + b[15] = (uint8_t)(plen); + + /* computing the authentication tag using cbc-mac: */ + (void) tc_aes_encrypt(tag, b, c->sched); + if (alen > 0) { + ccm_cbc_mac(tag, associated_data, alen, 1, c->sched); + } + if (plen > 0) { + ccm_cbc_mac(tag, payload, plen, 0, c->sched); + } + + /* ENCRYPTION: */ + + /* formatting the sequence b for encryption: */ + b[0] = 1; /* q - 1 = 2 - 1 = 1 */ + b[14] = b[15] = TC_ZERO_BYTE; + + /* encrypting payload using ctr mode: */ + ccm_ctr_mode(out, plen, payload, plen, b, c->sched); + + b[14] = b[15] = TC_ZERO_BYTE; /* restoring initial counter for ctr_mode (0):*/ + + /* encrypting b and adding the tag to the output: */ + (void) tc_aes_encrypt(b, b, c->sched); + out += plen; + for (i = 0; i < c->mlen; ++i) { + *out++ = tag[i] ^ b[i]; + } + + return TC_CRYPTO_SUCCESS; +} + +int tc_ccm_decryption_verification(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, + unsigned int plen, TCCcmMode_t c) +{ + + /* input sanity check: */ + if ((out == (uint8_t *) 0) || + (c == (TCCcmMode_t) 0) || + ((plen > 0) && (payload == (uint8_t *) 0)) || + ((alen > 0) && (associated_data == (uint8_t *) 0)) || + (alen >= TC_CCM_AAD_MAX_BYTES) || /* associated data size unsupported */ + (plen >= TC_CCM_PAYLOAD_MAX_BYTES) || /* payload size unsupported */ + (olen < plen - c->mlen)) { /* invalid output buffer size */ + return TC_CRYPTO_FAIL; + } + + uint8_t b[Nb * Nk]; + uint8_t tag[Nb * Nk]; + unsigned int i; + + /* DECRYPTION: */ + + /* formatting the sequence b for decryption: */ + b[0] = 1; /* q - 1 = 2 - 1 = 1 */ + for (i = 1; i < 14; ++i) { + b[i] = c->nonce[i - 1]; + } + b[14] = b[15] = TC_ZERO_BYTE; /* initial counter value is 0 */ + + /* decrypting payload using ctr mode: */ + ccm_ctr_mode(out, plen - c->mlen, payload, plen - c->mlen, b, c->sched); + + b[14] = b[15] = TC_ZERO_BYTE; /* restoring initial counter value (0) */ + + /* encrypting b and restoring the tag from input: */ + (void) tc_aes_encrypt(b, b, c->sched); + for (i = 0; i < c->mlen; ++i) { + tag[i] = *(payload + plen - c->mlen + i) ^ b[i]; + } + + /* VERIFYING THE AUTHENTICATION TAG: */ + + /* formatting the sequence b for authentication: */ + b[0] = ((alen > 0) ? 0x40 : 0) | (((c->mlen - 2) / 2 << 3)) | (1); + for (i = 1; i < 14; ++i) { + b[i] = c->nonce[i - 1]; + } + b[14] = (uint8_t)((plen - c->mlen) >> 8); + b[15] = (uint8_t)(plen - c->mlen); + + /* computing the authentication tag using cbc-mac: */ + (void) tc_aes_encrypt(b, b, c->sched); + if (alen > 0) { + ccm_cbc_mac(b, associated_data, alen, 1, c->sched); + } + if (plen > 0) { + ccm_cbc_mac(b, out, plen - c->mlen, 0, c->sched); + } + + /* comparing the received tag and the computed one: */ + if (_compare(b, tag, c->mlen) == 0) { + return TC_CRYPTO_SUCCESS; + } else { + /* erase the decrypted buffer in case of mac validation failure: */ + _set(out, 0, plen - c->mlen); + return TC_CRYPTO_FAIL; + } +} diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c similarity index 58% rename from components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c rename to components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c index 544bbea72..a4e040428 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c @@ -1,4 +1,4 @@ -/* aes_encrypt.c - TinyCrypt implementation of AES encryption procedure */ +/* cmac_mode.c - TinyCrypt CMAC mode implementation */ /* * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "mesh_util.h" -#include "mesh_aes_encrypt.h" +#include +#include +#include +#include /* max number of calls until change the key (2^48).*/ -const static uint64_t MAX_CALLS = ((uint64_t)1 << 48); +static const uint64_t MAX_CALLS = ((uint64_t)1 << 48); /* * gf_wrap -- In our implementation, GF(2^128) is represented as a 16 byte @@ -64,160 +66,32 @@ const static uint64_t MAX_CALLS = ((uint64_t)1 << 48); */ const unsigned char gf_wrap = 0x87; -static const uint8_t sbox[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, - 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, - 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, - 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, - 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, - 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, - 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, - 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, - 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, - 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, - 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, - 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, - 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, - 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, - 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, - 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, - 0xb0, 0x54, 0xbb, 0x16 -}; - -static inline unsigned int rotword(unsigned int a) -{ - return (((a) >> 24) | ((a) << 8)); -} - -#define subbyte(a, o) (sbox[((a) >> (o))&0xff] << (o)) -#define subword(a) (subbyte(a, 24)|subbyte(a, 16)|subbyte(a, 8)|subbyte(a, 0)) - -int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k) -{ - const unsigned int rconst[11] = { - 0x00000000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, - 0x20000000, 0x40000000, 0x80000000, 0x1b000000, 0x36000000 - }; - unsigned int i; - unsigned int t; - - if (s == (TCAesKeySched_t) 0) { - return TC_CRYPTO_FAIL; - } else if (k == (const uint8_t *) 0) { - return TC_CRYPTO_FAIL; - } - - for (i = 0; i < Nk; ++i) { - s->words[i] = (k[Nb * i] << 24) | (k[Nb * i + 1] << 16) | - (k[Nb * i + 2] << 8) | (k[Nb * i + 3]); - } - - for (; i < (Nb * (Nr + 1)); ++i) { - t = s->words[i - 1]; - if ((i % Nk) == 0) { - t = subword(rotword(t)) ^ rconst[i / Nk]; - } - s->words[i] = s->words[i - Nk] ^ t; - } - - return TC_CRYPTO_SUCCESS; -} - -static inline void add_round_key(uint8_t *s, const unsigned int *k) -{ - s[0] ^= (uint8_t)(k[0] >> 24); s[1] ^= (uint8_t)(k[0] >> 16); - s[2] ^= (uint8_t)(k[0] >> 8); s[3] ^= (uint8_t)(k[0]); - s[4] ^= (uint8_t)(k[1] >> 24); s[5] ^= (uint8_t)(k[1] >> 16); - s[6] ^= (uint8_t)(k[1] >> 8); s[7] ^= (uint8_t)(k[1]); - s[8] ^= (uint8_t)(k[2] >> 24); s[9] ^= (uint8_t)(k[2] >> 16); - s[10] ^= (uint8_t)(k[2] >> 8); s[11] ^= (uint8_t)(k[2]); - s[12] ^= (uint8_t)(k[3] >> 24); s[13] ^= (uint8_t)(k[3] >> 16); - s[14] ^= (uint8_t)(k[3] >> 8); s[15] ^= (uint8_t)(k[3]); -} - -static inline void sub_bytes(uint8_t *s) -{ - unsigned int i; - - for (i = 0; i < (Nb * Nk); ++i) { - s[i] = sbox[s[i]]; - } -} - -#define triple(a)(_double_byte(a)^(a)) - -static inline void mult_row_column(uint8_t *out, const uint8_t *in) -{ - out[0] = _double_byte(in[0]) ^ triple(in[1]) ^ in[2] ^ in[3]; - out[1] = in[0] ^ _double_byte(in[1]) ^ triple(in[2]) ^ in[3]; - out[2] = in[0] ^ in[1] ^ _double_byte(in[2]) ^ triple(in[3]); - out[3] = triple(in[0]) ^ in[1] ^ in[2] ^ _double_byte(in[3]); -} - -static inline void mix_columns(uint8_t *s) -{ - uint8_t t[Nb * Nk] = {0}; - - mult_row_column(t, s); - mult_row_column(&t[Nb], s + Nb); - mult_row_column(&t[2 * Nb], s + (2 * Nb)); - mult_row_column(&t[3 * Nb], s + (3 * Nb)); - (void) _copy(s, sizeof(t), t, sizeof(t)); -} - /* - * This shift_rows also implements the matrix flip required for mix_columns, but - * performs it here to reduce the number of memory operations. + * assumes: out != NULL and points to a GF(2^n) value to receive the + * doubled value; + * in != NULL and points to a 16 byte GF(2^n) value + * to double; + * the in and out buffers do not overlap. + * effects: doubles the GF(2^n) value pointed to by "in" and places + * the result in the GF(2^n) value pointed to by "out." */ -static inline void shift_rows(uint8_t *s) +void gf_double(uint8_t *out, uint8_t *in) { - uint8_t t[Nb * Nk] = {0}; - t[0] = s[0]; t[1] = s[5]; t[2] = s[10]; t[3] = s[15]; - t[4] = s[4]; t[5] = s[9]; t[6] = s[14]; t[7] = s[3]; - t[8] = s[8]; t[9] = s[13]; t[10] = s[2]; t[11] = s[7]; - t[12] = s[12]; t[13] = s[1]; t[14] = s[6]; t[15] = s[11]; - (void) _copy(s, sizeof(t), t, sizeof(t)); -} + /* start with low order byte */ + uint8_t *x = in + (TC_AES_BLOCK_SIZE - 1); -int tc_aes_encrypt(uint8_t *out, const uint8_t *in, const TCAesKeySched_t s) -{ - uint8_t state[Nk * Nb] = {0}; - unsigned int i; + /* if msb == 1, we need to add the gf_wrap value, otherwise add 0 */ + uint8_t carry = (in[0] >> 7) ? gf_wrap : 0; - if (out == (uint8_t *) 0) { - return TC_CRYPTO_FAIL; - } else if (in == (const uint8_t *) 0) { - return TC_CRYPTO_FAIL; - } else if (s == (TCAesKeySched_t) 0) { - return TC_CRYPTO_FAIL; + out += (TC_AES_BLOCK_SIZE - 1); + for (;;) { + *out-- = (*x << 1) ^ carry; + if (x == in) { + break; + } + carry = *x-- >> 7; } - - (void)_copy(state, sizeof(state), in, sizeof(state)); - add_round_key(state, s->words); - - for (i = 0; i < (Nr - 1); ++i) { - sub_bytes(state); - shift_rows(state); - mix_columns(state); - add_round_key(state, s->words + Nb * (i + 1)); - } - - sub_bytes(state); - shift_rows(state); - add_round_key(state, s->words + Nb * (i + 1)); - - (void)_copy(out, sizeof(state), state, sizeof(state)); - - /* zeroing out the state buffer */ - _set(state, TC_ZERO_BYTE, sizeof(state)); - - return TC_CRYPTO_SUCCESS; } int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, TCAesKeySched_t sched) @@ -248,32 +122,16 @@ int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, TCAesKeySched_t sched) return TC_CRYPTO_SUCCESS; } -/* - * assumes: out != NULL and points to a GF(2^n) value to receive the - * doubled value; - * in != NULL and points to a 16 byte GF(2^n) value - * to double; - * the in and out buffers do not overlap. - * effects: doubles the GF(2^n) value pointed to by "in" and places - * the result in the GF(2^n) value pointed to by "out." - */ -void gf_double(uint8_t *out, uint8_t *in) +int tc_cmac_erase(TCCmacState_t s) { - - /* start with low order byte */ - uint8_t *x = in + (TC_AES_BLOCK_SIZE - 1); - - /* if msb == 1, we need to add the gf_wrap value, otherwise add 0 */ - uint8_t carry = (in[0] >> 7) ? gf_wrap : 0; - - out += (TC_AES_BLOCK_SIZE - 1); - for (;;) { - *out-- = (*x << 1) ^ carry; - if (x == in) { - break; - } - carry = *x-- >> 7; + if (s == (TCCmacState_t) 0) { + return TC_CRYPTO_FAIL; } + + /* destroy the current state */ + _set(s, 0, sizeof(*s)); + + return TC_CRYPTO_SUCCESS; } int tc_cmac_init(TCCmacState_t s) @@ -363,7 +221,7 @@ int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t data_length) int tc_cmac_final(uint8_t *tag, TCCmacState_t s) { - uint8_t *k = NULL; + uint8_t *k; unsigned int i; /* input sanity check: */ @@ -394,15 +252,3 @@ int tc_cmac_final(uint8_t *tag, TCCmacState_t s) return TC_CRYPTO_SUCCESS; } - -int tc_cmac_erase(TCCmacState_t s) -{ - if (s == (TCCmacState_t) 0) { - return TC_CRYPTO_FAIL; - } - - /* destroy the current state */ - _set(s, 0, sizeof(*s)); - - return TC_CRYPTO_SUCCESS; -} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c new file mode 100644 index 000000000..1cb12bc8c --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c @@ -0,0 +1,85 @@ +/* ctr_mode.c - TinyCrypt CTR mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +int tc_ctr_mode(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched) +{ + + uint8_t buffer[TC_AES_BLOCK_SIZE]; + uint8_t nonce[TC_AES_BLOCK_SIZE]; + unsigned int block_num; + unsigned int i; + + /* input sanity check: */ + if (out == (uint8_t *) 0 || + in == (uint8_t *) 0 || + ctr == (uint8_t *) 0 || + sched == (TCAesKeySched_t) 0 || + inlen == 0 || + outlen == 0 || + outlen != inlen) { + return TC_CRYPTO_FAIL; + } + + /* copy the ctr to the nonce */ + (void)_copy(nonce, sizeof(nonce), ctr, sizeof(nonce)); + + /* select the last 4 bytes of the nonce to be incremented */ + block_num = (nonce[12] << 24) | (nonce[13] << 16) | + (nonce[14] << 8) | (nonce[15]); + for (i = 0; i < inlen; ++i) { + if ((i % (TC_AES_BLOCK_SIZE)) == 0) { + /* encrypt data using the current nonce */ + if (tc_aes_encrypt(buffer, nonce, sched)) { + block_num++; + nonce[12] = (uint8_t)(block_num >> 24); + nonce[13] = (uint8_t)(block_num >> 16); + nonce[14] = (uint8_t)(block_num >> 8); + nonce[15] = (uint8_t)(block_num); + } else { + return TC_CRYPTO_FAIL; + } + } + /* update the output */ + *out++ = buffer[i % (TC_AES_BLOCK_SIZE)] ^ *in++; + } + + /* update the counter */ + ctr[12] = nonce[12]; ctr[13] = nonce[13]; + ctr[14] = nonce[14]; ctr[15] = nonce[15]; + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c new file mode 100644 index 000000000..f273ee555 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c @@ -0,0 +1,279 @@ +/* ctr_prng.c - TinyCrypt implementation of CTR-PRNG */ + +/* + * Copyright (c) 2016, Chris Morrison + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +/* + * This PRNG is based on the CTR_DRBG described in Recommendation for Random + * Number Generation Using Deterministic Random Bit Generators, + * NIST SP 800-90A Rev. 1. + * + * Annotations to particular steps (e.g. 10.2.1.2 Step 1) refer to the steps + * described in that document. + * + */ + +/** + * @brief Array incrementer + * Treats the supplied array as one contiguous number (MSB in arr[0]), and + * increments it by one + * @return none + * @param arr IN/OUT -- array to be incremented + * @param len IN -- size of arr in bytes + */ +static void arrInc(uint8_t arr[], unsigned int len) +{ + unsigned int i; + if (0 != arr) { + for (i = len; i > 0U; i--) { + if (++arr[i - 1] != 0U) { + break; + } + } + } +} + +/** + * @brief CTR PRNG update + * Updates the internal state of supplied the CTR PRNG context + * increments it by one + * @return none + * @note Assumes: providedData is (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) bytes long + * @param ctx IN/OUT -- CTR PRNG state + * @param providedData IN -- data used when updating the internal state + */ +static void tc_ctr_prng_update(TCCtrPrng_t *const ctx, uint8_t const *const providedData) +{ + if (0 != ctx) { + /* 10.2.1.2 step 1 */ + uint8_t temp[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE]; + unsigned int len = 0U; + + /* 10.2.1.2 step 2 */ + while (len < sizeof temp) { + unsigned int blocklen = sizeof(temp) - len; + uint8_t output_block[TC_AES_BLOCK_SIZE]; + + /* 10.2.1.2 step 2.1 */ + arrInc(ctx->V, sizeof ctx->V); + + /* 10.2.1.2 step 2.2 */ + if (blocklen > TC_AES_BLOCK_SIZE) { + blocklen = TC_AES_BLOCK_SIZE; + } + (void)tc_aes_encrypt(output_block, ctx->V, &ctx->key); + + /* 10.2.1.2 step 2.3/step 3 */ + memcpy(&(temp[len]), output_block, blocklen); + + len += blocklen; + } + + /* 10.2.1.2 step 4 */ + if (0 != providedData) { + unsigned int i; + for (i = 0U; i < sizeof temp; i++) { + temp[i] ^= providedData[i]; + } + } + + /* 10.2.1.2 step 5 */ + (void)tc_aes128_set_encrypt_key(&ctx->key, temp); + + /* 10.2.1.2 step 6 */ + memcpy(ctx->V, &(temp[TC_AES_KEY_SIZE]), TC_AES_BLOCK_SIZE); + } +} + +int tc_ctr_prng_init(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const personalization, + unsigned int pLen) +{ + int result = TC_CRYPTO_FAIL; + unsigned int i; + uint8_t personalization_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U}; + uint8_t seed_material[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE]; + uint8_t zeroArr[TC_AES_BLOCK_SIZE] = {0U}; + + if (0 != personalization) { + /* 10.2.1.3.1 step 1 */ + unsigned int len = pLen; + if (len > sizeof personalization_buf) { + len = sizeof personalization_buf; + } + + /* 10.2.1.3.1 step 2 */ + memcpy(personalization_buf, personalization, len); + } + + if ((0 != ctx) && (0 != entropy) && (entropyLen >= sizeof seed_material)) { + /* 10.2.1.3.1 step 3 */ + memcpy(seed_material, entropy, sizeof seed_material); + for (i = 0U; i < sizeof seed_material; i++) { + seed_material[i] ^= personalization_buf[i]; + } + + /* 10.2.1.3.1 step 4 */ + (void)tc_aes128_set_encrypt_key(&ctx->key, zeroArr); + + /* 10.2.1.3.1 step 5 */ + memset(ctx->V, 0x00, sizeof ctx->V); + + /* 10.2.1.3.1 step 6 */ + tc_ctr_prng_update(ctx, seed_material); + + /* 10.2.1.3.1 step 7 */ + ctx->reseedCount = 1U; + + result = TC_CRYPTO_SUCCESS; + } + return result; +} + +int tc_ctr_prng_reseed(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const additional_input, + unsigned int additionallen) +{ + unsigned int i; + int result = TC_CRYPTO_FAIL; + uint8_t additional_input_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U}; + uint8_t seed_material[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE]; + + if (0 != additional_input) { + /* 10.2.1.4.1 step 1 */ + unsigned int len = additionallen; + if (len > sizeof additional_input_buf) { + len = sizeof additional_input_buf; + } + + /* 10.2.1.4.1 step 2 */ + memcpy(additional_input_buf, additional_input, len); + } + + unsigned int seedlen = (unsigned int)TC_AES_KEY_SIZE + (unsigned int)TC_AES_BLOCK_SIZE; + if ((0 != ctx) && (entropyLen >= seedlen)) { + /* 10.2.1.4.1 step 3 */ + memcpy(seed_material, entropy, sizeof seed_material); + for (i = 0U; i < sizeof seed_material; i++) { + seed_material[i] ^= additional_input_buf[i]; + } + + /* 10.2.1.4.1 step 4 */ + tc_ctr_prng_update(ctx, seed_material); + + /* 10.2.1.4.1 step 5 */ + ctx->reseedCount = 1U; + + result = TC_CRYPTO_SUCCESS; + } + return result; +} + +int tc_ctr_prng_generate(TCCtrPrng_t *const ctx, + uint8_t const *const additional_input, + unsigned int additionallen, + uint8_t *const out, + unsigned int outlen) +{ + /* 2^48 - see section 10.2.1 */ + static const uint64_t MAX_REQS_BEFORE_RESEED = 0x1000000000000ULL; + + /* 2^19 bits - see section 10.2.1 */ + static const unsigned int MAX_BYTES_PER_REQ = 65536U; + + unsigned int result = TC_CRYPTO_FAIL; + + if ((0 != ctx) && (0 != out) && (outlen < MAX_BYTES_PER_REQ)) { + /* 10.2.1.5.1 step 1 */ + if (ctx->reseedCount > MAX_REQS_BEFORE_RESEED) { + result = TC_CTR_PRNG_RESEED_REQ; + } else { + uint8_t additional_input_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U}; + if (0 != additional_input) { + /* 10.2.1.5.1 step 2 */ + unsigned int len = additionallen; + if (len > sizeof additional_input_buf) { + len = sizeof additional_input_buf; + } + memcpy(additional_input_buf, additional_input, len); + tc_ctr_prng_update(ctx, additional_input_buf); + } + + /* 10.2.1.5.1 step 3 - implicit */ + + /* 10.2.1.5.1 step 4 */ + unsigned int len = 0U; + while (len < outlen) { + unsigned int blocklen = outlen - len; + uint8_t output_block[TC_AES_BLOCK_SIZE]; + + /* 10.2.1.5.1 step 4.1 */ + arrInc(ctx->V, sizeof ctx->V); + + /* 10.2.1.5.1 step 4.2 */ + (void)tc_aes_encrypt(output_block, ctx->V, &ctx->key); + + /* 10.2.1.5.1 step 4.3/step 5 */ + if (blocklen > TC_AES_BLOCK_SIZE) { + blocklen = TC_AES_BLOCK_SIZE; + } + memcpy(&(out[len]), output_block, blocklen); + + len += blocklen; + } + + /* 10.2.1.5.1 step 6 */ + tc_ctr_prng_update(ctx, additional_input_buf); + + /* 10.2.1.5.1 step 7 */ + ctx->reseedCount++; + + /* 10.2.1.5.1 step 8 */ + result = TC_CRYPTO_SUCCESS; + } + } + + return result; +} + +void tc_ctr_prng_uninstantiate(TCCtrPrng_t *const ctx) +{ + if (0 != ctx) { + memset(ctx->key.words, 0x00, sizeof ctx->key.words); + memset(ctx->V, 0x00, sizeof ctx->V); + ctx->reseedCount = 0U; + } +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c new file mode 100644 index 000000000..5606b67a9 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c @@ -0,0 +1,939 @@ +/* ecc.c - TinyCrypt implementation of common ECC functions */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +/* IMPORTANT: Make sure a cryptographically-secure PRNG is set and the platform + * has access to enough entropy in order to feed the PRNG regularly. */ +#if default_RNG_defined +static uECC_RNG_Function g_rng_function = &default_CSPRNG; +#else +static uECC_RNG_Function g_rng_function = 0; +#endif + +void uECC_set_rng(uECC_RNG_Function rng_function) +{ + g_rng_function = rng_function; +} + +uECC_RNG_Function uECC_get_rng(void) +{ + return g_rng_function; +} + +int uECC_curve_private_key_size(uECC_Curve curve) +{ + return BITS_TO_BYTES(curve->num_n_bits); +} + +int uECC_curve_public_key_size(uECC_Curve curve) +{ + return 2 * curve->num_bytes; +} + +void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words) +{ + wordcount_t i; + for (i = 0; i < num_words; ++i) { + vli[i] = 0; + } +} + +uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words) +{ + uECC_word_t bits = 0; + wordcount_t i; + for (i = 0; i < num_words; ++i) { + bits |= vli[i]; + } + return (bits == 0); +} + +uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit) +{ + return (vli[bit >> uECC_WORD_BITS_SHIFT] & + ((uECC_word_t)1 << (bit & uECC_WORD_BITS_MASK))); +} + +/* Counts the number of words in vli. */ +static wordcount_t vli_numDigits(const uECC_word_t *vli, + const wordcount_t max_words) +{ + + wordcount_t i; + /* Search from the end until we find a non-zero digit. We do it in reverse + * because we expect that most digits will be nonzero. */ + for (i = max_words - 1; i >= 0 && vli[i] == 0; --i) { + } + + return (i + 1); +} + +bitcount_t uECC_vli_numBits(const uECC_word_t *vli, + const wordcount_t max_words) +{ + + uECC_word_t i; + uECC_word_t digit; + + wordcount_t num_digits = vli_numDigits(vli, max_words); + if (num_digits == 0) { + return 0; + } + + digit = vli[num_digits - 1]; + for (i = 0; digit; ++i) { + digit >>= 1; + } + + return (((bitcount_t)(num_digits - 1) << uECC_WORD_BITS_SHIFT) + i); +} + +void uECC_vli_set(uECC_word_t *dest, const uECC_word_t *src, + wordcount_t num_words) +{ + wordcount_t i; + + for (i = 0; i < num_words; ++i) { + dest[i] = src[i]; + } +} + +cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left, + const uECC_word_t *right, + wordcount_t num_words) +{ + wordcount_t i; + + for (i = num_words - 1; i >= 0; --i) { + if (left[i] > right[i]) { + return 1; + } else if (left[i] < right[i]) { + return -1; + } + } + return 0; +} + +uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words) +{ + + uECC_word_t diff = 0; + wordcount_t i; + + for (i = num_words - 1; i >= 0; --i) { + diff |= (left[i] ^ right[i]); + } + return !(diff == 0); +} + +uECC_word_t cond_set(uECC_word_t p_true, uECC_word_t p_false, unsigned int cond) +{ + return (p_true * (cond)) | (p_false * (!cond)); +} + +/* Computes result = left - right, returning borrow, in constant time. + * Can modify in place. */ +uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words) +{ + uECC_word_t borrow = 0; + wordcount_t i; + for (i = 0; i < num_words; ++i) { + uECC_word_t diff = left[i] - right[i] - borrow; + uECC_word_t val = (diff > left[i]); + borrow = cond_set(val, borrow, (diff != left[i])); + + result[i] = diff; + } + return borrow; +} + +/* Computes result = left + right, returning carry, in constant time. + * Can modify in place. */ +static uECC_word_t uECC_vli_add(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words) +{ + uECC_word_t carry = 0; + wordcount_t i; + for (i = 0; i < num_words; ++i) { + uECC_word_t sum = left[i] + right[i] + carry; + uECC_word_t val = (sum < left[i]); + carry = cond_set(val, carry, (sum != left[i])); + result[i] = sum; + } + return carry; +} + +cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words) +{ + uECC_word_t tmp[NUM_ECC_WORDS]; + uECC_word_t neg = !!uECC_vli_sub(tmp, left, right, num_words); + uECC_word_t equal = uECC_vli_isZero(tmp, num_words); + return (!equal - 2 * neg); +} + +/* Computes vli = vli >> 1. */ +static void uECC_vli_rshift1(uECC_word_t *vli, wordcount_t num_words) +{ + uECC_word_t *end = vli; + uECC_word_t carry = 0; + + vli += num_words; + while (vli-- > end) { + uECC_word_t temp = *vli; + *vli = (temp >> 1) | carry; + carry = temp << (uECC_WORD_BITS - 1); + } +} + +static void muladd(uECC_word_t a, uECC_word_t b, uECC_word_t *r0, + uECC_word_t *r1, uECC_word_t *r2) +{ + + uECC_dword_t p = (uECC_dword_t)a * b; + uECC_dword_t r01 = ((uECC_dword_t)(*r1) << uECC_WORD_BITS) | *r0; + r01 += p; + *r2 += (r01 < p); + *r1 = r01 >> uECC_WORD_BITS; + *r0 = (uECC_word_t)r01; + +} + +/* Computes result = left * right. Result must be 2 * num_words long. */ +static void uECC_vli_mult(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words) +{ + + uECC_word_t r0 = 0; + uECC_word_t r1 = 0; + uECC_word_t r2 = 0; + wordcount_t i, k; + + /* Compute each digit of result in sequence, maintaining the carries. */ + for (k = 0; k < num_words; ++k) { + + for (i = 0; i <= k; ++i) { + muladd(left[i], right[k - i], &r0, &r1, &r2); + } + + result[k] = r0; + r0 = r1; + r1 = r2; + r2 = 0; + } + + for (k = num_words; k < num_words * 2 - 1; ++k) { + + for (i = (k + 1) - num_words; i < num_words; ++i) { + muladd(left[i], right[k - i], &r0, &r1, &r2); + } + result[k] = r0; + r0 = r1; + r1 = r2; + r2 = 0; + } + result[num_words * 2 - 1] = r0; +} + +void uECC_vli_modAdd(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words) +{ + uECC_word_t carry = uECC_vli_add(result, left, right, num_words); + if (carry || uECC_vli_cmp_unsafe(mod, result, num_words) != 1) { + /* result > mod (result = mod + remainder), so subtract mod to get + * remainder. */ + uECC_vli_sub(result, result, mod, num_words); + } +} + +void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words) +{ + uECC_word_t l_borrow = uECC_vli_sub(result, left, right, num_words); + if (l_borrow) { + /* In this case, result == -diff == (max int) - diff. Since -x % d == d - x, + * we can get the correct result from result + mod (with overflow). */ + uECC_vli_add(result, result, mod, num_words); + } +} + +/* Computes result = product % mod, where product is 2N words long. */ +/* Currently only designed to work for curve_p or curve_n. */ +void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product, + const uECC_word_t *mod, wordcount_t num_words) +{ + uECC_word_t mod_multiple[2 * NUM_ECC_WORDS]; + uECC_word_t tmp[2 * NUM_ECC_WORDS]; + uECC_word_t *v[2] = {tmp, product}; + uECC_word_t index; + + /* Shift mod so its highest set bit is at the maximum position. */ + bitcount_t shift = (num_words * 2 * uECC_WORD_BITS) - + uECC_vli_numBits(mod, num_words); + wordcount_t word_shift = shift / uECC_WORD_BITS; + wordcount_t bit_shift = shift % uECC_WORD_BITS; + uECC_word_t carry = 0; + uECC_vli_clear(mod_multiple, word_shift); + if (bit_shift > 0) { + for (index = 0; index < (uECC_word_t)num_words; ++index) { + mod_multiple[word_shift + index] = (mod[index] << bit_shift) | carry; + carry = mod[index] >> (uECC_WORD_BITS - bit_shift); + } + } else { + uECC_vli_set(mod_multiple + word_shift, mod, num_words); + } + + for (index = 1; shift >= 0; --shift) { + uECC_word_t borrow = 0; + wordcount_t i; + for (i = 0; i < num_words * 2; ++i) { + uECC_word_t diff = v[index][i] - mod_multiple[i] - borrow; + if (diff != v[index][i]) { + borrow = (diff > v[index][i]); + } + v[1 - index][i] = diff; + } + /* Swap the index if there was no borrow */ + index = !(index ^ borrow); + uECC_vli_rshift1(mod_multiple, num_words); + mod_multiple[num_words - 1] |= mod_multiple[num_words] << + (uECC_WORD_BITS - 1); + uECC_vli_rshift1(mod_multiple + num_words, num_words); + } + uECC_vli_set(result, v[index], num_words); +} + +void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words) +{ + uECC_word_t product[2 * NUM_ECC_WORDS]; + uECC_vli_mult(product, left, right, num_words); + uECC_vli_mmod(result, product, mod, num_words); +} + +void uECC_vli_modMult_fast(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, uECC_Curve curve) +{ + uECC_word_t product[2 * NUM_ECC_WORDS]; + uECC_vli_mult(product, left, right, curve->num_words); + + curve->mmod_fast(result, product); +} + +static void uECC_vli_modSquare_fast(uECC_word_t *result, + const uECC_word_t *left, + uECC_Curve curve) +{ + uECC_vli_modMult_fast(result, left, left, curve); +} + + +#define EVEN(vli) (!(vli[0] & 1)) + +static void vli_modInv_update(uECC_word_t *uv, + const uECC_word_t *mod, + wordcount_t num_words) +{ + + uECC_word_t carry = 0; + + if (!EVEN(uv)) { + carry = uECC_vli_add(uv, uv, mod, num_words); + } + uECC_vli_rshift1(uv, num_words); + if (carry) { + uv[num_words - 1] |= HIGH_BIT_SET; + } +} + +void uECC_vli_modInv(uECC_word_t *result, const uECC_word_t *input, + const uECC_word_t *mod, wordcount_t num_words) +{ + uECC_word_t a[NUM_ECC_WORDS], b[NUM_ECC_WORDS]; + uECC_word_t u[NUM_ECC_WORDS], v[NUM_ECC_WORDS]; + cmpresult_t cmpResult; + + if (uECC_vli_isZero(input, num_words)) { + uECC_vli_clear(result, num_words); + return; + } + + uECC_vli_set(a, input, num_words); + uECC_vli_set(b, mod, num_words); + uECC_vli_clear(u, num_words); + u[0] = 1; + uECC_vli_clear(v, num_words); + while ((cmpResult = uECC_vli_cmp_unsafe(a, b, num_words)) != 0) { + if (EVEN(a)) { + uECC_vli_rshift1(a, num_words); + vli_modInv_update(u, mod, num_words); + } else if (EVEN(b)) { + uECC_vli_rshift1(b, num_words); + vli_modInv_update(v, mod, num_words); + } else if (cmpResult > 0) { + uECC_vli_sub(a, a, b, num_words); + uECC_vli_rshift1(a, num_words); + if (uECC_vli_cmp_unsafe(u, v, num_words) < 0) { + uECC_vli_add(u, u, mod, num_words); + } + uECC_vli_sub(u, u, v, num_words); + vli_modInv_update(u, mod, num_words); + } else { + uECC_vli_sub(b, b, a, num_words); + uECC_vli_rshift1(b, num_words); + if (uECC_vli_cmp_unsafe(v, u, num_words) < 0) { + uECC_vli_add(v, v, mod, num_words); + } + uECC_vli_sub(v, v, u, num_words); + vli_modInv_update(v, mod, num_words); + } + } + uECC_vli_set(result, u, num_words); +} + +/* ------ Point operations ------ */ + +void double_jacobian_default(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *Z1, uECC_Curve curve) +{ + /* t1 = X, t2 = Y, t3 = Z */ + uECC_word_t t4[NUM_ECC_WORDS]; + uECC_word_t t5[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + + if (uECC_vli_isZero(Z1, num_words)) { + return; + } + + uECC_vli_modSquare_fast(t4, Y1, curve); /* t4 = y1^2 */ + uECC_vli_modMult_fast(t5, X1, t4, curve); /* t5 = x1*y1^2 = A */ + uECC_vli_modSquare_fast(t4, t4, curve); /* t4 = y1^4 */ + uECC_vli_modMult_fast(Y1, Y1, Z1, curve); /* t2 = y1*z1 = z3 */ + uECC_vli_modSquare_fast(Z1, Z1, curve); /* t3 = z1^2 */ + + uECC_vli_modAdd(X1, X1, Z1, curve->p, num_words); /* t1 = x1 + z1^2 */ + uECC_vli_modAdd(Z1, Z1, Z1, curve->p, num_words); /* t3 = 2*z1^2 */ + uECC_vli_modSub(Z1, X1, Z1, curve->p, num_words); /* t3 = x1 - z1^2 */ + uECC_vli_modMult_fast(X1, X1, Z1, curve); /* t1 = x1^2 - z1^4 */ + + uECC_vli_modAdd(Z1, X1, X1, curve->p, num_words); /* t3 = 2*(x1^2 - z1^4) */ + uECC_vli_modAdd(X1, X1, Z1, curve->p, num_words); /* t1 = 3*(x1^2 - z1^4) */ + if (uECC_vli_testBit(X1, 0)) { + uECC_word_t l_carry = uECC_vli_add(X1, X1, curve->p, num_words); + uECC_vli_rshift1(X1, num_words); + X1[num_words - 1] |= l_carry << (uECC_WORD_BITS - 1); + } else { + uECC_vli_rshift1(X1, num_words); + } + + /* t1 = 3/2*(x1^2 - z1^4) = B */ + uECC_vli_modSquare_fast(Z1, X1, curve); /* t3 = B^2 */ + uECC_vli_modSub(Z1, Z1, t5, curve->p, num_words); /* t3 = B^2 - A */ + uECC_vli_modSub(Z1, Z1, t5, curve->p, num_words); /* t3 = B^2 - 2A = x3 */ + uECC_vli_modSub(t5, t5, Z1, curve->p, num_words); /* t5 = A - x3 */ + uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = B * (A - x3) */ + /* t4 = B * (A - x3) - y1^4 = y3: */ + uECC_vli_modSub(t4, X1, t4, curve->p, num_words); + + uECC_vli_set(X1, Z1, num_words); + uECC_vli_set(Z1, Y1, num_words); + uECC_vli_set(Y1, t4, num_words); +} + +void x_side_default(uECC_word_t *result, + const uECC_word_t *x, + uECC_Curve curve) +{ + uECC_word_t _3[NUM_ECC_WORDS] = {3}; /* -a = 3 */ + wordcount_t num_words = curve->num_words; + + uECC_vli_modSquare_fast(result, x, curve); /* r = x^2 */ + uECC_vli_modSub(result, result, _3, curve->p, num_words); /* r = x^2 - 3 */ + uECC_vli_modMult_fast(result, result, x, curve); /* r = x^3 - 3x */ + /* r = x^3 - 3x + b: */ + uECC_vli_modAdd(result, result, curve->b, curve->p, num_words); +} + +uECC_Curve uECC_secp256r1(void) +{ + return &curve_secp256r1; +} + +void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product) +{ + unsigned int tmp[NUM_ECC_WORDS]; + int carry; + + /* t */ + uECC_vli_set(result, product, NUM_ECC_WORDS); + + /* s1 */ + tmp[0] = tmp[1] = tmp[2] = 0; + tmp[3] = product[11]; + tmp[4] = product[12]; + tmp[5] = product[13]; + tmp[6] = product[14]; + tmp[7] = product[15]; + carry = uECC_vli_add(tmp, tmp, tmp, NUM_ECC_WORDS); + carry += uECC_vli_add(result, result, tmp, NUM_ECC_WORDS); + + /* s2 */ + tmp[3] = product[12]; + tmp[4] = product[13]; + tmp[5] = product[14]; + tmp[6] = product[15]; + tmp[7] = 0; + carry += uECC_vli_add(tmp, tmp, tmp, NUM_ECC_WORDS); + carry += uECC_vli_add(result, result, tmp, NUM_ECC_WORDS); + + /* s3 */ + tmp[0] = product[8]; + tmp[1] = product[9]; + tmp[2] = product[10]; + tmp[3] = tmp[4] = tmp[5] = 0; + tmp[6] = product[14]; + tmp[7] = product[15]; + carry += uECC_vli_add(result, result, tmp, NUM_ECC_WORDS); + + /* s4 */ + tmp[0] = product[9]; + tmp[1] = product[10]; + tmp[2] = product[11]; + tmp[3] = product[13]; + tmp[4] = product[14]; + tmp[5] = product[15]; + tmp[6] = product[13]; + tmp[7] = product[8]; + carry += uECC_vli_add(result, result, tmp, NUM_ECC_WORDS); + + /* d1 */ + tmp[0] = product[11]; + tmp[1] = product[12]; + tmp[2] = product[13]; + tmp[3] = tmp[4] = tmp[5] = 0; + tmp[6] = product[8]; + tmp[7] = product[10]; + carry -= uECC_vli_sub(result, result, tmp, NUM_ECC_WORDS); + + /* d2 */ + tmp[0] = product[12]; + tmp[1] = product[13]; + tmp[2] = product[14]; + tmp[3] = product[15]; + tmp[4] = tmp[5] = 0; + tmp[6] = product[9]; + tmp[7] = product[11]; + carry -= uECC_vli_sub(result, result, tmp, NUM_ECC_WORDS); + + /* d3 */ + tmp[0] = product[13]; + tmp[1] = product[14]; + tmp[2] = product[15]; + tmp[3] = product[8]; + tmp[4] = product[9]; + tmp[5] = product[10]; + tmp[6] = 0; + tmp[7] = product[12]; + carry -= uECC_vli_sub(result, result, tmp, NUM_ECC_WORDS); + + /* d4 */ + tmp[0] = product[14]; + tmp[1] = product[15]; + tmp[2] = 0; + tmp[3] = product[9]; + tmp[4] = product[10]; + tmp[5] = product[11]; + tmp[6] = 0; + tmp[7] = product[13]; + carry -= uECC_vli_sub(result, result, tmp, NUM_ECC_WORDS); + + if (carry < 0) { + do { + carry += uECC_vli_add(result, result, curve_secp256r1.p, NUM_ECC_WORDS); + } while (carry < 0); + } else { + while (carry || + uECC_vli_cmp_unsafe(curve_secp256r1.p, result, NUM_ECC_WORDS) != 1) { + carry -= uECC_vli_sub(result, result, curve_secp256r1.p, NUM_ECC_WORDS); + } + } +} + +uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve) +{ + return uECC_vli_isZero(point, curve->num_words * 2); +} + +void apply_z(uECC_word_t *X1, uECC_word_t *Y1, const uECC_word_t *const Z, + uECC_Curve curve) +{ + uECC_word_t t1[NUM_ECC_WORDS]; + + uECC_vli_modSquare_fast(t1, Z, curve); /* z^2 */ + uECC_vli_modMult_fast(X1, X1, t1, curve); /* x1 * z^2 */ + uECC_vli_modMult_fast(t1, t1, Z, curve); /* z^3 */ + uECC_vli_modMult_fast(Y1, Y1, t1, curve); /* y1 * z^3 */ +} + +/* P = (x1, y1) => 2P, (x2, y2) => P' */ +static void XYcZ_initial_double(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *X2, uECC_word_t *Y2, + const uECC_word_t *const initial_Z, + uECC_Curve curve) +{ + uECC_word_t z[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + if (initial_Z) { + uECC_vli_set(z, initial_Z, num_words); + } else { + uECC_vli_clear(z, num_words); + z[0] = 1; + } + + uECC_vli_set(X2, X1, num_words); + uECC_vli_set(Y2, Y1, num_words); + + apply_z(X1, Y1, z, curve); + curve->double_jacobian(X1, Y1, z, curve); + apply_z(X2, Y2, z, curve); +} + +void XYcZ_add(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *X2, uECC_word_t *Y2, + uECC_Curve curve) +{ + /* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */ + uECC_word_t t5[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + + uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */ + uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */ + uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */ + uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */ + uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */ + uECC_vli_modSquare_fast(t5, Y2, curve); /* t5 = (y2 - y1)^2 = D */ + + uECC_vli_modSub(t5, t5, X1, curve->p, num_words); /* t5 = D - B */ + uECC_vli_modSub(t5, t5, X2, curve->p, num_words); /* t5 = D - B - C = x3 */ + uECC_vli_modSub(X2, X2, X1, curve->p, num_words); /* t3 = C - B */ + uECC_vli_modMult_fast(Y1, Y1, X2, curve); /* t2 = y1*(C - B) */ + uECC_vli_modSub(X2, X1, t5, curve->p, num_words); /* t3 = B - x3 */ + uECC_vli_modMult_fast(Y2, Y2, X2, curve); /* t4 = (y2 - y1)*(B - x3) */ + uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y3 */ + + uECC_vli_set(X2, t5, num_words); +} + +/* Input P = (x1, y1, Z), Q = (x2, y2, Z) + Output P + Q = (x3, y3, Z3), P - Q = (x3', y3', Z3) + or P => P - Q, Q => P + Q + */ +static void XYcZ_addC(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *X2, uECC_word_t *Y2, + uECC_Curve curve) +{ + /* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */ + uECC_word_t t5[NUM_ECC_WORDS]; + uECC_word_t t6[NUM_ECC_WORDS]; + uECC_word_t t7[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + + uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */ + uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */ + uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */ + uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */ + uECC_vli_modAdd(t5, Y2, Y1, curve->p, num_words); /* t5 = y2 + y1 */ + uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */ + + uECC_vli_modSub(t6, X2, X1, curve->p, num_words); /* t6 = C - B */ + uECC_vli_modMult_fast(Y1, Y1, t6, curve); /* t2 = y1 * (C - B) = E */ + uECC_vli_modAdd(t6, X1, X2, curve->p, num_words); /* t6 = B + C */ + uECC_vli_modSquare_fast(X2, Y2, curve); /* t3 = (y2 - y1)^2 = D */ + uECC_vli_modSub(X2, X2, t6, curve->p, num_words); /* t3 = D - (B + C) = x3 */ + + uECC_vli_modSub(t7, X1, X2, curve->p, num_words); /* t7 = B - x3 */ + uECC_vli_modMult_fast(Y2, Y2, t7, curve); /* t4 = (y2 - y1)*(B - x3) */ + /* t4 = (y2 - y1)*(B - x3) - E = y3: */ + uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); + + uECC_vli_modSquare_fast(t7, t5, curve); /* t7 = (y2 + y1)^2 = F */ + uECC_vli_modSub(t7, t7, t6, curve->p, num_words); /* t7 = F - (B + C) = x3' */ + uECC_vli_modSub(t6, t7, X1, curve->p, num_words); /* t6 = x3' - B */ + uECC_vli_modMult_fast(t6, t6, t5, curve); /* t6 = (y2+y1)*(x3' - B) */ + /* t2 = (y2+y1)*(x3' - B) - E = y3': */ + uECC_vli_modSub(Y1, t6, Y1, curve->p, num_words); + + uECC_vli_set(X1, t7, num_words); +} + +void EccPoint_mult(uECC_word_t *result, const uECC_word_t *point, + const uECC_word_t *scalar, + const uECC_word_t *initial_Z, + bitcount_t num_bits, uECC_Curve curve) +{ + /* R0 and R1 */ + uECC_word_t Rx[2][NUM_ECC_WORDS]; + uECC_word_t Ry[2][NUM_ECC_WORDS]; + uECC_word_t z[NUM_ECC_WORDS]; + bitcount_t i; + uECC_word_t nb; + wordcount_t num_words = curve->num_words; + + uECC_vli_set(Rx[1], point, num_words); + uECC_vli_set(Ry[1], point + num_words, num_words); + + XYcZ_initial_double(Rx[1], Ry[1], Rx[0], Ry[0], initial_Z, curve); + + for (i = num_bits - 2; i > 0; --i) { + nb = !uECC_vli_testBit(scalar, i); + XYcZ_addC(Rx[1 - nb], Ry[1 - nb], Rx[nb], Ry[nb], curve); + XYcZ_add(Rx[nb], Ry[nb], Rx[1 - nb], Ry[1 - nb], curve); + } + + nb = !uECC_vli_testBit(scalar, 0); + XYcZ_addC(Rx[1 - nb], Ry[1 - nb], Rx[nb], Ry[nb], curve); + + /* Find final 1/Z value. */ + uECC_vli_modSub(z, Rx[1], Rx[0], curve->p, num_words); /* X1 - X0 */ + uECC_vli_modMult_fast(z, z, Ry[1 - nb], curve); /* Yb * (X1 - X0) */ + uECC_vli_modMult_fast(z, z, point, curve); /* xP * Yb * (X1 - X0) */ + uECC_vli_modInv(z, z, curve->p, num_words); /* 1 / (xP * Yb * (X1 - X0))*/ + /* yP / (xP * Yb * (X1 - X0)) */ + uECC_vli_modMult_fast(z, z, point + num_words, curve); + /* Xb * yP / (xP * Yb * (X1 - X0)) */ + uECC_vli_modMult_fast(z, z, Rx[1 - nb], curve); + /* End 1/Z calculation */ + + XYcZ_add(Rx[nb], Ry[nb], Rx[1 - nb], Ry[1 - nb], curve); + apply_z(Rx[0], Ry[0], z, curve); + + uECC_vli_set(result, Rx[0], num_words); + uECC_vli_set(result + num_words, Ry[0], num_words); +} + +uECC_word_t regularize_k(const uECC_word_t *const k, uECC_word_t *k0, + uECC_word_t *k1, uECC_Curve curve) +{ + + wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits); + + bitcount_t num_n_bits = curve->num_n_bits; + + uECC_word_t carry = uECC_vli_add(k0, k, curve->n, num_n_words) || + (num_n_bits < ((bitcount_t)num_n_words * uECC_WORD_SIZE * 8) && + uECC_vli_testBit(k0, num_n_bits)); + + uECC_vli_add(k1, k0, curve->n, num_n_words); + + return carry; +} + +uECC_word_t EccPoint_compute_public_key(uECC_word_t *result, + uECC_word_t *private_key, + uECC_Curve curve) +{ + + uECC_word_t tmp1[NUM_ECC_WORDS]; + uECC_word_t tmp2[NUM_ECC_WORDS]; + uECC_word_t *p2[2] = {tmp1, tmp2}; + uECC_word_t carry; + + /* Regularize the bitcount for the private key so that attackers cannot + * use a side channel attack to learn the number of leading zeros. */ + carry = regularize_k(private_key, tmp1, tmp2, curve); + + EccPoint_mult(result, curve->G, p2[!carry], 0, curve->num_n_bits + 1, curve); + + if (EccPoint_isZero(result, curve)) { + return 0; + } + return 1; +} + +/* Converts an integer in uECC native format to big-endian bytes. */ +void uECC_vli_nativeToBytes(uint8_t *bytes, int num_bytes, + const unsigned int *native) +{ + wordcount_t i; + for (i = 0; i < num_bytes; ++i) { + unsigned b = num_bytes - 1 - i; + bytes[i] = native[b / uECC_WORD_SIZE] >> (8 * (b % uECC_WORD_SIZE)); + } +} + +/* Converts big-endian bytes to an integer in uECC native format. */ +void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes, + int num_bytes) +{ + wordcount_t i; + uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) / uECC_WORD_SIZE); + for (i = 0; i < num_bytes; ++i) { + unsigned b = num_bytes - 1 - i; + native[b / uECC_WORD_SIZE] |= + (uECC_word_t)bytes[i] << (8 * (b % uECC_WORD_SIZE)); + } +} + +int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top, + wordcount_t num_words) +{ + uECC_word_t mask = (uECC_word_t) - 1; + uECC_word_t tries; + bitcount_t num_bits = uECC_vli_numBits(top, num_words); + + if (!g_rng_function) { + return 0; + } + + for (tries = 0; tries < uECC_RNG_MAX_TRIES; ++tries) { + if (!g_rng_function((uint8_t *)random, num_words * uECC_WORD_SIZE)) { + return 0; + } + random[num_words - 1] &= + mask >> ((bitcount_t)(num_words * uECC_WORD_SIZE * 8 - num_bits)); + if (!uECC_vli_isZero(random, num_words) && + uECC_vli_cmp(top, random, num_words) == 1) { + return 1; + } + } + return 0; +} + + +int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve) +{ + uECC_word_t tmp1[NUM_ECC_WORDS]; + uECC_word_t tmp2[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + + /* The point at infinity is invalid. */ + if (EccPoint_isZero(point, curve)) { + return -1; + } + + /* x and y must be smaller than p. */ + if (uECC_vli_cmp_unsafe(curve->p, point, num_words) != 1 || + uECC_vli_cmp_unsafe(curve->p, point + num_words, num_words) != 1) { + return -2; + } + + uECC_vli_modSquare_fast(tmp1, point + num_words, curve); + curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */ + + /* Make sure that y^2 == x^3 + ax + b */ + if (uECC_vli_equal(tmp1, tmp2, num_words) != 0) { + return -3; + } + + return 0; +} + +int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve) +{ + + uECC_word_t _public[NUM_ECC_WORDS * 2]; + + uECC_vli_bytesToNative(_public, public_key, curve->num_bytes); + uECC_vli_bytesToNative( + _public + curve->num_words, + public_key + curve->num_bytes, + curve->num_bytes); + + if (uECC_vli_cmp_unsafe(_public, curve->G, NUM_ECC_WORDS * 2) == 0) { + return -4; + } + + return uECC_valid_point(_public, curve); +} + +int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, + uECC_Curve curve) +{ + + uECC_word_t _private[NUM_ECC_WORDS]; + uECC_word_t _public[NUM_ECC_WORDS * 2]; + + uECC_vli_bytesToNative( + _private, + private_key, + BITS_TO_BYTES(curve->num_n_bits)); + + /* Make sure the private key is in the range [1, n-1]. */ + if (uECC_vli_isZero(_private, BITS_TO_WORDS(curve->num_n_bits))) { + return 0; + } + + if (uECC_vli_cmp(curve->n, _private, BITS_TO_WORDS(curve->num_n_bits)) != 1) { + return 0; + } + + /* Compute public key. */ + if (!EccPoint_compute_public_key(_public, _private, curve)) { + return 0; + } + + uECC_vli_nativeToBytes(public_key, curve->num_bytes, _public); + uECC_vli_nativeToBytes( + public_key + + curve->num_bytes, curve->num_bytes, _public + curve->num_words); + return 1; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c new file mode 100644 index 000000000..f8cd70c4c --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c @@ -0,0 +1,198 @@ +/* ec_dh.c - TinyCrypt implementation of EC-DH */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include + +#if default_RNG_defined +static uECC_RNG_Function g_rng_function = &default_CSPRNG; +#else +static uECC_RNG_Function g_rng_function = 0; +#endif + +int uECC_make_key_with_d(uint8_t *public_key, uint8_t *private_key, + unsigned int *d, uECC_Curve curve) +{ + + uECC_word_t _private[NUM_ECC_WORDS]; + uECC_word_t _public[NUM_ECC_WORDS * 2]; + + /* This function is designed for test purposes-only (such as validating NIST + * test vectors) as it uses a provided value for d instead of generating + * it uniformly at random. */ + memcpy (_private, d, NUM_ECC_BYTES); + + /* Computing public-key from private: */ + if (EccPoint_compute_public_key(_public, _private, curve)) { + + /* Converting buffers to correct bit order: */ + uECC_vli_nativeToBytes(private_key, + BITS_TO_BYTES(curve->num_n_bits), + _private); + uECC_vli_nativeToBytes(public_key, + curve->num_bytes, + _public); + uECC_vli_nativeToBytes(public_key + curve->num_bytes, + curve->num_bytes, + _public + curve->num_words); + + /* erasing temporary buffer used to store secret: */ + _set_secure(_private, 0, NUM_ECC_BYTES); + + return 1; + } + return 0; +} + +int uECC_make_key(uint8_t *public_key, uint8_t *private_key, uECC_Curve curve) +{ + + uECC_word_t _random[NUM_ECC_WORDS * 2]; + uECC_word_t _private[NUM_ECC_WORDS]; + uECC_word_t _public[NUM_ECC_WORDS * 2]; + uECC_word_t tries; + + for (tries = 0; tries < uECC_RNG_MAX_TRIES; ++tries) { + /* Generating _private uniformly at random: */ + uECC_RNG_Function rng_function = uECC_get_rng(); + if (!rng_function || + !rng_function((uint8_t *)_random, 2 * NUM_ECC_WORDS * uECC_WORD_SIZE)) { + return 0; + } + + /* computing modular reduction of _random (see FIPS 186.4 B.4.1): */ + uECC_vli_mmod(_private, _random, curve->n, BITS_TO_WORDS(curve->num_n_bits)); + + /* Computing public-key from private: */ + if (EccPoint_compute_public_key(_public, _private, curve)) { + + /* Converting buffers to correct bit order: */ + uECC_vli_nativeToBytes(private_key, + BITS_TO_BYTES(curve->num_n_bits), + _private); + uECC_vli_nativeToBytes(public_key, + curve->num_bytes, + _public); + uECC_vli_nativeToBytes(public_key + curve->num_bytes, + curve->num_bytes, + _public + curve->num_words); + + /* erasing temporary buffer that stored secret: */ + _set_secure(_private, 0, NUM_ECC_BYTES); + + return 1; + } + } + return 0; +} + +int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key, + uint8_t *secret, uECC_Curve curve) +{ + + uECC_word_t _public[NUM_ECC_WORDS * 2]; + uECC_word_t _private[NUM_ECC_WORDS]; + + uECC_word_t tmp[NUM_ECC_WORDS]; + uECC_word_t *p2[2] = {_private, tmp}; + uECC_word_t *initial_Z = 0; + uECC_word_t carry; + wordcount_t num_words = curve->num_words; + wordcount_t num_bytes = curve->num_bytes; + int r; + + /* Converting buffers to correct bit order: */ + uECC_vli_bytesToNative(_private, + private_key, + BITS_TO_BYTES(curve->num_n_bits)); + uECC_vli_bytesToNative(_public, + public_key, + num_bytes); + uECC_vli_bytesToNative(_public + num_words, + public_key + num_bytes, + num_bytes); + + /* Regularize the bitcount for the private key so that attackers cannot use a + * side channel attack to learn the number of leading zeros. */ + carry = regularize_k(_private, _private, tmp, curve); + + /* If an RNG function was specified, try to get a random initial Z value to + * improve protection against side-channel attacks. */ + if (g_rng_function) { + if (!uECC_generate_random_int(p2[carry], curve->p, num_words)) { + r = 0; + goto clear_and_out; + } + initial_Z = p2[carry]; + } + + EccPoint_mult(_public, _public, p2[!carry], initial_Z, curve->num_n_bits + 1, + curve); + + uECC_vli_nativeToBytes(secret, num_bytes, _public); + r = !EccPoint_isZero(_public, curve); + +clear_and_out: + /* erasing temporary buffer used to store secret: */ + _set_secure(p2, 0, sizeof(p2)); + _set_secure(tmp, 0, sizeof(tmp)); + _set_secure(_private, 0, sizeof(_private)); + + return r; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c new file mode 100644 index 000000000..3b4d17909 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c @@ -0,0 +1,293 @@ +/* ec_dsa.c - TinyCrypt implementation of EC-DSA */ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE.*/ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#if default_RNG_defined +static uECC_RNG_Function g_rng_function = &default_CSPRNG; +#else +static uECC_RNG_Function g_rng_function = 0; +#endif + +static void bits2int(uECC_word_t *native, const uint8_t *bits, + unsigned bits_size, uECC_Curve curve) +{ + unsigned num_n_bytes = BITS_TO_BYTES(curve->num_n_bits); + unsigned num_n_words = BITS_TO_WORDS(curve->num_n_bits); + int shift; + uECC_word_t carry; + uECC_word_t *ptr; + + if (bits_size > num_n_bytes) { + bits_size = num_n_bytes; + } + + uECC_vli_clear(native, num_n_words); + uECC_vli_bytesToNative(native, bits, bits_size); + if (bits_size * 8 <= (unsigned)curve->num_n_bits) { + return; + } + shift = bits_size * 8 - curve->num_n_bits; + carry = 0; + ptr = native + num_n_words; + while (ptr-- > native) { + uECC_word_t temp = *ptr; + *ptr = (temp >> shift) | carry; + carry = temp << (uECC_WORD_BITS - shift); + } + + /* Reduce mod curve_n */ + if (uECC_vli_cmp_unsafe(curve->n, native, num_n_words) != 1) { + uECC_vli_sub(native, native, curve->n, num_n_words); + } +} + +int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash, + unsigned hash_size, uECC_word_t *k, uint8_t *signature, + uECC_Curve curve) +{ + + uECC_word_t tmp[NUM_ECC_WORDS]; + uECC_word_t s[NUM_ECC_WORDS]; + uECC_word_t *k2[2] = {tmp, s}; + uECC_word_t p[NUM_ECC_WORDS * 2]; + uECC_word_t carry; + wordcount_t num_words = curve->num_words; + wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits); + bitcount_t num_n_bits = curve->num_n_bits; + + /* Make sure 0 < k < curve_n */ + if (uECC_vli_isZero(k, num_words) || + uECC_vli_cmp(curve->n, k, num_n_words) != 1) { + return 0; + } + + carry = regularize_k(k, tmp, s, curve); + EccPoint_mult(p, curve->G, k2[!carry], 0, num_n_bits + 1, curve); + if (uECC_vli_isZero(p, num_words)) { + return 0; + } + + /* If an RNG function was specified, get a random number + to prevent side channel analysis of k. */ + if (!g_rng_function) { + uECC_vli_clear(tmp, num_n_words); + tmp[0] = 1; + } else if (!uECC_generate_random_int(tmp, curve->n, num_n_words)) { + return 0; + } + + /* Prevent side channel analysis of uECC_vli_modInv() to determine + bits of k / the private key by premultiplying by a random number */ + uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); /* k' = rand * k */ + uECC_vli_modInv(k, k, curve->n, num_n_words); /* k = 1 / k' */ + uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); /* k = 1 / k */ + + uECC_vli_nativeToBytes(signature, curve->num_bytes, p); /* store r */ + + /* tmp = d: */ + uECC_vli_bytesToNative(tmp, private_key, BITS_TO_BYTES(curve->num_n_bits)); + + s[num_n_words - 1] = 0; + uECC_vli_set(s, p, num_words); + uECC_vli_modMult(s, tmp, s, curve->n, num_n_words); /* s = r*d */ + + bits2int(tmp, message_hash, hash_size, curve); + uECC_vli_modAdd(s, tmp, s, curve->n, num_n_words); /* s = e + r*d */ + uECC_vli_modMult(s, s, k, curve->n, num_n_words); /* s = (e + r*d) / k */ + if (uECC_vli_numBits(s, num_n_words) > (bitcount_t)curve->num_bytes * 8) { + return 0; + } + + uECC_vli_nativeToBytes(signature + curve->num_bytes, curve->num_bytes, s); + return 1; +} + +int uECC_sign(const uint8_t *private_key, const uint8_t *message_hash, + unsigned hash_size, uint8_t *signature, uECC_Curve curve) +{ + uECC_word_t _random[2 * NUM_ECC_WORDS]; + uECC_word_t k[NUM_ECC_WORDS]; + uECC_word_t tries; + + for (tries = 0; tries < uECC_RNG_MAX_TRIES; ++tries) { + /* Generating _random uniformly at random: */ + uECC_RNG_Function rng_function = uECC_get_rng(); + if (!rng_function || + !rng_function((uint8_t *)_random, 2 * NUM_ECC_WORDS * uECC_WORD_SIZE)) { + return 0; + } + + // computing k as modular reduction of _random (see FIPS 186.4 B.5.1): + uECC_vli_mmod(k, _random, curve->n, BITS_TO_WORDS(curve->num_n_bits)); + + if (uECC_sign_with_k(private_key, message_hash, hash_size, k, signature, + curve)) { + return 1; + } + } + return 0; +} + +static bitcount_t smax(bitcount_t a, bitcount_t b) +{ + return (a > b ? a : b); +} + +int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash, + unsigned hash_size, const uint8_t *signature, + uECC_Curve curve) +{ + + uECC_word_t u1[NUM_ECC_WORDS], u2[NUM_ECC_WORDS]; + uECC_word_t z[NUM_ECC_WORDS]; + uECC_word_t sum[NUM_ECC_WORDS * 2]; + uECC_word_t rx[NUM_ECC_WORDS]; + uECC_word_t ry[NUM_ECC_WORDS]; + uECC_word_t tx[NUM_ECC_WORDS]; + uECC_word_t ty[NUM_ECC_WORDS]; + uECC_word_t tz[NUM_ECC_WORDS]; + const uECC_word_t *points[4]; + const uECC_word_t *point; + bitcount_t num_bits; + bitcount_t i; + + uECC_word_t _public[NUM_ECC_WORDS * 2]; + uECC_word_t r[NUM_ECC_WORDS], s[NUM_ECC_WORDS]; + wordcount_t num_words = curve->num_words; + wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits); + + rx[num_n_words - 1] = 0; + r[num_n_words - 1] = 0; + s[num_n_words - 1] = 0; + + uECC_vli_bytesToNative(_public, public_key, curve->num_bytes); + uECC_vli_bytesToNative(_public + num_words, public_key + curve->num_bytes, + curve->num_bytes); + uECC_vli_bytesToNative(r, signature, curve->num_bytes); + uECC_vli_bytesToNative(s, signature + curve->num_bytes, curve->num_bytes); + + /* r, s must not be 0. */ + if (uECC_vli_isZero(r, num_words) || uECC_vli_isZero(s, num_words)) { + return 0; + } + + /* r, s must be < n. */ + if (uECC_vli_cmp_unsafe(curve->n, r, num_n_words) != 1 || + uECC_vli_cmp_unsafe(curve->n, s, num_n_words) != 1) { + return 0; + } + + /* Calculate u1 and u2. */ + uECC_vli_modInv(z, s, curve->n, num_n_words); /* z = 1/s */ + u1[num_n_words - 1] = 0; + bits2int(u1, message_hash, hash_size, curve); + uECC_vli_modMult(u1, u1, z, curve->n, num_n_words); /* u1 = e/s */ + uECC_vli_modMult(u2, r, z, curve->n, num_n_words); /* u2 = r/s */ + + /* Calculate sum = G + Q. */ + uECC_vli_set(sum, _public, num_words); + uECC_vli_set(sum + num_words, _public + num_words, num_words); + uECC_vli_set(tx, curve->G, num_words); + uECC_vli_set(ty, curve->G + num_words, num_words); + uECC_vli_modSub(z, sum, tx, curve->p, num_words); /* z = x2 - x1 */ + XYcZ_add(tx, ty, sum, sum + num_words, curve); + uECC_vli_modInv(z, z, curve->p, num_words); /* z = 1/z */ + apply_z(sum, sum + num_words, z, curve); + + /* Use Shamir's trick to calculate u1*G + u2*Q */ + points[0] = 0; + points[1] = curve->G; + points[2] = _public; + points[3] = sum; + num_bits = smax(uECC_vli_numBits(u1, num_n_words), + uECC_vli_numBits(u2, num_n_words)); + + point = points[(!!uECC_vli_testBit(u1, num_bits - 1)) | + ((!!uECC_vli_testBit(u2, num_bits - 1)) << 1)]; + uECC_vli_set(rx, point, num_words); + uECC_vli_set(ry, point + num_words, num_words); + uECC_vli_clear(z, num_words); + z[0] = 1; + + for (i = num_bits - 2; i >= 0; --i) { + uECC_word_t index; + curve->double_jacobian(rx, ry, z, curve); + + index = (!!uECC_vli_testBit(u1, i)) | ((!!uECC_vli_testBit(u2, i)) << 1); + point = points[index]; + if (point) { + uECC_vli_set(tx, point, num_words); + uECC_vli_set(ty, point + num_words, num_words); + apply_z(tx, ty, z, curve); + uECC_vli_modSub(tz, rx, tx, curve->p, num_words); /* Z = x2 - x1 */ + XYcZ_add(tx, ty, rx, ry, curve); + uECC_vli_modMult_fast(z, z, tz, curve); + } + } + + uECC_vli_modInv(z, z, curve->p, num_words); /* Z = 1/Z */ + apply_z(rx, ry, z, curve); + + /* v = x1 (mod n) */ + if (uECC_vli_cmp_unsafe(curve->n, rx, num_n_words) != 1) { + uECC_vli_sub(rx, rx, curve->n, num_n_words); + } + + /* Accept only if v == r. */ + return (int)(uECC_vli_equal(rx, r, num_words) == 0); +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c new file mode 100644 index 000000000..a15fe56d3 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c @@ -0,0 +1,106 @@ +/* uECC_platform_specific.c - Implementation of platform specific functions*/ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE.*/ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * uECC_platform_specific.c -- Implementation of platform specific functions + */ + + +#if defined(unix) || defined(__linux__) || defined(__unix__) || \ + defined(__unix) | (defined(__APPLE__) && defined(__MACH__)) || \ + defined(uECC_POSIX) + +/* Some POSIX-like system with /dev/urandom or /dev/random. */ +#include +#include +#include + +#include + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +int default_CSPRNG(uint8_t *dest, unsigned int size) +{ + + /* input sanity check: */ + if (dest == (uint8_t *) 0 || (size <= 0)) { + return 0; + } + + int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); + if (fd == -1) { + fd = open("/dev/random", O_RDONLY | O_CLOEXEC); + if (fd == -1) { + return 0; + } + } + + char *ptr = (char *)dest; + size_t left = (size_t) size; + while (left > 0) { + ssize_t bytes_read = read(fd, ptr, left); + if (bytes_read <= 0) { // read failed + close(fd); + return 0; + } + left -= bytes_read; + ptr += bytes_read; + } + + close(fd); + return 1; +} + +#endif /* platform */ diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c new file mode 100644 index 000000000..83da669f7 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c @@ -0,0 +1,147 @@ +/* hmac.c - TinyCrypt implementation of the HMAC algorithm */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +static void rekey(uint8_t *key, const uint8_t *new_key, unsigned int key_size) +{ + const uint8_t inner_pad = (uint8_t) 0x36; + const uint8_t outer_pad = (uint8_t) 0x5c; + unsigned int i; + + for (i = 0; i < key_size; ++i) { + key[i] = inner_pad ^ new_key[i]; + key[i + TC_SHA256_BLOCK_SIZE] = outer_pad ^ new_key[i]; + } + for (; i < TC_SHA256_BLOCK_SIZE; ++i) { + key[i] = inner_pad; key[i + TC_SHA256_BLOCK_SIZE] = outer_pad; + } +} + +int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, + unsigned int key_size) +{ + /* Input sanity check */ + if (ctx == (TCHmacState_t) 0 || + key == (const uint8_t *) 0 || + key_size == 0) { + return TC_CRYPTO_FAIL; + } + + const uint8_t dummy_key[TC_SHA256_BLOCK_SIZE]; + struct tc_hmac_state_struct dummy_state; + + if (key_size <= TC_SHA256_BLOCK_SIZE) { + /* + * The next three calls are dummy calls just to avoid + * certain timing attacks. Without these dummy calls, + * adversaries would be able to learn whether the key_size is + * greater than TC_SHA256_BLOCK_SIZE by measuring the time + * consumed in this process. + */ + (void)tc_sha256_init(&dummy_state.hash_state); + (void)tc_sha256_update(&dummy_state.hash_state, + dummy_key, + key_size); + (void)tc_sha256_final(&dummy_state.key[TC_SHA256_DIGEST_SIZE], + &dummy_state.hash_state); + + /* Actual code for when key_size <= TC_SHA256_BLOCK_SIZE: */ + rekey(ctx->key, key, key_size); + } else { + (void)tc_sha256_init(&ctx->hash_state); + (void)tc_sha256_update(&ctx->hash_state, key, key_size); + (void)tc_sha256_final(&ctx->key[TC_SHA256_DIGEST_SIZE], + &ctx->hash_state); + rekey(ctx->key, + &ctx->key[TC_SHA256_DIGEST_SIZE], + TC_SHA256_DIGEST_SIZE); + } + + return TC_CRYPTO_SUCCESS; +} + +int tc_hmac_init(TCHmacState_t ctx) +{ + + /* input sanity check: */ + if (ctx == (TCHmacState_t) 0) { + return TC_CRYPTO_FAIL; + } + + (void) tc_sha256_init(&ctx->hash_state); + (void) tc_sha256_update(&ctx->hash_state, ctx->key, TC_SHA256_BLOCK_SIZE); + + return TC_CRYPTO_SUCCESS; +} + +int tc_hmac_update(TCHmacState_t ctx, + const void *data, + unsigned int data_length) +{ + + /* input sanity check: */ + if (ctx == (TCHmacState_t) 0) { + return TC_CRYPTO_FAIL; + } + + (void)tc_sha256_update(&ctx->hash_state, data, data_length); + + return TC_CRYPTO_SUCCESS; +} + +int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx) +{ + + /* input sanity check: */ + if (tag == (uint8_t *) 0 || + taglen != TC_SHA256_DIGEST_SIZE || + ctx == (TCHmacState_t) 0) { + return TC_CRYPTO_FAIL; + } + + (void) tc_sha256_final(tag, &ctx->hash_state); + + (void)tc_sha256_init(&ctx->hash_state); + (void)tc_sha256_update(&ctx->hash_state, + &ctx->key[TC_SHA256_BLOCK_SIZE], + TC_SHA256_BLOCK_SIZE); + (void)tc_sha256_update(&ctx->hash_state, tag, TC_SHA256_DIGEST_SIZE); + (void)tc_sha256_final(tag, &ctx->hash_state); + + /* destroy the current state */ + _set(ctx, 0, sizeof(*ctx)); + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c new file mode 100644 index 000000000..6b2a6bfe2 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c @@ -0,0 +1,234 @@ +/* hmac_prng.c - TinyCrypt implementation of HMAC-PRNG */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +/* + * min bytes in the seed string. + * MIN_SLEN*8 must be at least the expected security level. + */ +static const unsigned int MIN_SLEN = 32; + +/* + * max bytes in the seed string; + * SP800-90A specifies a maximum of 2^35 bits (i.e., 2^32 bytes). + */ +static const unsigned int MAX_SLEN = UINT32_MAX; + +/* + * max bytes in the personalization string; + * SP800-90A specifies a maximum of 2^35 bits (i.e., 2^32 bytes). + */ +static const unsigned int MAX_PLEN = UINT32_MAX; + +/* + * max bytes in the additional_info string; + * SP800-90A specifies a maximum of 2^35 bits (i.e., 2^32 bytes). + */ +static const unsigned int MAX_ALEN = UINT32_MAX; + +/* + * max number of generates between re-seeds; + * TinyCrypt accepts up to (2^32 - 1) which is the maximal value of + * a 32-bit unsigned int variable, while SP800-90A specifies a maximum of 2^48. + */ +static const unsigned int MAX_GENS = UINT32_MAX; + +/* + * maximum bytes per generate call; + * SP800-90A specifies a maximum up to 2^19. + */ +static const unsigned int MAX_OUT = (1 << 19); + +/* + * Assumes: prng != NULL + */ +static void update(TCHmacPrng_t prng, const uint8_t *data, unsigned int datalen, const uint8_t *additional_data, unsigned int additional_datalen) +{ + const uint8_t separator0 = 0x00; + const uint8_t separator1 = 0x01; + + /* configure the new prng key into the prng's instance of hmac */ + tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key)); + + /* use current state, e and separator 0 to compute a new prng key: */ + (void)tc_hmac_init(&prng->h); + (void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v)); + (void)tc_hmac_update(&prng->h, &separator0, sizeof(separator0)); + + if (data && datalen) { + (void)tc_hmac_update(&prng->h, data, datalen); + } + if (additional_data && additional_datalen) { + (void)tc_hmac_update(&prng->h, additional_data, additional_datalen); + } + + (void)tc_hmac_final(prng->key, sizeof(prng->key), &prng->h); + + /* configure the new prng key into the prng's instance of hmac */ + (void)tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key)); + + /* use the new key to compute a new state variable v */ + (void)tc_hmac_init(&prng->h); + (void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v)); + (void)tc_hmac_final(prng->v, sizeof(prng->v), &prng->h); + + if (data == 0 || datalen == 0) { + return; + } + + /* configure the new prng key into the prng's instance of hmac */ + tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key)); + + /* use current state, e and separator 1 to compute a new prng key: */ + (void)tc_hmac_init(&prng->h); + (void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v)); + (void)tc_hmac_update(&prng->h, &separator1, sizeof(separator1)); + (void)tc_hmac_update(&prng->h, data, datalen); + if (additional_data && additional_datalen) { + (void)tc_hmac_update(&prng->h, additional_data, additional_datalen); + } + (void)tc_hmac_final(prng->key, sizeof(prng->key), &prng->h); + + /* configure the new prng key into the prng's instance of hmac */ + (void)tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key)); + + /* use the new key to compute a new state variable v */ + (void)tc_hmac_init(&prng->h); + (void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v)); + (void)tc_hmac_final(prng->v, sizeof(prng->v), &prng->h); +} + +int tc_hmac_prng_init(TCHmacPrng_t prng, + const uint8_t *personalization, + unsigned int plen) +{ + + /* input sanity check: */ + if (prng == (TCHmacPrng_t) 0 || + personalization == (uint8_t *) 0 || + plen > MAX_PLEN) { + return TC_CRYPTO_FAIL; + } + + /* put the generator into a known state: */ + _set(prng->key, 0x00, sizeof(prng->key)); + _set(prng->v, 0x01, sizeof(prng->v)); + + update(prng, personalization, plen, 0, 0); + + /* force a reseed before allowing tc_hmac_prng_generate to succeed: */ + prng->countdown = 0; + + return TC_CRYPTO_SUCCESS; +} + +int tc_hmac_prng_reseed(TCHmacPrng_t prng, + const uint8_t *seed, + unsigned int seedlen, + const uint8_t *additional_input, + unsigned int additionallen) +{ + + /* input sanity check: */ + if (prng == (TCHmacPrng_t) 0 || + seed == (const uint8_t *) 0 || + seedlen < MIN_SLEN || + seedlen > MAX_SLEN) { + return TC_CRYPTO_FAIL; + } + + if (additional_input != (const uint8_t *) 0) { + /* + * Abort if additional_input is provided but has inappropriate + * length + */ + if (additionallen == 0 || + additionallen > MAX_ALEN) { + return TC_CRYPTO_FAIL; + } else { + /* call update for the seed and additional_input */ + update(prng, seed, seedlen, additional_input, additionallen); + } + } else { + /* call update only for the seed */ + update(prng, seed, seedlen, 0, 0); + } + + /* ... and enable hmac_prng_generate */ + prng->countdown = MAX_GENS; + + return TC_CRYPTO_SUCCESS; +} + +int tc_hmac_prng_generate(uint8_t *out, unsigned int outlen, TCHmacPrng_t prng) +{ + unsigned int bufferlen; + + /* input sanity check: */ + if (out == (uint8_t *) 0 || + prng == (TCHmacPrng_t) 0 || + outlen == 0 || + outlen > MAX_OUT) { + return TC_CRYPTO_FAIL; + } else if (prng->countdown == 0) { + return TC_HMAC_PRNG_RESEED_REQ; + } + + prng->countdown--; + + while (outlen != 0) { + /* configure the new prng key into the prng's instance of hmac */ + tc_hmac_set_key(&prng->h, prng->key, sizeof(prng->key)); + + /* operate HMAC in OFB mode to create "random" outputs */ + (void)tc_hmac_init(&prng->h); + (void)tc_hmac_update(&prng->h, prng->v, sizeof(prng->v)); + (void)tc_hmac_final(prng->v, sizeof(prng->v), &prng->h); + + bufferlen = (TC_SHA256_DIGEST_SIZE > outlen) ? + outlen : TC_SHA256_DIGEST_SIZE; + (void)_copy(out, bufferlen, prng->v, bufferlen); + + out += bufferlen; + outlen = (outlen > TC_SHA256_DIGEST_SIZE) ? + (outlen - TC_SHA256_DIGEST_SIZE) : 0; + } + + /* block future PRNG compromises from revealing past state */ + update(prng, 0, 0, 0, 0); + + return TC_CRYPTO_SUCCESS; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c new file mode 100644 index 000000000..6b5b3fcb5 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c @@ -0,0 +1,217 @@ +/* sha256.c - TinyCrypt SHA-256 crypto hash algorithm implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +static void compress(unsigned int *iv, const uint8_t *data); + +int tc_sha256_init(TCSha256State_t s) +{ + /* input sanity check: */ + if (s == (TCSha256State_t) 0) { + return TC_CRYPTO_FAIL; + } + + /* + * Setting the initial state values. + * These values correspond to the first 32 bits of the fractional parts + * of the square roots of the first 8 primes: 2, 3, 5, 7, 11, 13, 17 + * and 19. + */ + _set((uint8_t *) s, 0x00, sizeof(*s)); + s->iv[0] = 0x6a09e667; + s->iv[1] = 0xbb67ae85; + s->iv[2] = 0x3c6ef372; + s->iv[3] = 0xa54ff53a; + s->iv[4] = 0x510e527f; + s->iv[5] = 0x9b05688c; + s->iv[6] = 0x1f83d9ab; + s->iv[7] = 0x5be0cd19; + + return TC_CRYPTO_SUCCESS; +} + +int tc_sha256_update(TCSha256State_t s, const uint8_t *data, size_t datalen) +{ + /* input sanity check: */ + if (s == (TCSha256State_t) 0 || + data == (void *) 0) { + return TC_CRYPTO_FAIL; + } else if (datalen == 0) { + return TC_CRYPTO_SUCCESS; + } + + while (datalen-- > 0) { + s->leftover[s->leftover_offset++] = *(data++); + if (s->leftover_offset >= TC_SHA256_BLOCK_SIZE) { + compress(s->iv, s->leftover); + s->leftover_offset = 0; + s->bits_hashed += (TC_SHA256_BLOCK_SIZE << 3); + } + } + + return TC_CRYPTO_SUCCESS; +} + +int tc_sha256_final(uint8_t *digest, TCSha256State_t s) +{ + unsigned int i; + + /* input sanity check: */ + if (digest == (uint8_t *) 0 || + s == (TCSha256State_t) 0) { + return TC_CRYPTO_FAIL; + } + + s->bits_hashed += (s->leftover_offset << 3); + + s->leftover[s->leftover_offset++] = 0x80; /* always room for one byte */ + if (s->leftover_offset > (sizeof(s->leftover) - 8)) { + /* there is not room for all the padding in this block */ + _set(s->leftover + s->leftover_offset, 0x00, + sizeof(s->leftover) - s->leftover_offset); + compress(s->iv, s->leftover); + s->leftover_offset = 0; + } + + /* add the padding and the length in big-Endian format */ + _set(s->leftover + s->leftover_offset, 0x00, + sizeof(s->leftover) - 8 - s->leftover_offset); + s->leftover[sizeof(s->leftover) - 1] = (uint8_t)(s->bits_hashed); + s->leftover[sizeof(s->leftover) - 2] = (uint8_t)(s->bits_hashed >> 8); + s->leftover[sizeof(s->leftover) - 3] = (uint8_t)(s->bits_hashed >> 16); + s->leftover[sizeof(s->leftover) - 4] = (uint8_t)(s->bits_hashed >> 24); + s->leftover[sizeof(s->leftover) - 5] = (uint8_t)(s->bits_hashed >> 32); + s->leftover[sizeof(s->leftover) - 6] = (uint8_t)(s->bits_hashed >> 40); + s->leftover[sizeof(s->leftover) - 7] = (uint8_t)(s->bits_hashed >> 48); + s->leftover[sizeof(s->leftover) - 8] = (uint8_t)(s->bits_hashed >> 56); + + /* hash the padding and length */ + compress(s->iv, s->leftover); + + /* copy the iv out to digest */ + for (i = 0; i < TC_SHA256_STATE_BLOCKS; ++i) { + unsigned int t = *((unsigned int *) &s->iv[i]); + *digest++ = (uint8_t)(t >> 24); + *digest++ = (uint8_t)(t >> 16); + *digest++ = (uint8_t)(t >> 8); + *digest++ = (uint8_t)(t); + } + + /* destroy the current state */ + _set(s, 0, sizeof(*s)); + + return TC_CRYPTO_SUCCESS; +} + +/* + * Initializing SHA-256 Hash constant words K. + * These values correspond to the first 32 bits of the fractional parts of the + * cube roots of the first 64 primes between 2 and 311. + */ +static const unsigned int k256[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, + 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, + 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, + 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static inline unsigned int ROTR(unsigned int a, unsigned int n) +{ + return (((a) >> n) | ((a) << (32 - n))); +} + +#define Sigma0(a)(ROTR((a), 2) ^ ROTR((a), 13) ^ ROTR((a), 22)) +#define Sigma1(a)(ROTR((a), 6) ^ ROTR((a), 11) ^ ROTR((a), 25)) +#define sigma0(a)(ROTR((a), 7) ^ ROTR((a), 18) ^ ((a) >> 3)) +#define sigma1(a)(ROTR((a), 17) ^ ROTR((a), 19) ^ ((a) >> 10)) + +#define Ch(a, b, c)(((a) & (b)) ^ ((~(a)) & (c))) +#define Maj(a, b, c)(((a) & (b)) ^ ((a) & (c)) ^ ((b) & (c))) + +static inline unsigned int BigEndian(const uint8_t **c) +{ + unsigned int n = 0; + + n = (((unsigned int)(*((*c)++))) << 24); + n |= ((unsigned int)(*((*c)++)) << 16); + n |= ((unsigned int)(*((*c)++)) << 8); + n |= ((unsigned int)(*((*c)++))); + return n; +} + +static void compress(unsigned int *iv, const uint8_t *data) +{ + unsigned int a, b, c, d, e, f, g, h; + unsigned int s0, s1; + unsigned int t1, t2; + unsigned int work_space[16]; + unsigned int n; + unsigned int i; + + a = iv[0]; b = iv[1]; c = iv[2]; d = iv[3]; + e = iv[4]; f = iv[5]; g = iv[6]; h = iv[7]; + + for (i = 0; i < 16; ++i) { + n = BigEndian(&data); + t1 = work_space[i] = n; + t1 += h + Sigma1(e) + Ch(e, f, g) + k256[i]; + t2 = Sigma0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + t1; + d = c; c = b; b = a; a = t1 + t2; + } + + for ( ; i < 64; ++i) { + s0 = work_space[(i + 1) & 0x0f]; + s0 = sigma0(s0); + s1 = work_space[(i + 14) & 0x0f]; + s1 = sigma1(s1); + + t1 = work_space[i & 0xf] += s0 + s1 + work_space[(i + 9) & 0xf]; + t1 += h + Sigma1(e) + Ch(e, f, g) + k256[i]; + t2 = Sigma0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + t1; + d = c; c = b; b = a; a = t1 + t2; + } + + iv[0] += a; iv[1] += b; iv[2] += c; iv[3] += d; + iv[4] += e; iv[5] += f; iv[6] += g; iv[7] += h; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/utils.c b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/utils.c new file mode 100644 index 000000000..117ad7f57 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/tinycrypt/src/utils.c @@ -0,0 +1,74 @@ +/* utils.c - TinyCrypt platform-dependent run-time operations */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include + +#define MASK_TWENTY_SEVEN 0x1b + +unsigned int _copy(uint8_t *to, unsigned int to_len, + const uint8_t *from, unsigned int from_len) +{ + if (from_len <= to_len) { + (void)memcpy(to, from, from_len); + return from_len; + } else { + return TC_CRYPTO_FAIL; + } +} + +void _set(void *to, uint8_t val, unsigned int len) +{ + (void)memset(to, val, len); +} + +/* + * Doubles the value of a byte for values up to 127. + */ +uint8_t _double_byte(uint8_t a) +{ + return ((a << 1) ^ ((a >> 7) * MASK_TWENTY_SEVEN)); +} + +int _compare(const uint8_t *a, const uint8_t *b, size_t size) +{ + const uint8_t *tempa = a; + const uint8_t *tempb = b; + uint8_t result = 0; + + for (unsigned int i = 0; i < size; i++) { + result |= tempa[i] ^ tempb[i]; + } + return result; +} diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index 2711e724b..2f6fe9140 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -19,223 +19,14 @@ #include "foundation.h" #include "mesh_main.h" #include "mesh_common.h" +#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, @@ -244,6 +35,11 @@ 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]; @@ -266,7 +62,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) int period = 0; if (!mod->pub) { - BT_ERR("%s, Model has no publication support", __func__); + BT_ERR("Model has no publication support"); return 0; } @@ -288,7 +84,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("%s, Unknown model publication period", __func__); + BT_ERR("Unknown model publication period"); return 0; } @@ -305,7 +101,7 @@ static s32_t next_period(struct bt_mesh_model *mod) u32_t elapsed = 0U, period = 0U; if (!pub) { - BT_ERR("%s, Model has no publication support", __func__); + BT_ERR("Model has no publication support"); return -ENOTSUP; } @@ -335,7 +131,7 @@ static void publish_sent(int err, void *user_data) BT_DBG("err %d", err); if (!mod->pub) { - BT_ERR("%s, Model has no publication support", __func__); + BT_ERR("Model has no publication support"); return; } @@ -376,7 +172,7 @@ static int publish_retransmit(struct bt_mesh_model *mod) { struct bt_mesh_model_pub *pub = mod->pub; if (!pub) { - BT_ERR("%s, Model has no publication support", __func__); + BT_ERR("Model has no publication support"); return -ENOTSUP; } @@ -398,13 +194,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("%s, AppKey 0x%03x not exists", __func__, pub->key); + BT_ERR("AppKey 0x%03x not exists", pub->key); return -EADDRNOTAVAIL; } tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, key->net_idx); if (!tx.sub) { - BT_ERR("%s, Subnet 0x%04x not exists", __func__, key->net_idx); + BT_ERR("Subnet 0x%04x not exists", key->net_idx); return -EADDRNOTAVAIL; } @@ -413,7 +209,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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -446,12 +242,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("period %u ms", period_ms); + BT_INFO("Publish period %u ms", period_ms); if (pub->count) { err = publish_retransmit(pub->mod); if (err) { - BT_ERR("%s, Failed to retransmit (err %d)", __func__, err); + BT_ERR("Failed to retransmit (err %d)", err); pub->count = 0U; @@ -468,14 +264,11 @@ 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. */ - err = pub->update(pub->mod); - if (err) { + if (pub->update && pub->update(pub->mod)) { /* Cancel this publish attempt. */ BT_ERR("Update failed, skipping publish (err %d)", err); pub->period_start = k_uptime_get_32(); @@ -485,7 +278,7 @@ static void mod_publish(struct k_work *work) err = bt_mesh_model_publish(pub->mod); if (err) { - BT_ERR("%s, Publishing failed (err %d)", __func__, err); + BT_ERR("Publishing failed (err %d)", err); } } @@ -499,12 +292,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("%s, dev_comp is not initialized", __func__); + BT_ERR("dev_comp not initialized"); return NULL; } if (elem_idx >= dev_comp->elem_count) { - BT_ERR("%s, Invalid element index %u", __func__, elem_idx); + BT_ERR("Invalid element index %u", elem_idx); return NULL; } @@ -512,14 +305,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("%s, Invalid vendor model index %u", __func__, mod_idx); + BT_ERR("Invalid vendor model index %u", mod_idx); return NULL; } return &elem->vnd_models[mod_idx]; } else { if (mod_idx >= elem->model_count) { - BT_ERR("%s, Invalid SIG model index %u", __func__, mod_idx); + BT_ERR("Invalid SIG model index %u", mod_idx); return NULL; } @@ -530,8 +323,19 @@ 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) { @@ -555,18 +359,27 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, return; } - for (i = 0; i < ARRAY_SIZE(model_init); i++) { - if (model_init[i].id == mod->id) { - model_init[i].init(mod, primary); - } + if (mod->cb && mod->cb->init) { + *err = mod->cb->init(mod); } } 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) { @@ -586,15 +399,15 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, return; } - for (i = 0; i < ARRAY_SIZE(model_deinit); i++) { - if (model_deinit[i].id == mod->id) { - model_deinit[i].deinit(mod, primary); - } + if (mod->cb && mod->cb->deinit) { + *err = mod->cb->deinit(mod); } } 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; @@ -602,23 +415,24 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp) dev_comp = comp; - bt_mesh_model_foreach(mod_init, NULL); + bt_mesh_model_foreach(mod_init, &err); - return 0; + return err; } int bt_mesh_comp_deregister(void) { + int err = 0; + if (dev_comp == NULL) { return -EINVAL; } - bt_mesh_model_foreach(mod_deinit, NULL); + bt_mesh_model_foreach(mod_deinit, &err); - dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED; dev_comp = NULL; - return 0; + return err; } void bt_mesh_comp_provision(u16_t addr) @@ -644,8 +458,6 @@ 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) @@ -667,7 +479,7 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr) } static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem, - u16_t group_addr) + u16_t group_addr) { struct bt_mesh_model *model = NULL; u16_t *match = NULL; @@ -775,7 +587,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) case 0x00: case 0x01: if (buf->data[0] == 0x7f) { - BT_ERR("%s, Ignoring RFU OpCode", __func__); + BT_ERR("Ignoring RFU OpCode"); return -EINVAL; } @@ -783,7 +595,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) return 0; case 0x02: if (buf->len < 2) { - BT_ERR("%s, Too short payload for 2-octet OpCode", __func__); + BT_ERR("Too short payload for 2-octet OpCode"); return -EINVAL; } @@ -791,7 +603,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) return 0; case 0x03: if (buf->len < 3) { - BT_ERR("%s, Too short payload for 3-octet OpCode", __func__); + BT_ERR("Too short payload for 3-octet OpCode"); return -EINVAL; } @@ -837,7 +649,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("%s, Unable to decode OpCode", __func__); + BT_WARN("Unable to decode OpCode"); return; } @@ -931,7 +743,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("%s, Failed to find DST 0x%04x", __func__, dst); + BT_ERR("Failed to find DST 0x%04x", dst); return false; } return true; @@ -951,7 +763,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("%s, Failed to get model role", __func__); + BT_ERR("Failed to get model role"); return -EINVAL; } @@ -960,22 +772,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("%s, Not ready", __func__); + BT_ERR("Not ready to send"); return -EINVAL; } if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) { - BT_ERR("%s, Not enough tailroom for TransMIC", __func__); + BT_ERR("Not enough tailroom for TransMIC"); return -EINVAL; } if (msg->len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN) - BLE_MESH_MIC_SHORT) { - BT_ERR("%s, Too big message", __func__); + BT_ERR("Too big message (len %d)", msg->len); return -EMSGSIZE; } if (!implicit_bind && !model_has_key(model, tx->ctx->app_idx)) { - BT_ERR("%s, Model not bound to AppKey 0x%04x", __func__, tx->ctx->app_idx); + BT_ERR("Model not bound to AppKey 0x%04x", tx->ctx->app_idx); return -EINVAL; } @@ -992,13 +804,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("%s, Failed to get model role", __func__); + BT_ERR("Failed to get model role"); return -EINVAL; } sub = bt_mesh_tx_netkey_get(role, ctx->net_idx); if (!sub) { - BT_ERR("%s, Failed to get subnet", __func__); + BT_ERR("Invalid NetKeyIndex 0x%04x", ctx->net_idx); return -EINVAL; } @@ -1034,28 +846,28 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) BT_DBG("%s", __func__); if (!pub || !pub->msg) { - BT_ERR("%s, Model has no publication support", __func__); + BT_ERR("Model has no publication support"); return -ENOTSUP; } if (pub->addr == BLE_MESH_ADDR_UNASSIGNED) { - BT_WARN("%s, Unassigned model publish address", __func__); + BT_WARN("Unassigned publish address"); return -EADDRNOTAVAIL; } key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key); if (!key) { - BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key); + BT_ERR("Invalid AppKeyIndex 0x%03x", 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("%s, Message does not fit maximum SDU size", __func__); + BT_ERR("Message does not fit maximum SDU size"); return -EMSGSIZE; } if (pub->count) { - BT_WARN("%s, Clearing publish retransmit timer", __func__); + BT_WARN("Clearing publish retransmit timer"); k_delayed_work_cancel(&pub->timer); } @@ -1070,7 +882,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("%s, Subnet 0x%04x not exists", __func__, ctx.net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", ctx.net_idx); return -EADDRNOTAVAIL; } @@ -1081,7 +893,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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -1097,7 +909,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) } struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, - u16_t company, u16_t id) + u16_t company, u16_t id) { int i; @@ -1111,8 +923,7 @@ 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; diff --git a/components/bt/esp_ble_mesh/mesh_core/access.h b/components/bt/esp_ble_mesh/mesh_core/access.h index 3e002686c..c5615af54 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.h +++ b/components/bt/esp_ble_mesh/mesh_core/access.h @@ -29,11 +29,6 @@ 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); diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index 4e1d94849..60e1ea664 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -27,25 +27,19 @@ #include "mesh_bearer_adapt.h" /* Convert from ms to 0.625ms units */ -#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5) +#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5) /* Convert from 0.625ms units to interval(ms) */ -#define ADV_SCAN_INT(val) ((val) * 5 / 8) +#define ADV_SCAN_INT(val) ((val) * 5 / 8) /* Window and Interval are equal for continuous scanning */ -#define MESH_SCAN_INTERVAL 0x20 -#define MESH_SCAN_WINDOW 0x20 +#define MESH_SCAN_INTERVAL 0x20 +#define MESH_SCAN_WINDOW 0x20 /* Pre-5.0 controllers enforce a minimum interval of 100ms * whereas 5.0+ controllers can go down to 20ms. */ -#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 +#define ADV_INT_DEFAULT_MS 100 +#define ADV_INT_FAST_MS 20 static const bt_mesh_addr_t *dev_addr; @@ -62,19 +56,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 queue; -#if CONFIG_SPIRAM_USE_MALLOC + QueueHandle_t handle; +#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC StaticQueue_t *buffer; u8_t *storage; #endif }; -static struct bt_mesh_queue xBleMeshQueue; -/* We reserve one queue for bt_mesh_adv_update() */ +static struct bt_mesh_queue adv_queue; +/* We reserve one queue item for bt_mesh_adv_update() */ #if CONFIG_BLE_MESH_SUPPORT_BLE_ADV -#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1) +#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1) #else -#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1) +#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1) #endif #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) @@ -83,11 +77,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 xBleMeshRelayQueue; +static struct bt_mesh_queue relay_queue; #define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT -static QueueSetHandle_t xBleMeshQueueSet; -#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE) +static QueueSetHandle_t mesh_queue_set; +#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_ADV_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE) #define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6) #define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF @@ -121,7 +115,9 @@ static void bt_mesh_ble_adv_deinit(void); struct bt_mesh_adv_task { TaskHandle_t handle; -#if CONFIG_SPIRAM_USE_MALLOC +#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \ + CONFIG_SPIRAM_CACHE_WORKAROUND && \ + CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY) StaticTask_t *task; StackType_t *stack; #endif @@ -194,7 +190,7 @@ static inline int adv_send(struct net_buf *buf) struct ble_adv_tx *tx = cb_data; if (tx == NULL) { - BT_ERR("%s, Invalid adv user data", __func__); + BT_ERR("Invalid adv user data"); net_buf_unref(buf); return -EINVAL; } @@ -222,7 +218,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("%s, Advertising failed: err %d", __func__, err); + BT_ERR("Start advertising failed: err %d", err); return err; } @@ -233,7 +229,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("%s, Stop advertising failed: err %d", __func__, err); + BT_ERR("Stop advertising failed: err %d", err); return 0; } @@ -258,54 +254,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(xBleMeshQueue.queue, &msg, K_NO_WAIT); + xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT); while (!(*buf)) { s32_t timeout; BT_DBG("Mesh Proxy Advertising start"); - timeout = bt_mesh_proxy_adv_start(); + timeout = bt_mesh_proxy_server_adv_start(); BT_DBG("Mesh Proxy Advertising up to %d ms", timeout); - xQueueReceive(xBleMeshQueue.queue, &msg, timeout); + xQueueReceive(adv_queue.handle, &msg, timeout); BT_DBG("Mesh Proxy Advertising stop"); - bt_mesh_proxy_adv_stop(); + bt_mesh_proxy_server_adv_stop(); } #else - xQueueReceive(xBleMeshQueue.queue, &msg, portMAX_DELAY); + xQueueReceive(adv_queue.handle, &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(xBleMeshQueueSet, K_NO_WAIT); + handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT); if (handle) { - if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) { - xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT); - } else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) { - xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT); + 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); } } else { while (!(*buf)) { s32_t timeout = 0; BT_DBG("Mesh Proxy Advertising start"); - timeout = bt_mesh_proxy_adv_start(); + timeout = bt_mesh_proxy_server_adv_start(); BT_DBG("Mesh Proxy Advertising up to %d ms", timeout); - handle = xQueueSelectFromSet(xBleMeshQueueSet, timeout); + handle = xQueueSelectFromSet(mesh_queue_set, timeout); BT_DBG("Mesh Proxy Advertising stop"); - bt_mesh_proxy_adv_stop(); + bt_mesh_proxy_server_adv_stop(); if (handle) { - if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) { - xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT); - } else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) { - xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT); + 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); } } } } #else - handle = xQueueSelectFromSet(xBleMeshQueueSet, portMAX_DELAY); + handle = xQueueSelectFromSet(mesh_queue_set, portMAX_DELAY); if (handle) { - if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) { - xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT); - } else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) { - xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT); + 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); } } #endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */ @@ -320,18 +316,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("%s, Failed to send adv packet", __func__); + BT_WARN("Failed to send adv packet"); } #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("%s, Ignore relay packet", __func__); + BT_INFO("Ignore relay packet"); net_buf_unref(*buf); } else { if (adv_send(*buf)) { - BT_WARN("%s, Failed to send adv packet", __func__); + BT_WARN("Failed to send adv packet"); } } #endif @@ -346,9 +342,9 @@ static void adv_thread(void *p) } struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, - bt_mesh_adv_alloc_t get_id, - enum bt_mesh_adv_type type, - u8_t xmit, s32_t timeout) + bt_mesh_adv_alloc_t get_id, + enum bt_mesh_adv_type type, + u8_t xmit, s32_t timeout) { struct bt_mesh_adv *adv = NULL; struct net_buf *buf = NULL; @@ -363,8 +359,8 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, return NULL; } - BT_DBG("%s, pool = %p, buf_count = %d, uinit_count = %d", __func__, - buf->pool, pool->buf_count, pool->uninit_count); + BT_DBG("pool %p, buf_count %d, uinit_count %d", + buf->pool, pool->buf_count, pool->uninit_count); adv = get_id(net_buf_id(buf)); BLE_MESH_ADV(buf) = adv; @@ -446,19 +442,19 @@ static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front) { BT_DBG("%s", __func__); - if (xBleMeshQueue.queue == NULL) { - BT_ERR("%s, Invalid queue", __func__); + if (adv_queue.handle == NULL) { + BT_ERR("Invalid adv queue"); return; } if (front) { - if (xQueueSendToFront(xBleMeshQueue.queue, msg, timeout) != pdTRUE) { - BT_ERR("%s, Failed to send item to queue front", __func__); + if (xQueueSendToFront(adv_queue.handle, msg, timeout) != pdTRUE) { + BT_ERR("Failed to send item to adv queue front"); bt_mesh_unref_buf(msg); } } else { - if (xQueueSend(xBleMeshQueue.queue, msg, timeout) != pdTRUE) { - BT_ERR("%s, Failed to send item to queue back", __func__); + if (xQueueSend(adv_queue.handle, msg, timeout) != pdTRUE) { + BT_ERR("Failed to send item to adv queue back"); bt_mesh_unref_buf(msg); } } @@ -517,7 +513,7 @@ static struct bt_mesh_adv *relay_adv_alloc(int id) } struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout) + s32_t timeout) { return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc, type, xmit, timeout); @@ -530,12 +526,12 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout) BT_DBG("%s", __func__); - if (xBleMeshRelayQueue.queue == NULL) { - BT_ERR("%s, Invalid relay queue", __func__); + if (relay_queue.handle == NULL) { + BT_ERR("Invalid relay queue"); return; } - if (xQueueSend(xBleMeshRelayQueue.queue, msg, timeout) == pdTRUE) { + if (xQueueSend(relay_queue.handle, msg, timeout) == pdTRUE) { return; } @@ -543,25 +539,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(xBleMeshQueueSet, K_NO_WAIT); - if (handle && uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) { - BT_INFO("%s, Full queue, remove the oldest relay packet", __func__); + handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT); + if (handle && uxQueueMessagesWaiting(relay_queue.handle)) { + BT_INFO("Full queue, remove the oldest relay packet"); /* Remove the oldest relay packet from queue */ - if (xQueueReceive(xBleMeshRelayQueue.queue, &old_msg, K_NO_WAIT) != pdTRUE) { - BT_ERR("%s, Failed to remove item from queue", __func__); + if (xQueueReceive(relay_queue.handle, &old_msg, K_NO_WAIT) != pdTRUE) { + BT_ERR("Failed to remove item from queue"); 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(xBleMeshRelayQueue.queue, msg, K_NO_WAIT) != pdTRUE) { - BT_ERR("%s, Failed to send item to relay queue", __func__); + if (xQueueSend(relay_queue.handle, msg, K_NO_WAIT) != pdTRUE) { + BT_ERR("Failed to send item to relay queue"); bt_mesh_unref_buf(msg); return; } } else { - BT_WARN("%s, Empty queue, but failed to send the relay packet", __func__); + BT_WARN("Empty queue, but failed to send the relay packet"); bt_mesh_unref_buf(msg); } } @@ -584,29 +580,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 xBleMeshRelayQueue is full return immediately */ + /* Use K_NO_WAIT here, if relay_queue 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(xBleMeshRelayQueue.queue); + return (u16_t)uxQueueMessagesWaiting(relay_queue.handle); } #endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ -const bt_mesh_addr_t *bt_mesh_pba_get_addr(void) +const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void) { return dev_addr; } #if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \ CONFIG_BLE_MESH_GATT_PROXY_CLIENT -static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf) +static bool adv_flags_valid(struct net_buf_simple *buf) { u8_t flags = 0U; if (buf->len != 1U) { - BT_DBG("%s, Unexpected flags length", __func__); + BT_DBG("Unexpected adv flags length %d", buf->len); return false; } @@ -620,7 +616,7 @@ static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf) return true; } -static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uuid) +static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid) { if (buf->len != 2U) { BT_DBG("Length not match mesh service uuid"); @@ -653,7 +649,9 @@ static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uui #define BLE_MESH_PROXY_SRV_DATA_LEN1 0x09 #define BLE_MESH_PROXY_SRV_DATA_LEN2 0x11 -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) +static void handle_adv_service_data(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, + u16_t uuid, s8_t rssi) { u16_t type = 0U; @@ -664,7 +662,7 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_ type = net_buf_simple_pull_le16(buf); if (type != uuid) { - BT_DBG("%s, Invalid Mesh Service Data UUID 0x%04x", __func__, type); + BT_DBG("Invalid Mesh Service Data UUID 0x%04x", type); return; } @@ -673,12 +671,12 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_ case BLE_MESH_UUID_MESH_PROV_VAL: if (bt_mesh_is_provisioner_en()) { if (buf->len != BLE_MESH_PROV_SRV_DATA_LEN) { - BT_WARN("%s, Invalid Mesh Prov Service Data length %d", __func__, buf->len); + BT_WARN("Invalid Mesh Prov Service Data length %d", buf->len); return; } BT_DBG("Start to handle Mesh Prov Service Data"); - bt_mesh_provisioner_prov_adv_ind_recv(buf, addr, rssi); + bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi); } break; #endif @@ -686,12 +684,12 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_ 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("%s, Invalid Mesh Proxy Service Data length %d", __func__, buf->len); + BT_WARN("Invalid Mesh Proxy Service Data length %d", buf->len); return; } BT_DBG("Start to handle Mesh Proxy Service Data"); - bt_mesh_proxy_client_adv_ind_recv(buf, addr, rssi); + bt_mesh_proxy_client_gatt_adv_recv(buf, addr, rssi); break; #endif default: @@ -712,7 +710,7 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi, return; } - BT_DBG("%s, len %u: %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("scan, len %u: %s", buf->len, bt_hex(buf->data, buf->len)); dev_addr = addr; @@ -767,19 +765,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 (!bt_mesh_is_adv_flags_valid(buf)) { + if (!adv_flags_valid(buf)) { BT_DBG("Adv Flags mismatch, ignore this adv pkt"); return; } break; case BLE_MESH_DATA_UUID16_ALL: - if (!bt_mesh_is_adv_srv_uuid_valid(buf, &uuid)) { + if (!adv_service_uuid_valid(buf, &uuid)) { BT_DBG("Adv Service UUID mismatch, ignore this adv pkt"); return; } break; case BLE_MESH_DATA_SVC_DATA16: - bt_mesh_adv_srv_data_recv(buf, addr, uuid, rssi); + handle_adv_service_data(buf, addr, uuid, rssi); break; #endif default: @@ -795,65 +793,81 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi, void bt_mesh_adv_init(void) { -#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__); +#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); #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_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__); +#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); #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 */ - xBleMeshQueueSet = xQueueCreateSet(BLE_MESH_QUEUE_SET_SIZE); - __ASSERT(xBleMeshQueueSet, "%s, Failed to create queue set", __func__); - xQueueAddToSet(xBleMeshQueue.queue, xBleMeshQueueSet); - xQueueAddToSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet); + 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); #endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ -#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 +#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \ + CONFIG_SPIRAM_CACHE_WORKAROUND && \ + CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY) adv_task.task = heap_caps_calloc(1, sizeof(StaticTask_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); - __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 + __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 */ } void bt_mesh_adv_deinit(void) { - if (xBleMeshQueue.queue == NULL) { + if (adv_queue.handle == NULL) { return; } vTaskDelete(adv_task.handle); adv_task.handle = NULL; -#if CONFIG_SPIRAM_USE_MALLOC +#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \ + CONFIG_SPIRAM_CACHE_WORKAROUND && \ + CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY) heap_caps_free(adv_task.stack); adv_task.stack = NULL; heap_caps_free(adv_task.task); @@ -861,32 +875,32 @@ void bt_mesh_adv_deinit(void) #endif #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) - xQueueRemoveFromSet(xBleMeshQueue.queue, xBleMeshQueueSet); - xQueueRemoveFromSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet); + xQueueRemoveFromSet(adv_queue.handle, mesh_queue_set); + xQueueRemoveFromSet(relay_queue.handle, mesh_queue_set); - 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; + 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; #endif bt_mesh_unref_buf_from_pool(&relay_adv_buf_pool); memset(relay_adv_pool, 0, sizeof(relay_adv_pool)); - vQueueDelete(xBleMeshQueueSet); - xBleMeshQueueSet = NULL; + vQueueDelete(mesh_queue_set); + mesh_queue_set = NULL; #endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ - 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; + 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; #endif bt_mesh_unref_buf_from_pool(&adv_buf_pool); @@ -959,7 +973,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) { + if (err && err != -EALREADY) { BT_ERR("starting scan failed (err %d)", err); return err; } @@ -1097,17 +1111,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("%s, Invalid adv interval 0x%04x", __func__, param->interval); + BT_ERR("Invalid adv interval 0x%04x", param->interval); return -EINVAL; } if (param->adv_type > BLE_MESH_ADV_DIRECT_IND_LOW_DUTY) { - BT_ERR("%s, Invalid adv type 0x%02x", __func__, param->adv_type); + BT_ERR("Invalid adv type 0x%02x", param->adv_type); return -EINVAL; } if (param->own_addr_type > BLE_MESH_ADDR_RANDOM_ID) { - BT_ERR("%s, Invalid own addr type 0x%02x", __func__, param->own_addr_type); + BT_ERR("Invalid own addr type 0x%02x", param->own_addr_type); return -EINVAL; } @@ -1116,29 +1130,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("%s, Invalid peer addr type 0x%02x", __func__, param->peer_addr_type); + BT_ERR("Invalid peer addr type 0x%02x", param->peer_addr_type); return -EINVAL; } if (data && (data->adv_data_len > 31 || data->scan_rsp_data_len > 31)) { - BT_ERR("%s, Invalid adv data length, %d %d", __func__, - data->adv_data_len, data->scan_rsp_data_len); + BT_ERR("Invalid adv data length (adv %d, scan rsp %d)", + data->adv_data_len, data->scan_rsp_data_len); return -EINVAL; } if (param->priority > BLE_MESH_BLE_ADV_PRIO_HIGH) { - BT_ERR("%s, Invalid adv priority %d", __func__, param->priority); + BT_ERR("Invalid adv priority %d", param->priority); return -EINVAL; } if (param->duration < ADV_SCAN_INT(param->interval)) { - BT_ERR("%s, Too small duration %dms", __func__, param->duration); + BT_ERR("Too small duration %dms", param->duration); return -EINVAL; } buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, 0U, K_NO_WAIT); if (!buf) { - BT_ERR("%s, Unable to allocate buffer", __func__); + BT_ERR("Unable to allocate buffer"); return -ENOBUFS; } @@ -1188,14 +1202,14 @@ int bt_mesh_stop_ble_advertising(u8_t index) bool unref = true; if (index >= ARRAY_SIZE(ble_adv_tx)) { - BT_ERR("%s, Invalid index %d", __func__, index); + BT_ERR("Invalid adv index %d", index); return -EINVAL; } tx = &ble_adv_tx[index]; if (tx->buf == NULL) { - BT_WARN("%s, Already stopped, index %d", __func__, index); + BT_WARN("Already stopped, index %d", index); return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.h b/components/bt/esp_ble_mesh/mesh_core/adv.h index e0ade0da3..79f344e43 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.h +++ b/components/bt/esp_ble_mesh/mesh_core/adv.h @@ -69,19 +69,19 @@ void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf, u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag); struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, - bt_mesh_adv_alloc_t get_id, - enum bt_mesh_adv_type type, - u8_t xmit, s32_t timeout); + bt_mesh_adv_alloc_t get_id, + enum bt_mesh_adv_type type, + u8_t xmit, s32_t timeout); 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_pba_get_addr(void); +const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void); struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout); + s32_t timeout); void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, void *cb_data, u16_t src, u16_t dst); diff --git a/components/bt/esp_ble_mesh/mesh_core/beacon.c b/components/bt/esp_ble_mesh/mesh_core/beacon.c index 2f53aa49f..1ae51acdf 100644 --- a/components/bt/esp_ble_mesh/mesh_core/beacon.c +++ b/components/bt/esp_ble_mesh/mesh_core/beacon.c @@ -40,6 +40,9 @@ /* 1 transmission, 20ms interval */ #define PROV_XMIT BLE_MESH_TRANSMIT(0, 20) +#define SNB_NET_IDX_SET(_val) ((void *)((u32_t)(_val))) +#define SNB_NET_IDX_GET(_ptr) ((u32_t)(_ptr)) + static struct k_delayed_work beacon_timer; static struct bt_mesh_subnet *cache_check(u8_t data[21]) @@ -71,11 +74,30 @@ static void cache_add(u8_t data[21], struct bt_mesh_subnet *sub) static void beacon_complete(int err, void *user_data) { - struct bt_mesh_subnet *sub = user_data; + struct bt_mesh_subnet *sub = NULL; + u16_t net_idx = BLE_MESH_KEY_UNUSED; BT_DBG("err %d", err); - sub->beacon_sent = k_uptime_get_32(); + net_idx = (u16_t)SNB_NET_IDX_GET(user_data); + + /* For node, directly updating the "beacon_sent" timestamp is fine, + * since the subnet is pre-allocated. + * For Provisioner, before updating the "beacon_sent" timestamp, we + * need to make sure that the subnet still exists, because there is + * a chance that the subnet is removed just before the completion of + * sending the Secure Network Beacon. + */ + if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { + sub = bt_mesh_subnet_get(net_idx); + } else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && + bt_mesh_is_provisioner_en()) { + sub = bt_mesh_provisioner_subnet_get(net_idx); + } + + if (sub) { + sub->beacon_sent = k_uptime_get_32(); + } } void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, @@ -155,13 +177,23 @@ static int secure_beacon_send(void) buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, PROV_XMIT, K_NO_WAIT); if (!buf) { - BT_ERR("%s, Unable to allocate beacon buffer", __func__); + BT_ERR("Out of beacon buffer"); return -ENOBUFS; } bt_mesh_beacon_create(sub, &buf->b); - bt_mesh_adv_send(buf, &send_cb, sub); + /* Care should be taken here. Previously the user_data is the + * pointer of a subnet. When the device is a Provisioner, its + * subnet is created dynamically. If the corresponding subnet + * is removed right after the Secure Network Beacon is sent, + * update its "beacon_sent" timestamp in beacon_complete() will + * cause exception. + * Here we use the "net_idx" of the subnet instead. And in the + * beacon_complete(), we will try to get the subnet before + * updating its "beacon_sent" timestamp. + */ + bt_mesh_adv_send(buf, &send_cb, SNB_NET_IDX_SET(sub->net_idx)); net_buf_unref(buf); } @@ -181,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("%s, Unable to allocate beacon buffer", __func__); + BT_ERR("Out of beacon buffer"); return -ENOBUFS; } @@ -264,16 +296,9 @@ static void update_beacon_observation(void) static bool ready_to_send(void) { - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { + if (bt_mesh_is_provisioned() || bt_mesh_is_provisioner_en()) { return true; } - - if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) { - if (bt_mesh_provisioner_get_node_count()) { - return true; - } - } - return false; } @@ -316,7 +341,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf) u8_t flags = 0U; if (buf->len < 21) { - BT_ERR("%s, Too short secure beacon (len %u)", __func__, buf->len); + BT_ERR("Too short secure beacon (len %u)", buf->len); return; } @@ -395,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("%s, Too short beacon", __func__); + BT_ERR("Too short beacon"); return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index 801c26341..d6e09936e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -21,8 +21,10 @@ #include "mbedtls/aes.h" #include "bt_common.h" +#include +#include + #include "mesh_hci.h" -#include "mesh_aes_encrypt.h" #include "mesh_bearer_adapt.h" #include "mesh_common.h" #include "provisioner_prov.h" @@ -128,7 +130,7 @@ void bt_mesh_hci_init(void) } static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir, - tBTA_DM_SEARCH_CBACK *p_scan_cback) + tBTA_DM_SEARCH_CBACK *p_scan_cback) { tBTM_INQ_INFO *p_inq_info = NULL; tBTA_DM_SEARCH result = {0}; @@ -257,7 +259,8 @@ 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 */ @@ -286,7 +289,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? */ @@ -298,7 +301,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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len); @@ -308,9 +311,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("%s, Scan completed, number of scan response %d", __func__, p_data->inq_cmpl.num_resps); + BT_INFO("Scan completed, number of scan response %d", p_data->inq_cmpl.num_resps); } else { - BT_WARN("%s, Unexpected event 0x%x", __func__, event); + BT_WARN("Unexpected scan result event %d", event); } } @@ -334,13 +337,13 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param, #endif if (!valid_adv_param(param)) { - BT_ERR("%s, Invalid adv parameters", __func__); + BT_ERR("Invalid adv parameters"); return -EINVAL; } err = set_adv_data(BLE_MESH_HCI_OP_SET_ADV_DATA, ad, ad_len); if (err) { - BT_ERR("%s, Failed to set adv data", __func__); + BT_ERR("Failed to set adv data"); return err; } @@ -356,7 +359,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("%s, Failed to set scan rsp data", __func__); + BT_ERR("Failed to set scan rsp data"); return err; } } @@ -457,11 +460,10 @@ 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; @@ -475,31 +477,30 @@ 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); -#endif - bt_mesh_scan_dev_found_cb = cb; - return err; + + return 0; } int bt_le_scan_stop(void) { -#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); - BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL)); + if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { + BT_INFO("Scan is already stopped"); + return -EALREADY; } -#else - BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL)); -#endif + 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); bt_mesh_scan_dev_found_cb = NULL; + return 0; } @@ -537,7 +538,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("%s, read: handle = %d", __func__, p_data->req_data.p_data->read_req.handle); + BT_DBG("gatts read, handle %d", 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, @@ -547,9 +548,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("%s, Send gatts read response, handle = %x", __func__, attr->handle); + BT_DBG("Send gatts read rsp, handle %d", attr->handle); } else { - BT_WARN("%s, BLE Mesh gatts read failed", __func__); + BT_WARN("Mesh gatts read failed"); } } break; @@ -559,7 +560,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("%s, write: handle = %d, len = %d, data = %s", __func__, p_data->req_data.p_data->write_req.handle, + BT_DBG("gatts write, handle %d, len %d, data %s", 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)); @@ -571,7 +572,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("%s, send mesh write rsp, handle = %x", __func__, attr->handle); + BT_DBG("Send gatts write rsp, handle %d", attr->handle); } } } @@ -585,7 +586,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("%s, svc_handle = %d, future_mesh = %p", __func__, svc_handle, future_mesh); + BT_DBG("svc_handle %d, future_mesh %p", svc_handle, future_mesh); if (future_mesh != NULL) { future_ready(future_mesh, FUTURE_SUCCESS); } @@ -726,7 +727,8 @@ 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) { @@ -752,8 +754,8 @@ struct gatts_incl { } __packed; ssize_t bt_mesh_gatts_attr_read_included(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_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; @@ -802,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; @@ -820,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("%s, No value for characteristic at 0x%04x", __func__, attr->handle); + BT_WARN("No value for characteristic, handle 0x%04x", attr->handle); pdu.value_handle = 0x0000; } else { pdu.value_handle = sys_cpu_to_le16(next->handle); @@ -852,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("%s, Invalid mesh uuid type = %d", __func__, uuid->type); + BT_ERR("Invalid mesh uuid type %d", uuid->type); } return; @@ -870,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("%s, handle = %d", __func__, handle); + BT_DBG("gatts register, handle %d", handle); ((void) handle); @@ -935,11 +937,12 @@ 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("%s, Failed to add primary service", __func__); + BT_ERR("Failed to add primary service"); return ESP_FAIL; } svc->attrs[i].handle = 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); + BT_DBG("Add primary service, uuid 0x%04x, perm %d, handle %d", + bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle); break; } case BLE_MESH_UUID_GATT_SECONDARY_VAL: { @@ -948,11 +951,12 @@ 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("%s, Failed to add secondary service", __func__); + BT_ERR("Failed to add secondary service"); return ESP_FAIL; } svc->attrs[i].handle = 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); + BT_DBG("Add secondary service, uuid 0x%04x, perm %d, handle %d", + bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle); break; } case BLE_MESH_UUID_GATT_INCLUDE_VAL: { @@ -964,13 +968,14 @@ 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("%s, Failed to add characteristic", __func__); + BT_ERR("Failed to add characteristic"); 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: 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); + 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); break; } case BLE_MESH_UUID_GATT_CEP_VAL: @@ -988,11 +993,12 @@ 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("%s, Failed to add descriptor", __func__); + BT_ERR("Failed to add descriptor"); return ESP_FAIL; } svc->attrs[i].handle = 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); + 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); break; } default: @@ -1036,7 +1042,8 @@ 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); @@ -1084,7 +1091,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("%s, type 0x%02x, val 0x%04x", __func__, uuid_16->uuid.type, uuid_16->val); + BT_DBG("service start, type 0x%02x, val 0x%04x", 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); } @@ -1139,7 +1146,7 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) } } - BT_ERR("%s, Conn is not found", __func__); + BT_ERR("Conn %p not found", conn); return 0; } @@ -1160,21 +1167,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("%s, Invalid remote address", __func__); + BT_ERR("Invalid remote address"); return -EINVAL; } if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL && service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { - BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid); + BT_ERR("Invalid service uuid 0x%04x", 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("%s, Already create connection with %s", - __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + BT_WARN("Already create connection with %s", + bt_hex(addr->val, BLE_MESH_ADDR_LEN)); return -EALREADY; } } @@ -1192,19 +1199,16 @@ 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("%s, gattc info is full", __func__); + BT_WARN("gattc info is full"); return -ENOMEM; } -#if BLE_MESH_DEV - if (bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { + if (bt_mesh_atomic_test_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("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN)); /* Min_interval: 250ms * Max_interval: 250ms @@ -1245,7 +1249,8 @@ 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; @@ -1261,7 +1266,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_g } } - BT_ERR("%s, Conn is not found", __func__); + BT_ERR("Conn %p not found", conn); return -EEXIST; } @@ -1286,7 +1291,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn) } } - BT_ERR("%s, Conn is not found", __func__); + BT_ERR("Conn %p not found", conn); return; } @@ -1371,7 +1376,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) } if (conn == NULL) { - BT_ERR("%s, Conn handle is not found", __func__); + BT_ERR("Conn handle 0x%04x not found", handle); return; } @@ -1511,12 +1516,12 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) } if (conn == NULL) { - BT_ERR("%s, Conn handle is not found", __func__); + BT_ERR("Conn handle 0x%04x not found", handle); return; } if (bt_mesh_gattc_info[i].ccc_handle != p_data->write.handle) { - BT_WARN("%s, gattc ccc_handle is not matched", __func__); + BT_WARN("gattc ccc_handle not matched"); bt_mesh_gattc_disconnect(conn); return; } @@ -1525,7 +1530,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("%s, prov_write_descr failed", __func__); + BT_ERR("prov_write_descr failed"); bt_mesh_gattc_disconnect(conn); return; } @@ -1535,7 +1540,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("%s, proxy_write_descr failed", __func__); + BT_ERR("proxy_write_descr failed"); bt_mesh_gattc_disconnect(conn); return; } @@ -1563,14 +1568,14 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) } if (conn == NULL) { - BT_ERR("%s, Conn handle is not found", __func__); + BT_ERR("Conn handle 0x%04x not found", handle); 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("%s, Notification error", __func__); + BT_ERR("Notification error"); bt_mesh_gattc_disconnect(conn); return; } @@ -1580,7 +1585,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("%s, prov_notify failed", __func__); + BT_ERR("prov_notify failed"); bt_mesh_gattc_disconnect(conn); return; } @@ -1590,7 +1595,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("%s, proxy_notify failed", __func__); + BT_ERR("proxy_notify failed"); bt_mesh_gattc_disconnect(conn); return; } @@ -1606,30 +1611,20 @@ 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 BTA_DmBleScan() to re-enable scan. + /* After current connection is established, Provisioner can + * use BTM_BleScan() 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)) { - status = BTM_BleScan(true, 0, bt_mesh_scan_results_cb, NULL, NULL); + tBTM_STATUS 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); + BT_ERR("Invalid scan status %d", 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; @@ -1637,7 +1632,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("%s, gattc_if & connect_if don't match", __func__); + BT_ERR("gattc_if & connect_if mismatch"); return; } @@ -1656,7 +1651,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("%s, gattc_if & disconnect_if don't match", __func__); + BT_ERR("gattc_if & disconnect_if mismatch"); return; } @@ -1815,7 +1810,7 @@ int bt_mesh_rand(void *buf, size_t len) memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t)); } - BT_DBG("%s, rand: %s", __func__, bt_hex(buf, len)); + BT_DBG("Rand %s", bt_hex(buf, len)); return 0; } @@ -2017,13 +2012,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("%s, NULL Provisioning Link ID", __func__); + BT_ERR("Invalid Provisioning Link ID"); return -EINVAL; } sys_memcpy_swap(value, info, sizeof(u32_t)); } - BT_DBG("%s, %s type 0x%x", __func__, sub_code ? "Remove" : "Add", type); + BT_DBG("%s exceptional list, type 0x%02x", 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)); diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c index 0390f4923..16c2f6d90 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c @@ -20,13 +20,6 @@ #include "mesh_common.h" #include "cfg_cli.h" -/* 2 byte dummy opcode for getting compile time buffer sizes. */ -#define DUMMY_2_BYTE_OP BLE_MESH_MODEL_OP_2(0xff, 0xff) - -s32_t config_msg_timeout; - -static bt_mesh_config_client_t *cli; - static const bt_mesh_client_op_pair_t cfg_op_pair[] = { { OP_BEACON_GET, OP_BEACON_STATUS }, { OP_BEACON_SET, OP_BEACON_STATUS }, @@ -130,9 +123,9 @@ static void timeout_handler(struct k_work *work) return; } -static void cfg_client_cancel(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - void *status, size_t len) +static void cfg_client_recv_status(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + void *status, size_t len) { bt_mesh_client_node_t *node = NULL; struct net_buf_simple buf = {0}; @@ -151,7 +144,7 @@ static void cfg_client_cancel(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true); if (!node) { - BT_DBG("Unexpected config status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Config Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case OP_BEACON_GET: @@ -221,8 +214,7 @@ static void cfg_client_cancel(struct bt_mesh_model *model, switch (ctx->recv_op) { case OP_DEV_COMP_DATA_STATUS: { - struct bt_mesh_cfg_comp_data_status *val; - val = (struct bt_mesh_cfg_comp_data_status *)status; + struct bt_mesh_cfg_comp_data_status *val = status; bt_mesh_free_buf(val->comp_data); break; } @@ -266,13 +258,13 @@ static void comp_data_status(struct bt_mesh_model *model, status.page = net_buf_simple_pull_u8(buf); status.comp_data = bt_mesh_alloc_buf(buf->len); if (!status.comp_data) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(status.comp_data, buf->data, buf->len); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_comp_data_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_comp_data_status)); } static void state_status_u8(struct bt_mesh_model *model, @@ -287,7 +279,7 @@ static void state_status_u8(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(u8_t)); + cfg_client_recv_status(model, ctx, &status, sizeof(u8_t)); } static void beacon_status(struct bt_mesh_model *model, @@ -331,7 +323,7 @@ static void relay_status(struct bt_mesh_model *model, status.relay = net_buf_simple_pull_u8(buf); status.retransmit = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_relay_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_relay_status)); } static void net_key_status(struct bt_mesh_model *model, @@ -347,7 +339,7 @@ static void net_key_status(struct bt_mesh_model *model, status.status = net_buf_simple_pull_u8(buf); status.net_idx = net_buf_simple_pull_le16(buf) & 0xfff; - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_netkey_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_netkey_status)); } static void app_key_status(struct bt_mesh_model *model, @@ -363,7 +355,7 @@ static void app_key_status(struct bt_mesh_model *model, status.status = net_buf_simple_pull_u8(buf); key_idx_unpack(buf, &status.net_idx, &status.app_idx); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_appkey_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_appkey_status)); } static void mod_app_status(struct bt_mesh_model *model, @@ -386,7 +378,7 @@ static void mod_app_status(struct bt_mesh_model *model, } status.mod_id = net_buf_simple_pull_le16(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_app_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_app_status)); } static void mod_pub_status(struct bt_mesh_model *model, @@ -415,7 +407,7 @@ static void mod_pub_status(struct bt_mesh_model *model, } status.mod_id = net_buf_simple_pull_le16(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_pub_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_pub_status)); } static void mod_sub_status(struct bt_mesh_model *model, @@ -438,7 +430,7 @@ static void mod_sub_status(struct bt_mesh_model *model, } status.mod_id = net_buf_simple_pull_le16(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_sub_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_mod_sub_status)); } static void hb_sub_status(struct bt_mesh_model *model, @@ -459,7 +451,7 @@ static void hb_sub_status(struct bt_mesh_model *model, status.min = net_buf_simple_pull_u8(buf); status.max = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_hb_sub_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_hb_sub_status)); } static void hb_pub_status(struct bt_mesh_model *model, @@ -480,7 +472,7 @@ static void hb_pub_status(struct bt_mesh_model *model, status.feat = net_buf_simple_pull_u8(buf); status.net_idx = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_hb_sub_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_hb_sub_status)); } static void node_reset_status(struct bt_mesh_model *model, @@ -491,7 +483,7 @@ static void node_reset_status(struct bt_mesh_model *model, ctx->net_idx, ctx->app_idx, ctx->addr, buf->len, bt_hex(buf->data, buf->len)); - cfg_client_cancel(model, ctx, NULL, 0); + cfg_client_recv_status(model, ctx, NULL, 0); } static void mod_sub_list(struct bt_mesh_model *model, @@ -515,12 +507,12 @@ static void mod_sub_list(struct bt_mesh_model *model, list.addr = bt_mesh_alloc_buf(buf->len); if (!list.addr) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(list.addr, buf->data, buf->len); - cfg_client_cancel(model, ctx, &list, sizeof(struct bt_mesh_cfg_mod_sub_list)); + cfg_client_recv_status(model, ctx, &list, sizeof(struct bt_mesh_cfg_mod_sub_list)); } static void net_key_list(struct bt_mesh_model *model, @@ -535,12 +527,12 @@ static void net_key_list(struct bt_mesh_model *model, list.net_idx = bt_mesh_alloc_buf(buf->len); if (!list.net_idx) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(list.net_idx, buf->data, buf->len); - cfg_client_cancel(model, ctx, &list, sizeof(struct bt_mesh_cfg_net_key_list)); + cfg_client_recv_status(model, ctx, &list, sizeof(struct bt_mesh_cfg_net_key_list)); } static void app_key_list(struct bt_mesh_model *model, @@ -557,12 +549,12 @@ static void app_key_list(struct bt_mesh_model *model, list.net_idx = net_buf_simple_pull_le16(buf); list.app_idx = bt_mesh_alloc_buf(buf->len); if (!list.app_idx) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(list.app_idx, buf->data, buf->len); - cfg_client_cancel(model, ctx, &list, sizeof(struct bt_mesh_cfg_app_key_list)); + cfg_client_recv_status(model, ctx, &list, sizeof(struct bt_mesh_cfg_app_key_list)); } static void node_id_status(struct bt_mesh_model *model, @@ -579,7 +571,7 @@ static void node_id_status(struct bt_mesh_model *model, status.net_idx = net_buf_simple_pull_le16(buf); status.identity = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_node_id_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_node_id_status)); } static void mod_app_list(struct bt_mesh_model *model, @@ -603,12 +595,12 @@ static void mod_app_list(struct bt_mesh_model *model, list.app_idx = bt_mesh_alloc_buf(buf->len); if (!list.app_idx) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(list.app_idx, buf->data, buf->len); - cfg_client_cancel(model, ctx, &list, sizeof(struct bt_mesh_cfg_mod_app_list)); + cfg_client_recv_status(model, ctx, &list, sizeof(struct bt_mesh_cfg_mod_app_list)); } static void kr_phase_status(struct bt_mesh_model *model, @@ -625,7 +617,7 @@ static void kr_phase_status(struct bt_mesh_model *model, status.net_idx = net_buf_simple_pull_le16(buf); status.phase = net_buf_simple_pull_u8(buf); - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_key_refresh_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_key_refresh_status)); } static void lpn_pollto_status(struct bt_mesh_model *model, @@ -643,7 +635,7 @@ static void lpn_pollto_status(struct bt_mesh_model *model, status.timeout |= net_buf_simple_pull_u8(buf) << 8; status.timeout |= net_buf_simple_pull_u8(buf) << 16; - cfg_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_cfg_lpn_pollto_status)); + cfg_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_cfg_lpn_pollto_status)); } static void net_trans_status(struct bt_mesh_model *model, @@ -681,251 +673,158 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page) +static int send_msg_with_none(bt_mesh_client_common_param_t *param, u32_t op) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_DEV_COMP_DATA_GET, 1); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_DEV_COMP_DATA_GET); - net_buf_simple_add_u8(&msg, page); - - err = bt_mesh_client_send_msg(cli->model, OP_DEV_COMP_DATA_GET, ctx, - &msg, timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; -} - -static int get_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op) -{ - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 0); - int err = 0; + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 0); bt_mesh_model_msg_init(&msg, op); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int set_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op, u8_t new_val) +static int send_msg_with_u8(bt_mesh_client_common_param_t *param, u32_t op, u8_t val) { - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 1); - int err = 0; + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 1); bt_mesh_model_msg_init(&msg, op); - net_buf_simple_add_u8(&msg, new_val); + net_buf_simple_add_u8(&msg, val); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_beacon_get(struct bt_mesh_msg_ctx *ctx) +static int send_msg_with_le16(bt_mesh_client_common_param_t *param, u32_t op, u16_t val) { - if (!ctx || !ctx->addr) { + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 2); + + bt_mesh_model_msg_init(&msg, op); + net_buf_simple_add_le16(&msg, val); + + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); +} + +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page) +{ + return send_msg_with_u8(param, OP_DEV_COMP_DATA_GET, page); +} + +int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param) +{ + return send_msg_with_none(param, OP_BEACON_GET); +} + +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val) +{ + if (val > 0x01) { + BT_ERR("Invalid beacon state 0x%02x", val); return -EINVAL; } - return get_state_u8(ctx, OP_BEACON_GET); + return send_msg_with_u8(param, OP_BEACON_SET, 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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return set_state_u8(ctx, OP_BEACON_SET, val); + return send_msg_with_none(param, OP_DEFAULT_TTL_GET); } -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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return get_state_u8(ctx, OP_DEFAULT_TTL_GET); + return send_msg_with_u8(param, OP_DEFAULT_TTL_SET, 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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return set_state_u8(ctx, OP_DEFAULT_TTL_SET, val); + return send_msg_with_none(param, OP_FRIEND_GET); } -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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return get_state_u8(ctx, OP_FRIEND_GET); + return send_msg_with_u8(param, OP_FRIEND_SET, 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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return set_state_u8(ctx, OP_FRIEND_SET, val); + return send_msg_with_none(param, OP_GATT_PROXY_GET); } -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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return get_state_u8(ctx, OP_GATT_PROXY_GET); + return send_msg_with_u8(param, OP_GATT_PROXY_SET, 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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return set_state_u8(ctx, OP_GATT_PROXY_SET, val); + return send_msg_with_none(param, OP_RELAY_GET); } -int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx) -{ - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_GET, 0); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_RELAY_GET); - - err = bt_mesh_client_send_msg(cli->model, OP_RELAY_GET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; -} - -int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay, - u8_t new_transmit) +int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, + u8_t relay, u8_t retransmit) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_SET, 2); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_RELAY_SET); - net_buf_simple_add_u8(&msg, new_relay); - net_buf_simple_add_u8(&msg, new_transmit); + net_buf_simple_add_u8(&msg, relay); + net_buf_simple_add_u8(&msg, retransmit); - err = bt_mesh_client_send_msg(cli->model, OP_RELAY_SET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_net_key_add(bt_mesh_client_common_param_t *param, + u16_t net_idx, const u8_t net_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_ADD, 18); - int err = 0; - if (!ctx || !ctx->addr || !net_key) { + if (!net_key) { + BT_ERR("Invalid NetKey"); return -EINVAL; } bt_mesh_model_msg_init(&msg, OP_NET_KEY_ADD); - net_buf_simple_add_le16(&msg, key_net_idx); + net_buf_simple_add_le16(&msg, net_idx); net_buf_simple_add_mem(&msg, net_key, 16); - err = bt_mesh_client_send_msg(cli->model, OP_NET_KEY_ADD, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_app_key_add(bt_mesh_client_common_param_t *param, + u16_t net_idx, u16_t app_idx, + const u8_t app_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_ADD, 19); - int err = 0; - if (!ctx || !ctx->addr || !app_key) { + if (!app_key) { + BT_ERR("Invalid AppKey"); return -EINVAL; } bt_mesh_model_msg_init(&msg, OP_APP_KEY_ADD); - key_idx_pack(&msg, key_net_idx, key_app_idx); + key_idx_pack(&msg, net_idx, app_idx); net_buf_simple_add_mem(&msg, app_key, 16); - err = bt_mesh_client_send_msg(cli->model, OP_APP_KEY_ADD, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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) +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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_BIND, 8); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_MOD_APP_BIND); net_buf_simple_add_le16(&msg, elem_addr); - net_buf_simple_add_le16(&msg, mod_app_idx); + net_buf_simple_add_le16(&msg, app_idx); if (cid != BLE_MESH_CID_NVAL) { net_buf_simple_add_le16(&msg, cid); } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_APP_BIND, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_sub(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid) +static int mod_sub(bt_mesh_client_common_param_t *param, u32_t op, + u16_t elem_addr, u16_t sub_addr, + u16_t mod_id, u16_t cid) { - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 8); - int err = 0; + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 8); bt_mesh_model_msg_init(&msg, op); net_buf_simple_add_le16(&msg, elem_addr); @@ -935,50 +834,42 @@ static int mod_sub(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_add(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t sub_addr, + u16_t mod_id, u16_t cid) { - if (!ctx || !ctx->addr) { + return mod_sub(param, OP_MOD_SUB_ADD, elem_addr, sub_addr, mod_id, 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) +{ + return mod_sub(param, OP_MOD_SUB_DEL, elem_addr, sub_addr, mod_id, 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) +{ + return mod_sub(param, OP_MOD_SUB_OVERWRITE, elem_addr, sub_addr, mod_id, cid); +} + +static int mod_sub_va(bt_mesh_client_common_param_t *param, u32_t op, + u16_t elem_addr, const u8_t label[16], + u16_t mod_id, u16_t cid) +{ + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 22); + + if (!label) { + BT_ERR("Invalid label uuid"); return -EINVAL; } - return mod_sub(OP_MOD_SUB_ADD, ctx, elem_addr, sub_addr, mod_id, 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) -{ - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return mod_sub(OP_MOD_SUB_DEL, ctx, elem_addr, sub_addr, mod_id, 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) -{ - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return mod_sub(OP_MOD_SUB_OVERWRITE, ctx, elem_addr, sub_addr, mod_id, cid); -} - -static int mod_sub_va(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, u16_t cid) -{ - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 22); - int err = 0; - - BT_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x label %s", - ctx->net_idx, ctx->addr, elem_addr, label); + BT_DBG("elem_addr 0x%04x label %s", elem_addr, bt_hex(label, 16)); BT_DBG("mod_id 0x%04x cid 0x%04x", mod_id, cid); bt_mesh_model_msg_init(&msg, op); @@ -989,51 +880,34 @@ static int mod_sub_va(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_add(bt_mesh_client_common_param_t *param, + u16_t elem_addr, const u8_t label[16], + u16_t mod_id, u16_t cid) { - if (!ctx || !ctx->addr || !label) { - return -EINVAL; - } - return mod_sub_va(OP_MOD_SUB_VA_ADD, ctx, elem_addr, label, mod_id, cid); + return mod_sub_va(param, OP_MOD_SUB_VA_ADD, elem_addr, label, mod_id, 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_del(bt_mesh_client_common_param_t *param, + u16_t elem_addr, const u8_t label[16], + u16_t mod_id, u16_t cid) { - if (!ctx || !ctx->addr || !label) { - return -EINVAL; - } - return mod_sub_va(OP_MOD_SUB_VA_DEL, ctx, elem_addr, label, mod_id, cid); + return mod_sub_va(param, OP_MOD_SUB_VA_DEL, elem_addr, label, mod_id, 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) +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) { - if (!ctx || !ctx->addr || !label) { - return -EINVAL; - } - return mod_sub_va(OP_MOD_SUB_VA_OVERWRITE, ctx, elem_addr, label, mod_id, cid); + return mod_sub_va(param, OP_MOD_SUB_VA_OVERWRITE, elem_addr, label, mod_id, 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_get(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t mod_id, u16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_GET, 6); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_MOD_PUB_GET); net_buf_simple_add_le16(&msg, elem_addr); @@ -1042,24 +916,17 @@ int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_PUB_GET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_mod_pub_set(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, struct bt_mesh_cfg_mod_pub *pub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_SET, 13); - int err = 0; - if (!ctx || !ctx->addr || !pub) { + if (!pub) { + BT_ERR("Invalid model pub set"); return -EINVAL; } @@ -1075,23 +942,16 @@ int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_PUB_SET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, struct bt_mesh_cfg_hb_sub *sub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_SET, 5); - int err = 0; - if (!ctx || !ctx->addr || !sub) { + if (!sub) { + BT_ERR("Invalid heartbeat sub set"); return -EINVAL; } @@ -1100,44 +960,21 @@ int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx, net_buf_simple_add_le16(&msg, sub->dst); net_buf_simple_add_u8(&msg, sub->period); - err = bt_mesh_client_send_msg(cli->model, OP_HEARTBEAT_SUB_SET, ctx, - &msg, timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_GET, 0); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_HEARTBEAT_SUB_GET); - - err = bt_mesh_client_send_msg(cli->model, OP_HEARTBEAT_SUB_GET, ctx, - &msg, timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_none(param, OP_HEARTBEAT_SUB_GET); } -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_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_pub *pub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_SET, 9); - int err = 0; - if (!ctx || !ctx->addr || !pub) { + if (!pub) { + BT_ERR("Invalid heartbeat pub set"); return -EINVAL; } @@ -1149,66 +986,28 @@ int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx, net_buf_simple_add_le16(&msg, pub->feat); net_buf_simple_add_le16(&msg, pub->net_idx); - err = bt_mesh_client_send_msg(cli->model, OP_HEARTBEAT_PUB_SET, ctx, - &msg, timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_GET, 0); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_HEARTBEAT_PUB_GET); - - err = bt_mesh_client_send_msg(cli->model, OP_HEARTBEAT_PUB_GET, ctx, - &msg, timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_none(param, OP_HEARTBEAT_PUB_GET); } -int bt_mesh_cfg_node_reset(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_RESET, 0); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_NODE_RESET); - - err = bt_mesh_client_send_msg(cli->model, OP_NODE_RESET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_none(param, OP_NODE_RESET); } -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], +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], struct bt_mesh_cfg_mod_pub *pub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_VA_SET, 27); - int err = 0; - if (!ctx || !ctx->addr || !label || !pub) { + if (!label || !pub) { + BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -1224,25 +1023,13 @@ int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_PUB_VA_SET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_sub_del_all(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t mod_id, u16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_DEL_ALL, 6); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_MOD_SUB_DEL_ALL); net_buf_simple_add_le16(&msg, elem_addr); @@ -1251,21 +1038,13 @@ int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_SUB_DEL_ALL, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_sub_get(u32_t op, struct bt_mesh_msg_ctx *ctx, +static int mod_sub_get(bt_mesh_client_common_param_t *param, u32_t op, u16_t elem_addr, u16_t mod_id, u16_t cid) { - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 6); - int err = 0; + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6); bt_mesh_model_msg_init(&msg, op); net_buf_simple_add_le16(&msg, elem_addr); @@ -1274,39 +1053,32 @@ static int mod_sub_get(u32_t op, struct bt_mesh_msg_ctx *ctx, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_sub_get(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t mod_id) { - if (!ctx || !ctx->addr) { + return mod_sub_get(param, OP_MOD_SUB_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL); +} + +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) +{ + if (cid == BLE_MESH_CID_NVAL) { + BT_ERR("Invalid company id"); return -EINVAL; } - return mod_sub_get(OP_MOD_SUB_GET, ctx, elem_addr, mod_id, BLE_MESH_CID_NVAL); + return mod_sub_get(param, OP_MOD_SUB_GET_VND, elem_addr, mod_id, 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) -{ - if (!ctx || !ctx->addr || cid == BLE_MESH_CID_NVAL) { - return -EINVAL; - } - return mod_sub_get(OP_MOD_SUB_GET_VND, ctx, elem_addr, mod_id, cid); -} - -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_net_key_update(bt_mesh_client_common_param_t *param, + u16_t net_idx, const u8_t net_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_UPDATE, 18); - int err = 0; - if (!ctx || !ctx->addr || !net_key) { + if (!net_key) { + BT_ERR("Invalid NetKey"); return -EINVAL; } @@ -1314,66 +1086,27 @@ int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, net_buf_simple_add_le16(&msg, net_idx); net_buf_simple_add_mem(&msg, net_key, 16); - err = bt_mesh_client_send_msg(cli->model, OP_NET_KEY_UPDATE, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx) +int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_DEL, 2); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_NET_KEY_DEL); - net_buf_simple_add_le16(&msg, net_idx); - - err = bt_mesh_client_send_msg(cli->model, OP_NET_KEY_DEL, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_le16(param, OP_NET_KEY_DEL, net_idx); } -int bt_mesh_cfg_net_key_get(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_GET, 0); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_NET_KEY_GET); - - err = bt_mesh_client_send_msg(cli->model, OP_NET_KEY_GET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_none(param, OP_NET_KEY_GET); } -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_app_key_update(bt_mesh_client_common_param_t *param, + u16_t net_idx, u16_t app_idx, + const u8_t app_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_UPDATE, 19); - int err = 0; - if (!ctx || !ctx->addr || !app_key) { + if (!app_key) { + BT_ERR("Invalid AppKey"); return -EINVAL; } @@ -1381,106 +1114,52 @@ int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, key_idx_pack(&msg, net_idx, app_idx); net_buf_simple_add_mem(&msg, app_key, 16); - err = bt_mesh_client_send_msg(cli->model, OP_APP_KEY_UPDATE, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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_delete(bt_mesh_client_common_param_t *param, + u16_t net_idx, u16_t app_idx) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_DEL, 3); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_APP_KEY_DEL); key_idx_pack(&msg, net_idx, app_idx); - err = bt_mesh_client_send_msg(cli->model, OP_APP_KEY_DEL, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_app_key_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx) +int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_GET, 2); - int err = 0; + return send_msg_with_le16(param, OP_APP_KEY_GET, net_idx); +} - if (!ctx || !ctx->addr) { +int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx) +{ + return send_msg_with_le16(param, OP_NODE_IDENTITY_GET, net_idx); +} + +int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, + u16_t net_idx, u8_t identity) +{ + BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_SET, 3); + + if (identity > 0x02) { + BT_ERR("Invalid node identity 0x%02x", identity); return -EINVAL; } - bt_mesh_model_msg_init(&msg, OP_APP_KEY_GET); + bt_mesh_model_msg_init(&msg, OP_NODE_IDENTITY_SET); net_buf_simple_add_le16(&msg, net_idx); + net_buf_simple_add_u8(&msg, identity); - err = bt_mesh_client_send_msg(cli->model, OP_APP_KEY_GET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int node_identity_op(u32_t op, struct bt_mesh_msg_ctx *ctx, - u16_t net_idx, u8_t identity) -{ - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 3); - int err = 0; - - bt_mesh_model_msg_init(&msg, op); - net_buf_simple_add_le16(&msg, net_idx); - if (op == OP_NODE_IDENTITY_SET) { - net_buf_simple_add_u8(&msg, identity); - } - - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; -} - -int bt_mesh_cfg_node_identity_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx) -{ - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return node_identity_op(OP_NODE_IDENTITY_GET, ctx, net_idx, 0xFF); -} - -int bt_mesh_cfg_node_identity_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t identity) -{ - if (!ctx || !ctx->addr || identity > 0x01) { - return -EINVAL; - } - return node_identity_op(OP_NODE_IDENTITY_SET, ctx, net_idx, 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_unbind(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t app_idx, + u16_t mod_id, u16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_UNBIND, 8); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } bt_mesh_model_msg_init(&msg, OP_MOD_APP_UNBIND); net_buf_simple_add_le16(&msg, elem_addr); @@ -1490,21 +1169,13 @@ int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, OP_MOD_APP_UNBIND, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_app_get(u32_t op, struct bt_mesh_msg_ctx *ctx, +static int mod_app_get(bt_mesh_client_common_param_t *param, u32_t op, u16_t elem_addr, u16_t mod_id, u16_t cid) { - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 6); - int err = 0; + BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6); bt_mesh_model_msg_init(&msg, op); net_buf_simple_add_le16(&msg, elem_addr); @@ -1513,131 +1184,74 @@ static int mod_app_get(u32_t op, struct bt_mesh_msg_ctx *ctx, } net_buf_simple_add_le16(&msg, mod_id); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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(bt_mesh_client_common_param_t *param, + u16_t elem_addr, u16_t mod_id) { - if (!ctx || !ctx->addr) { + return mod_app_get(param, OP_SIG_MOD_APP_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL); +} + +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) +{ + if (cid == BLE_MESH_CID_NVAL) { + BT_ERR("Invalid company id"); return -EINVAL; } - return mod_app_get(OP_SIG_MOD_APP_GET, ctx, elem_addr, mod_id, BLE_MESH_CID_NVAL); + return mod_app_get(param, OP_VND_MOD_APP_GET, elem_addr, mod_id, cid); } -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(bt_mesh_client_common_param_t *param, u16_t net_idx) { - if (!ctx || !ctx->addr || cid == BLE_MESH_CID_NVAL) { + return send_msg_with_le16(param, OP_KRP_GET, net_idx); +} + +int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, + u16_t net_idx, u8_t transition) +{ + BLE_MESH_MODEL_BUF_DEFINE(msg, OP_KRP_SET, 3); + + if (transition > 0x03) { + BT_ERR("Invalid kr phase transition 0x%02x", transition); return -EINVAL; } - return mod_app_get(OP_VND_MOD_APP_GET, ctx, elem_addr, mod_id, cid); -} -static int kr_phase_op(u32_t op, struct bt_mesh_msg_ctx *ctx, - u16_t net_idx, u8_t transition) -{ - BLE_MESH_MODEL_BUF_DEFINE(msg, DUMMY_2_BYTE_OP, 3); - int err = 0; - - bt_mesh_model_msg_init(&msg, op); + bt_mesh_model_msg_init(&msg, OP_KRP_SET); net_buf_simple_add_le16(&msg, net_idx); - if (op == OP_KRP_SET) { - net_buf_simple_add_u8(&msg, transition); - } + net_buf_simple_add_u8(&msg, transition); - err = bt_mesh_client_send_msg(cli->model, op, ctx, &msg, timeout_handler, - config_msg_timeout, true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_kr_phase_get(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) { - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return kr_phase_op(OP_KRP_GET, ctx, net_idx, 0xFF); + return send_msg_with_le16(param, OP_LPN_TIMEOUT_GET, lpn_addr); } -int bt_mesh_cfg_kr_phase_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t transition) +int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param) { - if (!ctx || !ctx->addr || transition > 0x03) { - return -EINVAL; - } - return kr_phase_op(OP_KRP_SET, ctx, net_idx, transition);; + return send_msg_with_none(param, OP_NET_TRANSMIT_GET); } -int bt_mesh_cfg_lpn_timeout_get(struct bt_mesh_msg_ctx *ctx, u16_t lpn_addr) +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit) { - BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_GET, 2); - int err = 0; - - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - bt_mesh_model_msg_init(&msg, OP_LPN_TIMEOUT_GET); - net_buf_simple_add_le16(&msg, lpn_addr); - - err = bt_mesh_client_send_msg(cli->model, OP_LPN_TIMEOUT_GET, ctx, &msg, - timeout_handler, config_msg_timeout, - true, NULL, NULL); - if (err) { - BT_ERR("%s, send failed (err %d)", __func__, err); - } - - return err; + return send_msg_with_u8(param, OP_NET_TRANSMIT_SET, transmit); } -int bt_mesh_cfg_net_transmit_get(struct bt_mesh_msg_ctx *ctx) -{ - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return get_state_u8(ctx, OP_NET_TRANSMIT_GET); -} - -int bt_mesh_cfg_net_transmit_set(struct bt_mesh_msg_ctx *ctx, u8_t transmit) -{ - if (!ctx || !ctx->addr) { - return -EINVAL; - } - return set_state_u8(ctx, OP_NET_TRANSMIT_SET, transmit); -} - -s32_t bt_mesh_cfg_cli_timeout_get(void) -{ - return config_msg_timeout; -} - -void bt_mesh_cfg_cli_timeout_set(s32_t timeout) -{ - config_msg_timeout = timeout; -} - -int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary) +static int cfg_cli_init(struct bt_mesh_model *model) { config_internal_data_t *internal = NULL; bt_mesh_config_client_t *client = NULL; - BT_DBG("primary %u", primary); - - if (!primary) { - BT_ERR("Configuration Client only allowed in primary element"); + if (!model) { + BT_ERR("Invalid Configuration Client model"); return -EINVAL; } - if (!model) { - BT_ERR("Configuration Client model is NULL"); + if (!bt_mesh_model_in_primary(model)) { + BT_ERR("Configuration Client only allowed in primary element"); return -EINVAL; } @@ -1664,8 +1278,6 @@ int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary) bt_mesh_client_clear_list(client->internal_data); } - cli = client; - /* Configuration Model security is device-key based */ model->keys[0] = BLE_MESH_KEY_DEV; @@ -1674,17 +1286,17 @@ int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary) +static int cfg_cli_deinit(struct bt_mesh_model *model) { bt_mesh_config_client_t *client = NULL; - if (!primary) { - BT_ERR("Configuration Client only allowed in primary element"); + if (!model) { + BT_ERR("Invalid Configuration Client model"); return -EINVAL; } - if (!model) { - BT_ERR("Configuration Client model is NULL"); + if (!bt_mesh_model_in_primary(model)) { + BT_ERR("Configuration Client only allowed in primary element"); return -EINVAL; } @@ -1700,12 +1312,15 @@ int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary) /* Free the allocated internal data */ bt_mesh_free(client->internal_data); - cli->internal_data = NULL; + client->internal_data = NULL; } - client = NULL; - bt_mesh_cfg_client_mutex_free(); return 0; } + +const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = { + .init = cfg_cli_init, + .deinit = cfg_cli_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index 46b4a524e..0f6429cd6 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -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("%s, Too large device composition", __func__); + BT_ERR("Too large device composition"); 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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of 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("%s, Unable to get composition page 0", __func__); + BT_ERR("Unable to get composition page 0"); bt_mesh_free_buf(sdu); return; } if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) { - BT_ERR("%s, Unable to send Config Composition Data Status", __func__); + BT_ERR("Unable to send Config Composition Data Status"); } 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("%s, Unable to send Config AppKey Status", __func__); + BT_ERR("Unable to send Config AppKey Status"); 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("%s, Unable to send Config AppKey Status", __func__); + BT_ERR("Unable to send Config AppKey Status"); } 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("%s, Unable to send Config AppKey Status", __func__); + BT_ERR("Unable to send Config AppKey Status"); } 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("%s, Invalid NetKeyIndex 0x%04x", __func__, get_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Unable to send Config AppKey List", __func__); + BT_ERR("Unable to send Config AppKey List"); } } @@ -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("%s, Unable to send Config Beacon Status", __func__); + BT_ERR("Unable to send Config Beacon Status"); } } @@ -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("%s, Unable to send Config Beacon Status", __func__); + BT_ERR("Unable to send Config Beacon Status"); } } @@ -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("%s, Unable to send Config Default TTL Status", __func__); + BT_ERR("Unable to send Config Default TTL Status"); } } @@ -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("%s, Unable to send Config Default TTL Status", __func__); + BT_ERR("Unable to send Config Default TTL Status"); } } @@ -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("%s, Unable to send Config GATT Proxy Status", __func__); + BT_ERR("Unable to send Config GATT Proxy Status"); } } @@ -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("%s, Unable to send Config Network Transmit Status", __func__); + BT_ERR("Unable to send Config Network Transmit Status"); } } @@ -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("%s, Unable to send Config Network Transmit Status", __func__); + BT_ERR("Unable to send Config Network Transmit Status"); } } @@ -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("%s, Unable to send Config Relay Status", __func__); + BT_ERR("Unable to send Config Relay Status"); } } @@ -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("%s, Unable to send Config Relay Status", __func__); + BT_ERR("Unable to send Config Relay Status"); } } @@ -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("%s, Unable to send Config Model Publication Status", __func__); + BT_ERR("Unable to send Config Model Publication Status"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Invalid TTL value 0x%02x", __func__, pub_ttl); + BT_ERR("Invalid TTL value 0x%02x", 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("%s, Label UUID not found", __func__); + BT_ERR("Label UUID not found"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Invalid TTL value 0x%02x", __func__, pub_ttl); + BT_ERR("Invalid TTL value 0x%02x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Unable to send Config Model Subscription Status", __func__); + BT_ERR("Unable to send Config Model Subscription Status"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Unable to send Config Model Subscription List", __func__); + BT_ERR("Unable to send Config Model Subscription List"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Unable to send Config Vendor Model Subscription List", __func__); + BT_ERR("Unable to send Config Vendor Model Subscription List"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Unable to send Config NetKey Status", __func__); + BT_ERR("Unable to send Config NetKey Status"); } } @@ -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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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_beacon_send(sub); + bt_mesh_proxy_server_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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Invalid NetKeyIndex 0x%04x", __func__, del_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Unable to send Config NetKey List", __func__); + BT_ERR("Unable to send Config NetKey List"); } } @@ -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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Unable to send Config Node Identity Status", __func__); + BT_ERR("Unable to send Config Node Identity Status"); } } @@ -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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_WARN("Invalid NetKeyIndex 0x%04x", idx); return; } node_id = net_buf_simple_pull_u8(buf); if (node_id != 0x00 && node_id != 0x01) { - BT_WARN("%s, Invalid Node ID value 0x%02x", __func__, node_id); + BT_WARN("Invalid Node ID value 0x%02x", 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_identity_start(sub); + bt_mesh_proxy_server_identity_start(sub); } else { - bt_mesh_proxy_identity_stop(sub); + bt_mesh_proxy_server_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("%s, Unable to send Config Node Identity Status", __func__); + BT_ERR("Unable to send Config Node Identity Status"); } } @@ -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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", 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("%s, Client tried to bind AppKey to Configuration Model", __func__); + BT_ERR("Client tried to bind AppKey to Configuration Model"); 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("%s, Unable to send Config Model App Bind Status", __func__); + BT_ERR("Unable to send Config Model App Bind Status"); } 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", elem_addr); return; } @@ -2609,7 +2609,7 @@ send_status: mod_id); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("%s, Unable to send Config Model App Unbind Status", __func__); + BT_ERR("Unable to send Config Model App Unbind Status"); } 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("%s, Prohibited element address 0x%04x", __func__, elem_addr); + BT_ERR("Prohibited element address 0x%04x", elem_addr); return; } @@ -2693,7 +2693,7 @@ send_list: } if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { - BT_ERR("%s, Unable to send Config Model Application List", __func__); + BT_ERR("Unable to send Config Model Application List"); } } @@ -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("%s, Unable to send Config Node Reset Status", __func__); + BT_ERR("Unable to send Config Node Reset Status"); } 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("%s, Unable to send Config Friend Status", __func__); + BT_ERR("Unable to send Config Friend Status"); } } @@ -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("%s, Unable to send Config LPN PollTimeout Status", __func__); + BT_ERR("Unable to send Config LPN PollTimeout Status"); } } @@ -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("%s, Unable to send Config Key Refresh Phase Status", __func__); + BT_ERR("Unable to send Config Key Refresh Phase Status"); } } @@ -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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", 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("%s, Prohibited transition %u -> %u", __func__, sub->kr_phase, phase); + BT_WARN("Prohibited transition %u -> %u", sub->kr_phase, phase); return; } @@ -2912,17 +2912,25 @@ 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); } @@ -3007,7 +3015,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("%s, Unable to send Config Heartbeat Publication Status", __func__); + BT_ERR("Unable to send Config Heartbeat Publication Status"); } } @@ -3049,7 +3057,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("%s, Invalid TTL value 0x%02x", __func__, param->ttl); + BT_ERR("Invalid TTL value 0x%02x", param->ttl); return; } @@ -3057,7 +3065,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model, idx = sys_le16_to_cpu(param->net_idx); if (idx > 0xfff) { - BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", idx); return; } @@ -3146,7 +3154,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("%s, Unable to send Config Heartbeat Subscription Status", __func__); + BT_ERR("Unable to send Config Heartbeat Subscription Status"); } } @@ -3305,8 +3313,8 @@ static void hb_publish(struct k_work *work) sub = bt_mesh_subnet_get(cfg->hb_pub.net_idx); if (!sub) { - BT_ERR("%s, No matching subnet for idx 0x%02x", - __func__, cfg->hb_pub.net_idx); + BT_ERR("No matching subnet for idx 0x%04x", + cfg->hb_pub.net_idx); cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED; return; } @@ -3344,17 +3352,22 @@ static bool conf_is_valid(struct bt_mesh_cfg_srv *cfg) return true; } -int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary) +static int cfg_srv_init(struct bt_mesh_model *model) { 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("%s, No Configuration Server context provided", __func__); + BT_ERR("No Configuration Server context provided"); return -EINVAL; } if (!conf_is_valid(cfg)) { - BT_ERR("%s, Invalid values in configuration", __func__); + BT_ERR("Invalid values in configuration"); return -EINVAL; } @@ -3384,16 +3397,24 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary) +static int cfg_srv_deinit(struct bt_mesh_model *model) { struct bt_mesh_cfg_srv *cfg = model->user_data; - if (!cfg) { - BT_ERR("%s, No Configuration Server context provided", __func__); + if (!bt_mesh_model_in_primary(model)) { + BT_ERR("Configuration Server only allowed in primary element"); return -EINVAL; } - bt_mesh_cfg_reset(); + if (!cfg) { + BT_ERR("No Configuration Server context provided"); + 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); k_delayed_work_free(&cfg->hb_pub.timer); cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED; @@ -3403,9 +3424,15 @@ int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary) 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 @@ -3416,12 +3443,17 @@ 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) { + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && clear_count && store) { bt_mesh_store_mod_sub(mod); } } -void bt_mesh_cfg_reset(void) +void bt_mesh_mod_sub_reset(bool store) +{ + bt_mesh_model_foreach(mod_reset, &store); +} + +void bt_mesh_cfg_reset(bool store) { struct bt_mesh_cfg_srv *cfg = conf; int i; @@ -3445,11 +3477,11 @@ void bt_mesh_cfg_reset(void) struct bt_mesh_subnet *sub = &bt_mesh.sub[i]; if (sub->net_idx != BLE_MESH_KEY_UNUSED) { - bt_mesh_subnet_del(sub, true); + bt_mesh_subnet_del(sub, store); } } - bt_mesh_model_foreach(mod_reset, NULL); + bt_mesh_mod_sub_reset(store); (void)memset(labels, 0, sizeof(labels)); } diff --git a/components/bt/esp_ble_mesh/mesh_core/crypto.c b/components/bt/esp_ble_mesh/mesh_core/crypto.c index d1d94e167..c266b279b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/crypto.c +++ b/components/bt/esp_ble_mesh/mesh_core/crypto.c @@ -13,9 +13,12 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_CRYPTO) -#include "mesh_common.h" +#include +#include +#include + #include "crypto.h" -#include "mesh_aes_encrypt.h" +#include "mesh_common.h" #include "mesh_bearer_adapt.h" #define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4) diff --git a/components/bt/esp_ble_mesh/mesh_core/crypto.h b/components/bt/esp_ble_mesh/mesh_core/crypto.h index feed22613..147d85673 100644 --- a/components/bt/esp_ble_mesh/mesh_core/crypto.h +++ b/components/bt/esp_ble_mesh/mesh_core/crypto.h @@ -59,7 +59,7 @@ int bt_mesh_k4(const u8_t n[16], u8_t out[1]); int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16]); static inline int bt_mesh_id_resolving_key(const u8_t net_key[16], - u8_t resolving_key[16]) + u8_t resolving_key[16]) { return bt_mesh_k1_str(net_key, 16, "smbt", "smbi", resolving_key); } diff --git a/components/bt/esp_ble_mesh/mesh_core/fast_prov.c b/components/bt/esp_ble_mesh/mesh_core/fast_prov.c new file mode 100644 index 000000000..f7cb529ca --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_core/fast_prov.c @@ -0,0 +1,190 @@ +// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "mesh.h" +#include "mesh_common.h" +#include "access.h" +#include "beacon.h" +#include "foundation.h" +#include "proxy_client.h" +#include "provisioner_prov.h" +#include "provisioner_main.h" + +#if CONFIG_BLE_MESH_FAST_PROV + +#define ACTION_ENTER 0x01 +#define ACTION_SUSPEND 0x02 +#define ACTION_EXIT 0x03 + +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); + return NULL; + } + + if (dst == bt_mesh_primary_addr()) { + return bt_mesh.dev_key; + } + + return bt_mesh_provisioner_dev_key_get(dst); +} + +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx) +{ + struct bt_mesh_subnet *sub = NULL; + int i; + + for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) { + sub = &bt_mesh.sub[i]; + if (sub->net_idx == net_idx) { + return sub; + } + } + + for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) { + sub = bt_mesh.p_sub[i]; + if (sub && sub->net_idx == net_idx) { + return sub; + } + } + + return NULL; +} + +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx) +{ + struct bt_mesh_app_key *key = NULL; + int i; + + for (i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) { + key = &bt_mesh.app_keys[i]; + if (key->net_idx != BLE_MESH_KEY_UNUSED && + key->app_idx == app_idx) { + return key; + } + } + + for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) { + key = bt_mesh.p_app_keys[i]; + if (key && key->net_idx != BLE_MESH_KEY_UNUSED && + key->app_idx == app_idx) { + return key; + } + } + + return NULL; +} + +u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx) +{ + /* Set net_idx for fast provisioning */ + bt_mesh_provisioner_set_fast_prov_net_idx(net_idx); + + if (bt_mesh_fast_prov_subnet_get(net_idx) == NULL) { + /* If NetKey is not found, wait for NetKey to be added. */ + BT_WARN("Wait for NetKey for fast provisioning"); + return 0x01; /*status: Wait for NetKey */ + } + + return 0x0; /* status: Succeed */ +} + +u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]) +{ + u16_t net_idx = 0U; + int err = 0; + + net_idx = bt_mesh_provisioner_get_fast_prov_net_idx(); + bt_mesh.p_net_idx_next = net_idx; + + err = bt_mesh_provisioner_local_net_key_add(net_key, &net_idx); + if (err) { + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); + return 0x01; /* status: Add NetKey failed */ + }; + + bt_mesh_provisioner_set_fast_prov_net_idx(net_idx); + return 0x0; /* status: Succeed */ +} + +const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx) +{ + struct bt_mesh_subnet *sub = NULL; + + sub = bt_mesh_fast_prov_subnet_get(net_idx); + if (!sub) { + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); + return NULL; + } + + return (sub->kr_flag ? sub->keys[1].net : sub->keys[0].net); +} + +const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx) +{ + struct bt_mesh_app_key *key = NULL; + + key = bt_mesh_fast_prov_app_key_find(app_idx); + if (!key) { + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); + return NULL; + } + + return (key->updated ? key->keys[1].val : key->keys[0].val); +} + +u8_t bt_mesh_set_fast_prov_action(u8_t action) +{ + if (!action || action > ACTION_EXIT) { + return 0x01; + } + + if ((!bt_mesh_is_provisioner_en() && (action == ACTION_SUSPEND || action == ACTION_EXIT)) || + (bt_mesh_is_provisioner_en() && (action == ACTION_ENTER))) { + BT_WARN("%s, Already", __func__); + return 0x0; + } + + if (action == ACTION_ENTER) { + if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { + bt_mesh_beacon_disable(); + } + if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { + bt_mesh_proxy_client_prov_enable(); + } + bt_mesh_provisioner_set_primary_elem_addr(bt_mesh_primary_addr()); + bt_mesh_provisioner_set_prov_bearer(BLE_MESH_PROV_ADV, false); + bt_mesh_provisioner_fast_prov_enable(true); + 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(); + } + if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { + bt_mesh_beacon_enable(); + } + bt_mesh_atomic_and(bt_mesh.flags, ~(BIT(BLE_MESH_PROVISIONER) | BIT(BLE_MESH_VALID_PROV))); + bt_mesh_provisioner_fast_prov_enable(false); + if (action == ACTION_EXIT) { + bt_mesh_provisioner_remove_node(NULL); + } + } + + return 0x0; +} +#endif /* CONFIG_BLE_MESH_FAST_PROV */ diff --git a/components/bt/esp_ble_mesh/mesh_core/fast_prov.h b/components/bt/esp_ble_mesh/mesh_core/fast_prov.h new file mode 100644 index 000000000..9ab6fc4be --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_core/fast_prov.h @@ -0,0 +1,44 @@ +// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _FAST_PROV_H_ +#define _FAST_PROV_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst); + +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx); + +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx); + +u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx); + +u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]); + +const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx); + +const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx); + +u8_t bt_mesh_set_fast_prov_action(u8_t action); + +#ifdef __cplusplus +} +#endif + +#endif /* _FAST_PROV_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_core/foundation.h b/components/bt/esp_ble_mesh/mesh_core/foundation.h index 76634079e..f766fc9c3 100644 --- a/components/bt/esp_ble_mesh/mesh_core/foundation.h +++ b/components/bt/esp_ble_mesh/mesh_core/foundation.h @@ -132,19 +132,9 @@ struct label { bt_mesh_atomic_t flags[1]; }; -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_mod_sub_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_cfg_reset(bool store); void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat); diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.c b/components/bt/esp_ble_mesh/mesh_core/friend.c index 0c714bc9b..b9955709a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.c +++ b/components/bt/esp_ble_mesh/mesh_core/friend.c @@ -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("%s, Too short Friend Clear", __func__); + BT_WARN("Too short Friend Clear (len %d)", buf->len); 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("%s, No matching LPN addr 0x%04x", __func__, lpn_addr); + BT_WARN("No matching LPN addr 0x%04x", 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("%s, LPN Counter out of range (old %u new %u)", - __func__, frnd->lpn_counter, lpn_counter); + BT_WARN("LPN Counter out of range (old %u new %u)", + 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("%s, No space in friend subscription list", __func__); + BT_WARN("No space in friend subscription list"); } static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr) @@ -559,7 +559,10 @@ 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); - __ASSERT_NO_MSG(sub != NULL); + if (!sub) { + BT_ERR("Friend subnet 0x%04x not found", frnd->net_idx); + return NULL; + } BT_DBG("lpn 0x%04x md 0x%02x", frnd->lpn, md); @@ -588,7 +591,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("%s, Unable to encode Subscription List Confirmation", __func__); + BT_ERR("Unable to encode Subscription List Confirmation"); return; } @@ -619,18 +622,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("%s, Too short Friend Subscription Add", __func__); + BT_WARN("Too short Friend Subscription Add (len %d)", buf->len); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true); if (!frnd) { - BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr); + BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (frnd->pending_buf) { - BT_WARN("%s, Previous buffer not yet sent!", __func__); + BT_WARN("Previous buffer not yet sent!"); return 0; } @@ -654,18 +657,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("%s, Too short Friend Subscription Remove", __func__); + BT_WARN("Too short Friend Subscription Remove (len %d)", buf->len); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true); if (!frnd) { - BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr); + BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (frnd->pending_buf) { - BT_WARN("%s, Previous buffer not yet sent!", __func__); + BT_WARN("Previous buffer not yet sent!"); return 0; } @@ -694,7 +697,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md) buf = encode_update(frnd, md); if (!buf) { - BT_ERR("%s, Unable to encode Friend Update", __func__); + BT_ERR("Unable to encode Friend Update"); return; } @@ -708,23 +711,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("%s, Too short Friend Poll", __func__); + BT_WARN("Too short Friend Poll (len %d)", buf->len); return -EINVAL; } frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false); if (!frnd) { - BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr); + BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr); return 0; } if (msg->fsn & ~1) { - BT_WARN("%s, Prohibited (non-zero) padding bits", __func__); + BT_WARN("Prohibited (non-zero) padding bits"); return -EINVAL; } if (frnd->pending_buf) { - BT_WARN("%s, Previous buffer not yet sent!", __func__); + BT_WARN("Previous buffer not yet sent!"); return 0; } @@ -856,27 +859,27 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, BT_DBG("%s", __func__); if (buf->len < sizeof(*msg)) { - BT_WARN("%s, Too short Friend Clear Confirm", __func__); + BT_WARN("Too short Friend Clear Confirm (len %d)", buf->len); return -EINVAL; } frnd = find_clear(rx->ctx.addr); if (!frnd) { - BT_WARN("%s, No pending clear procedure for 0x%02x", __func__, rx->ctx.addr); + BT_WARN("No pending clear procedure for 0x%02x", rx->ctx.addr); return 0; } lpn_addr = sys_be16_to_cpu(msg->lpn_addr); if (lpn_addr != frnd->lpn) { - BT_WARN("%s, LPN address mismatch (0x%04x != 0x%04x)", - __func__, lpn_addr, frnd->lpn); + BT_WARN("LPN address mismatch (0x%04x != 0x%04x)", + lpn_addr, frnd->lpn); return 0; } lpn_counter = sys_be16_to_cpu(msg->lpn_counter); if (lpn_counter != frnd->lpn_counter) { - BT_WARN("%s, LPN counter mismatch (0x%04x != 0x%04x)", - __func__, lpn_counter, frnd->lpn_counter); + BT_WARN("LPN counter mismatch (0x%04x != 0x%04x)", + lpn_counter, frnd->lpn_counter); return 0; } @@ -906,7 +909,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("%s, Unable to encode Friend Offer", __func__); + BT_ERR("Unable to encode Friend Offer"); return; } @@ -964,47 +967,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("%s, Too short Friend Request", __func__); + BT_WARN("Too short Friend Request (len %d)", buf->len); return -EINVAL; } if (msg->recv_delay <= 0x09) { - BT_WARN("%s, Prohibited ReceiveDelay (0x%02x)", __func__, msg->recv_delay); + BT_WARN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay); return -EINVAL; } poll_to = sys_get_be24(msg->poll_to); if (poll_to <= 0x000009 || poll_to >= 0x34bc00) { - BT_WARN("%s, Prohibited PollTimeout (0x%06x)", __func__, poll_to); + BT_WARN("Prohibited PollTimeout (0x%06x)", poll_to); return -EINVAL; } if (msg->num_elem == 0x00) { - BT_WARN("%s, Prohibited NumElements value (0x00)", __func__); + BT_WARN("Prohibited NumElements value (0x00)"); return -EINVAL; } if (!BLE_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) { - BT_WARN("%s, LPN elements stretch outside of unicast range", __func__); + BT_WARN("LPN elements stretch outside of unicast range"); return -EINVAL; } if (!MIN_QUEUE_SIZE_LOG(msg->criteria)) { - BT_WARN("%s, Prohibited Minimum Queue Size in Friend Request", __func__); + BT_WARN("Prohibited Minimum Queue Size in Friend Request"); return -EINVAL; } if (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) { - BT_WARN("%s, We have a too small Friend Queue size (%u < %u)", - __func__, CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE, + BT_WARN("We have a too small Friend Queue size (%u < %u)", + 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("%s, Existing LPN re-requesting Friendship", __func__); + BT_WARN("Existing LPN re-requesting Friendship"); friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_RECV_FRND_REQ); goto init_friend; } @@ -1018,7 +1021,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } if (!frnd) { - BT_WARN("%s, No free Friend contexts for new LPN", __func__); + BT_WARN("No free Friend contexts for new LPN"); return -ENOMEM; } @@ -1194,7 +1197,10 @@ static void friend_timeout(struct k_work *work) .end = buf_send_end, }; - __ASSERT_NO_MSG(frnd->pending_buf == 0U); + if (frnd->pending_buf != 0U) { + BT_ERR("Previous buffer not yet sent!"); + return; + } BT_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn, frnd->send_last, frnd->last); @@ -1206,14 +1212,14 @@ static void friend_timeout(struct k_work *work) } if (frnd->established && !frnd->pending_req) { - BT_WARN("%s, Friendship lost with 0x%04x", __func__, frnd->lpn); + BT_WARN("Friendship lost with 0x%04x", 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("%s, Friendship not established with 0x%04x", __func__, frnd->lpn); + BT_WARN("Friendship not established with 0x%04x", frnd->lpn); friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL); return; } @@ -1400,7 +1406,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, buf = create_friend_pdu(frnd, &info, sbuf); if (!buf) { - BT_ERR("%s, Failed to encode Friend buffer", __func__); + BT_ERR("Failed to encode Friend buffer"); return; } @@ -1437,7 +1443,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, buf = create_friend_pdu(frnd, &info, sbuf); if (!buf) { - BT_ERR("%s, Failed to encode Friend buffer", __func__); + BT_ERR("Failed to encode Friend buffer"); return; } @@ -1695,7 +1701,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src, continue; } - BT_WARN("%s, Clearing incomplete segments for 0x%04x", __func__, src); + BT_WARN("Clearing incomplete segments for 0x%04x", src); purge_buffers(&seg->queue); seg->seg_count = 0U; diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index bceb45047..07c0c0cc3 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_cli.c @@ -18,10 +18,6 @@ #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 }, @@ -85,9 +81,9 @@ static void timeout_handler(struct k_work *work) return; } -static void health_client_cancel(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - void *status, size_t len) +static void health_client_recv_status(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + void *status, size_t len) { bt_mesh_client_node_t *node = NULL; struct net_buf_simple buf = {0}; @@ -106,7 +102,7 @@ static void health_client_cancel(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true); if (!node) { - BT_DBG("Unexpected health status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Health Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case OP_HEALTH_FAULT_GET: @@ -136,8 +132,12 @@ static void health_client_cancel(struct bt_mesh_model *model, switch (ctx->recv_op) { case OP_HEALTH_FAULT_STATUS: { - struct bt_mesh_health_fault_status *val; - val = (struct bt_mesh_health_fault_status *)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; bt_mesh_free_buf(val->fault_array); break; } @@ -160,40 +160,36 @@ 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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } net_buf_simple_add_mem(status.fault_array, buf->data, buf->len); - health_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_health_fault_status)); + health_client_recv_status(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) { - bt_mesh_client_node_t *node = NULL; - u8_t test_id = 0U; - u16_t cid = 0U; + struct bt_mesh_health_current_status status = {0}; 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)); - /* 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))) { + 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__); return; } - test_id = net_buf_simple_pull_u8(buf); - cid = net_buf_simple_pull_le16(buf); + net_buf_simple_add_mem(status.fault_array, buf->data, buf->len); - BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u", - test_id, cid, buf->len); - - ((void) test_id); - ((void) cid); + health_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_health_current_status)); } static void health_period_status(struct bt_mesh_model *model, @@ -208,7 +204,7 @@ static void health_period_status(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - health_client_cancel(model, ctx, &status, sizeof(u8_t)); + health_client_recv_status(model, ctx, &status, sizeof(u8_t)); } static void health_attention_status(struct bt_mesh_model *model, @@ -223,7 +219,7 @@ static void health_attention_status(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - health_client_cancel(model, ctx, &status, sizeof(u8_t)); + health_client_recv_status(model, ctx, &status, sizeof(u8_t)); } const struct bt_mesh_model_op bt_mesh_health_cli_op[] = { @@ -234,231 +230,101 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param) { 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); - 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); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, u8_t attention, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1); - u32_t opcode = 0U; - int err = 0; - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - if (need_ack) { - opcode = OP_ATTENTION_SET; - } else { - opcode = OP_ATTENTION_SET_UNREL; - } - bt_mesh_model_msg_init(&msg, opcode); + bt_mesh_model_msg_init(&msg, need_ack ? OP_ATTENTION_SET : OP_ATTENTION_SET_UNREL); 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; + return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler); } -int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx) +int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param) { 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); - 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); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, u8_t divisor, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1); - u32_t opcode = 0U; - int err = 0; - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - if (need_ack) { - opcode = OP_HEALTH_PERIOD_SET; - } else { - opcode = OP_HEALTH_PERIOD_SET_UNREL; - } - bt_mesh_model_msg_init(&msg, opcode); + bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_PERIOD_SET : OP_HEALTH_PERIOD_SET_UNREL); 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; + return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler); } -int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, 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; - 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); + bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_TEST : OP_HEALTH_FAULT_TEST_UNREL); net_buf_simple_add_u8(&msg, test_id); 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; + return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler); } -int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, u16_t cid, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2); - u32_t opcode = 0U; - int err = 0; - if (!ctx || !ctx->addr) { - return -EINVAL; - } - - if (need_ack) { - opcode = OP_HEALTH_FAULT_CLEAR; - } else { - opcode = OP_HEALTH_FAULT_CLEAR_UNREL; - } - bt_mesh_model_msg_init(&msg, opcode); + bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_CLEAR : OP_HEALTH_FAULT_CLEAR_UNREL); 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; + return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler); } -int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid) +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, 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); - 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); - } - - return err; + return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -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) +static int health_cli_init(struct bt_mesh_model *model) { health_internal_data_t *internal = NULL; bt_mesh_health_client_t *client = NULL; - BT_DBG("primary %u", primary); - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Health Client model"); 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("%s, No Health Client context provided", __func__); + BT_ERR("No Health Client context provided"); return -EINVAL; } if (!client->internal_data) { internal = bt_mesh_calloc(sizeof(health_internal_data_t)); if (!internal) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -474,26 +340,23 @@ int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary) bt_mesh_health_client_mutex_new(); - /* Set the default health client pointer */ - if (!health_cli) { - health_cli = client; - } - return 0; } -int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary) +static int health_cli_deinit(struct bt_mesh_model *model) { bt_mesh_health_client_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Health Client model"); 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("%s, No Health Client context provided", __func__); + BT_ERR("No Health Client context provided"); return -EINVAL; } @@ -508,9 +371,10 @@ int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary) bt_mesh_health_client_mutex_free(); - if (health_cli) { - health_cli = NULL; - } - return 0; } + +const struct bt_mesh_model_cb bt_mesh_health_cli_cb = { + .init = health_cli_init, + .deinit = health_cli_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_core/health_srv.c b/components/bt/esp_ble_mesh/mesh_core/health_srv.c index ccf18b368..e37ff6943 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_srv.c @@ -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, Failed to allocate memory", __func__); + BT_ERR("%s, Out of 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("%s, Failed to send Health Fault Status response", __func__); + BT_ERR("Failed to send Health Fault Status response"); } 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("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); return; } company_id = net_buf_simple_pull_le16(buf); if (company_id != srv->test.company_id) { - BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id); + BT_ERR("Unknown Company ID 0x%04x", 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("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); return; } company_id = net_buf_simple_pull_le16(buf); if (company_id != srv->test.company_id) { - BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id); + BT_ERR("Unknown Company ID 0x%04x", 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("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); return; } test_id = net_buf_simple_pull_u8(buf); if (health_is_test_id_exist(model, test_id) == false) { - BT_ERR("%s, Unknown Test ID 0x%02x", __func__, test_id); + BT_ERR("Unknown Test ID 0x%02x", test_id); return; } company_id = net_buf_simple_pull_le16(buf); if (company_id != srv->test.company_id) { - BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id); + BT_ERR("Unknown Company ID 0x%04x", 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("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); 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("%s, Unable to send Health Attention Status", __func__); + BT_ERR("Unable to send Health Attention Status"); } } @@ -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("%s, Unable to send Health Period Status", __func__); + BT_ERR("Unable to send Health Period Status"); } } @@ -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("%s, Prohibited period value %u", __func__, period); + BT_WARN("Prohibited period value %u", 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("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); return 0; } if (msg->size < 4) { - BT_ERR("%s, Too small health publication msg size %d", __func__, msg->size); + BT_ERR("Too small health publication msg size %d", 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("%s, Invalid health publication context", __func__); + BT_ERR("Invalid health publication context"); 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("%s, Health Server does not exist", __func__); + BT_ERR("Health Server not exists"); return -EINVAL; } if (!model->pub) { - BT_ERR("%s, Health Server has no publication support", __func__); + BT_ERR("Health Server has no publication support"); return -EINVAL; } @@ -419,7 +419,7 @@ static void attention_off(struct k_work *work) BT_DBG("%s", __func__); if (!srv) { - BT_ERR("%s, No Health Server context provided", __func__); + BT_ERR("No Health Server context provided"); return; } @@ -429,7 +429,7 @@ static void attention_off(struct k_work *work) srv->attn_timer_start = false; } -int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary) +static int health_srv_init(struct bt_mesh_model *model) { struct bt_mesh_health_srv *srv = model->user_data; @@ -438,22 +438,17 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary) */ if (!srv) { - 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__); + BT_ERR("No Health Server context provided"); return -EINVAL; } if (srv->test.id_count == 0 || !srv->test.test_ids) { - BT_ERR("%s, No Health Test ID provided", __func__); + BT_ERR("No Health Test ID provided"); return -EINVAL; } if (!model->pub) { - BT_ERR("%s, Health Server has no publication support", __func__); + BT_ERR("Health Server has no publication support"); return -EINVAL; } @@ -467,34 +462,29 @@ int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary) 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 (primary) { + if (bt_mesh_model_in_primary(model)) { health_srv = srv; } return 0; } -int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary) +static int health_srv_deinit(struct bt_mesh_model *model) { struct bt_mesh_health_srv *srv = model->user_data; if (!srv) { - 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__); + BT_ERR("No Health Server context provided"); return -EINVAL; } if (srv->test.id_count == 0 || !srv->test.test_ids) { - BT_ERR("%s, No Health Test ID provided", __func__); + BT_ERR("No Health Test ID provided"); return -EINVAL; } if (!model->pub) { - BT_ERR("%s, Health Server has no publication support", __func__); + BT_ERR("Health Server has no publication support"); return -EINVAL; } @@ -503,13 +493,18 @@ int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary) k_delayed_work_free(&srv->attn_timer); - if (primary) { + if (bt_mesh_model_in_primary(model)) { 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; @@ -517,7 +512,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) if (!model) { srv = health_srv; if (!srv) { - BT_WARN("%s, No Health Server context provided", __func__); + BT_WARN("No Health Server context provided"); return; } @@ -525,7 +520,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) } else { srv = model->user_data; if (!srv) { - BT_WARN("%s, No Health Server context provided", __func__); + BT_WARN("No Health Server context provided"); return; } } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h index 873d98985..2294a58f9 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h @@ -29,41 +29,45 @@ 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(BLE_MESH_MODEL_ID_CFG_CLI, \ - bt_mesh_cfg_cli_op, NULL, 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) -int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page); +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page); -int bt_mesh_cfg_beacon_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_beacon_set(struct bt_mesh_msg_ctx *ctx, u8_t val); +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val); -int bt_mesh_cfg_ttl_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_ttl_set(struct bt_mesh_msg_ctx *ctx, u8_t val); +int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val); -int bt_mesh_cfg_friend_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_friend_set(struct bt_mesh_msg_ctx *ctx, u8_t val); +int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val); -int bt_mesh_cfg_gatt_proxy_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_gatt_proxy_set(struct bt_mesh_msg_ctx *ctx, u8_t val); +int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val); -int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay, u8_t new_transmit); +int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, + u8_t relay, u8_t retransmit); -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_net_key_add(bt_mesh_client_common_param_t *param, + u16_t net_idx, const u8_t net_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_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_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); +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); struct bt_mesh_cfg_mod_pub { u16_t addr; @@ -74,30 +78,36 @@ struct bt_mesh_cfg_mod_pub { u8_t transmit; }; -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_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_set(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, struct bt_mesh_cfg_mod_pub *pub); -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_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_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_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_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_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_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_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_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_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_overwrite(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); struct bt_mesh_cfg_hb_sub { u16_t src; @@ -105,10 +115,10 @@ struct bt_mesh_cfg_hb_sub { u8_t period; }; -int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, struct bt_mesh_cfg_hb_sub *sub); -int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param); struct bt_mesh_cfg_hb_pub { u16_t dst; @@ -119,15 +129,12 @@ struct bt_mesh_cfg_hb_pub { u16_t net_idx; }; -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_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_pub *pub); -int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_hb_pub_get(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); +int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param); /* Configuration Client Status Message Context */ @@ -244,53 +251,61 @@ struct bt_mesh_cfg_lpn_pollto_status { s32_t timeout; }; -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], +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], struct bt_mesh_cfg_mod_pub *pub); -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_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(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id); +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(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, - u16_t mod_id, u16_t cid); +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(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, - const u8_t net_key[16]); +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(struct bt_mesh_msg_ctx *ctx, u16_t net_idx); +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(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_cfg_net_key_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_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(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t app_idx); +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(struct bt_mesh_msg_ctx *ctx, u16_t net_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(struct bt_mesh_msg_ctx *ctx, 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(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t identity); +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(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_unbind(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_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id); +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_app_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, - u16_t mod_id, u16_t cid); +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_kr_phase_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx); +int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, 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_kr_phase_set(bt_mesh_client_common_param_t *param, + 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_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr); -int bt_mesh_cfg_net_transmit_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_net_transmit_set(struct bt_mesh_msg_ctx *ctx, u8_t transmit); +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h b/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h index fe9843239..0af076e9e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h @@ -63,10 +63,11 @@ struct bt_mesh_cfg_srv { }; extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb; #define BLE_MESH_MODEL_CFG_SRV(srv_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_SRV, \ - bt_mesh_cfg_srv_op, NULL, srv_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_SRV, \ + bt_mesh_cfg_srv_op, NULL, srv_data, &bt_mesh_cfg_srv_cb) typedef union { struct { diff --git a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h index 52982eced..359b3878b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h @@ -29,34 +29,30 @@ typedef bt_mesh_client_user_data_t bt_mesh_health_client_t; typedef bt_mesh_client_internal_data_t health_internal_data_t; extern const struct bt_mesh_model_op bt_mesh_health_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; #define BLE_MESH_MODEL_HEALTH_CLI(cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_CLI, \ - bt_mesh_health_cli_op, NULL, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \ + bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb) -int bt_mesh_health_cli_set(struct bt_mesh_model *model); +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid); -int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid); +int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, + u16_t cid, bool need_ack); -int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx, u16_t cid, - bool need_ack); - -int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, u16_t cid, u8_t test_id, bool need_ack); -int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param); -int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, u8_t divisor, bool need_ack); -int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx); +int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param); -int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx, +int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, u8_t attention, bool need_ack); -s32_t bt_mesh_health_cli_timeout_get(void); -void bt_mesh_health_cli_timeout_set(s32_t timeout); - /* Health Client Status Message Context */ struct bt_mesh_health_current_status { diff --git a/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h b/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h index 02a21e295..8255993f8 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h @@ -75,6 +75,7 @@ struct bt_mesh_health_srv { }; extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb; /** @def BLE_MESH_MODEL_HEALTH_SRV * @@ -89,8 +90,8 @@ extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; * @return New mesh model instance. */ #define BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_SRV, \ - bt_mesh_health_srv_op, pub, srv) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_SRV, \ + bt_mesh_health_srv_op, pub, srv, &bt_mesh_health_srv_cb) int bt_mesh_fault_update(struct bt_mesh_elem *elem); diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h index dd3985a8d..31a8bbfb5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -190,12 +190,12 @@ struct bt_mesh_model_op { { BLE_MESH_MODEL_OP_END }) /** Helper to define an empty model array */ -#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){}) +#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){}) /** Length of a short Mesh MIC. */ -#define BLE_MESH_MIC_SHORT 4 +#define BLE_MESH_MIC_SHORT 4 /** Length of a long Mesh MIC. */ -#define BLE_MESH_MIC_LONG 8 +#define BLE_MESH_MIC_LONG 8 /** @def BLE_MESH_MODEL_OP_LEN * @@ -240,31 +240,54 @@ struct bt_mesh_model_op { * @param _payload_len Length of the model message payload. */ #define BLE_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len) \ - NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN(_op, (_payload_len))) + NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN((_op), (_payload_len))) -#define BLE_MESH_MODEL(_id, _op, _pub, _user_data) \ +/** @def BLE_MESH_MODEL_CB + * + * @brief Composition data SIG model entry with callback functions. + * + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \ { \ .id = (_id), \ - .op = _op, \ + .op = (_op), \ .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ BLE_MESH_KEY_UNUSED }, \ - .pub = _pub, \ + .pub = (_pub), \ .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ BLE_MESH_ADDR_UNASSIGNED }, \ - .user_data = _user_data, \ + .user_data = (_user_data), \ + .cb = (_cb), \ } -#define BLE_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \ +/** @def BLE_MESH_MODEL_VND_CB + * + * @brief Composition data vendor model entry with callback functions. + * + * @param _company Company ID. + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \ { \ .vnd.company = (_company), \ .vnd.id = (_id), \ - .op = _op, \ - .pub = _pub, \ + .op = (_op), \ + .pub = (_pub), \ .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ BLE_MESH_KEY_UNUSED }, \ .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ BLE_MESH_ADDR_UNASSIGNED }, \ - .user_data = _user_data, \ + .user_data = (_user_data), \ + .cb = (_cb), \ } /** @def BLE_MESH_TRANSMIT @@ -278,7 +301,7 @@ struct bt_mesh_model_op { * @return Mesh transmit value that can be used e.g. for the default * values of the configuration model data. */ -#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3)) +#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | ((((int_ms) / 10) - 1) << 3)) /** @def BLE_MESH_TRANSMIT_COUNT * @@ -311,7 +334,7 @@ struct bt_mesh_model_op { * @return Mesh transmit value that can be used e.g. for the default * values of the configuration model data. */ -#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT(count, (int_ms) / 5) +#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT((count), (int_ms) / 5) /** @def BLE_MESH_PUB_TRANSMIT_COUNT * @@ -400,6 +423,36 @@ struct bt_mesh_model_pub { .msg = &bt_mesh_pub_msg_##_name, \ } +/** Model callback functions. */ +struct bt_mesh_model_cb { + /** @brief Model init callback. + * + * Called on every model instance during mesh initialization. + * + * If any of the model init callbacks return an error, the mesh + * subsystem initialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_init. + * + * @param model Model to be initialized. + * + * @return 0 on success, error otherwise. + */ + int (*const init)(struct bt_mesh_model *model); + + /** @brief Model deinit callback. + * + * Called on every model instance during mesh deinitialization. + * All model data is deleted, and the model should clear its state. + * + * If any of the model deinit callbacks return an error, the mesh + * subsystem deinitialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_deinit. + * + * @param model Model to be de-initialized. + */ + int (*const deinit)(struct bt_mesh_model *model); +}; + /** Abstraction that describes a Mesh Model instance */ struct bt_mesh_model { union { @@ -427,8 +480,12 @@ struct bt_mesh_model { /* Subscription List (group or virtual addresses) */ u16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + /** Opcode handler list */ const struct bt_mesh_model_op *const op; + /** Model callback structure. */ + const struct bt_mesh_model_cb *const cb; + /* Model-specific user data */ void *user_data; }; @@ -488,6 +545,39 @@ int bt_mesh_model_publish(struct bt_mesh_model *model); */ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod); +/** @brief Find a SIG model. + * + * @param elem Element to search for the model in. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no SIG model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id); + +/** @brief Find a vendor model. + * + * @param elem Element to search for the model in. + * @param company Company ID of the model. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no vendor model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, + u16_t company, u16_t id); + +/** @brief Get whether the model is in the primary element of the device. + * + * @param mod Mesh model. + * + * @return true if the model is on the primary element, false otherwise. + */ +static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod) +{ + return (mod->elem_idx == 0); +} + /** Node Composition */ struct bt_mesh_comp { u16_t cid; diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h index ea4ba202b..3a3e8ca67 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -627,7 +627,7 @@ struct bt_mesh_gatt_attr { .uuid = BLE_MESH_UUID_GATT_CHRC, \ .perm = BLE_MESH_GATT_PERM_READ, \ .read = bt_mesh_gatts_attr_read_chrc, \ - .user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \ + .user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \ .properties = _props, }), \ } @@ -709,10 +709,11 @@ int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc); int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc); ssize_t bt_mesh_gatts_attr_read_included(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); -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); @@ -721,10 +722,11 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, void *buf, u16_t len, u16_t offset); 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); -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 bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn); @@ -750,7 +752,8 @@ void bt_mesh_gattc_exchange_mtu(u8_t index); u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn); -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); void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn); diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h index 362c0bec6..c18ce9155 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h @@ -359,17 +359,6 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers); */ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); -/* The following API is for BLE Mesh Fast Provisioning */ - -/** @brief Change the device action - * - * @param[IN] action: role of device to be set - * 0x01 - enter, 0x02 - suspend, 0x03 - exit - * - * @return status - */ -u8_t bt_mesh_set_fast_prov_action(u8_t action); - /* The following APIs are for BLE Mesh Provisioner */ /** @brief Provide provisioning input OOB string. @@ -394,14 +383,6 @@ int bt_mesh_prov_input_string(const char *str); */ int bt_mesh_prov_input_number(u32_t num); -/** @brief Enable Provisioner corresponding functionalities, e.g. scan, etc. - * - * @param bearers Bit-wise OR of provisioning bearers. - * - * @return Zero on success or (negative) error code otherwise. - */ -int bt_mesh_provisioner_net_start(bt_mesh_prov_bearer_t bearers); - /** @brief Enable specific provisioning bearers * * Enable one or more provisioning bearers. @@ -465,6 +446,12 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers); BLE_MESH_FEAT_FRIEND | \ BLE_MESH_FEAT_LOW_POWER) +/** @brief Check if the mesh stack is initialized. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_initialized(void); + /** @brief Initialize Mesh support * * After calling this API, the node will not automatically advertise as diff --git a/components/bt/esp_ble_mesh/mesh_core/local_operation.c b/components/bt/esp_ble_mesh/mesh_core/local_operation.c index 9e2ab3f5e..e3c2c5051 100644 --- a/components/bt/esp_ble_mesh/mesh_core/local_operation.c +++ b/components/bt/esp_ble_mesh/mesh_core/local_operation.c @@ -23,13 +23,13 @@ static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id struct bt_mesh_elem *elem = NULL; if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, elem_addr); + BT_ERR("Invalid unicast address 0x%04x", elem_addr); return NULL; } elem = bt_mesh_elem_find(elem_addr); if (elem == NULL) { - BT_ERR("%s, No element found, addr 0x%04x", __func__, elem_addr); + BT_ERR("No element found, addr 0x%04x", elem_addr); return NULL; } diff --git a/components/bt/esp_ble_mesh/mesh_core/lpn.c b/components/bt/esp_ble_mesh/mesh_core/lpn.c index 6aa5136e8..7ba704573 100644 --- a/components/bt/esp_ble_mesh/mesh_core/lpn.c +++ b/components/bt/esp_ble_mesh/mesh_core/lpn.c @@ -165,7 +165,7 @@ static void friend_clear_sent(int err, void *user_data) lpn->req_attempts++; if (err) { - BT_ERR("%s, Sending Friend Request failed (err %d)", __func__, err); + BT_ERR("Sending Friend Clear failed (err %d)", err); lpn_set_state(BLE_MESH_LPN_ENABLED); clear_friendship(false, lpn->disable); return; @@ -218,7 +218,7 @@ static void clear_friendship(bool force, bool disable) return; } - bt_mesh_rx_reset(); + bt_mesh_rx_reset(true); k_delayed_work_cancel(&lpn->timer); @@ -277,7 +277,7 @@ static void friend_req_sent(u16_t duration, int err, void *user_data) struct bt_mesh_lpn *lpn = &bt_mesh.lpn; if (err) { - BT_ERR("%s, Sending Friend Request failed (err %d)", __func__, err); + BT_ERR("Sending Friend Request failed (err %d)", err); if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) { bt_mesh_scan_enable(); @@ -339,7 +339,7 @@ static void req_sent(u16_t duration, int err, void *user_data) lpn->sent_req, duration, err, state2str(lpn->state)); if (err) { - BT_ERR("%s, Sending request failed (err %d)", __func__, err); + BT_ERR("Sending request failed (err %d)", err); lpn->sent_req = 0U; group_zero(lpn->pending); return; @@ -699,7 +699,7 @@ static bool sub_update(u8_t op) } if (added_count + g >= lpn->queue_size) { - BT_WARN("%s, Friend Queue Size exceeded", __func__); + BT_WARN("Friend Queue Size exceeded"); break; } @@ -834,7 +834,7 @@ static void lpn_timeout(struct k_work *work) update_timeout(lpn); break; default: - __ASSERT(0, "Unhandled LPN state"); + BT_ERR("Unhandled LPN state"); break; } } diff --git a/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index 64710ddc1..341fc8dd6 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -29,12 +29,13 @@ #include "provisioner_prov.h" #include "provisioner_main.h" -#define ACTION_ENTER 0x01 -#define ACTION_SUSPEND 0x02 -#define ACTION_EXIT 0x03 - static bool mesh_init = false; +bool bt_mesh_is_initialized(void) +{ + return mesh_init; +} + int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, u8_t flags, u32_t iv_index, u16_t addr, const u8_t dev_key[16]) @@ -52,7 +53,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, } if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { - if (bt_mesh_proxy_prov_disable(false) == 0) { + if (bt_mesh_proxy_server_prov_disable(false) == 0) { pb_gatt_enabled = true; } else { pb_gatt_enabled = false; @@ -66,7 +67,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_VALID); if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && pb_gatt_enabled) { - bt_mesh_proxy_prov_enable(); + bt_mesh_proxy_server_prov_enable(); } return err; @@ -85,9 +86,6 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, bt_mesh_store_iv(false); } - /* Add this to avoid "already active status" for bt_mesh_scan_enable() */ - bt_mesh_scan_disable(); - bt_mesh_net_start(); return 0; @@ -107,9 +105,9 @@ void bt_mesh_node_reset(void) k_delayed_work_cancel(&bt_mesh.ivu_timer); - bt_mesh_cfg_reset(); + bt_mesh_cfg_reset(true); - bt_mesh_rx_reset(); + bt_mesh_rx_reset(true); bt_mesh_tx_reset(); if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) { @@ -121,11 +119,7 @@ void bt_mesh_node_reset(void) } if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { - bt_mesh_proxy_gatt_disable(); - } - - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_net(); + bt_mesh_proxy_server_gatt_disable(); } (void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key)); @@ -136,6 +130,7 @@ void bt_mesh_node_reset(void) bt_mesh_comp_unprovision(); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_clear_net(); bt_mesh_clear_seq(); bt_mesh_clear_role(); } @@ -175,16 +170,53 @@ bool bt_mesh_is_provisioner_en(void) } } +static bool prov_bearers_valid(bt_mesh_prov_bearer_t bearers) +{ + if ((!(bearers & (BLE_MESH_PROV_ADV | BLE_MESH_PROV_GATT))) || + (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && + !IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && + !(bearers & BLE_MESH_PROV_ADV)) || + (!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && + !(bearers & BLE_MESH_PROV_GATT))) { + BT_ERR("Invalid bearers 0x%02x", bearers); + return false; + } + return true; +} + int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) { if (bt_mesh_is_provisioned()) { + BT_WARN("%s, Already", __func__); return -EALREADY; } - bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_NODE); + if (prov_bearers_valid(bearers) == false) { + return -EINVAL; + } - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_store_role(); + /* Add this judgement here in case the device worked as a + * Provisioner previously. Before the corresponding info + * of Provisioner is erased from flash, users try to use + * the device as a node, which will cause the information + * in NVS been handled incorrectly. + */ + u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; + if (role != BLE_MESH_SETTINGS_ROLE_NONE && + role != BLE_MESH_SETTINGS_ROLE_NODE) { + BT_ERR("%s, Mismatch role %u", __func__, role); + return -EIO; + } + + if (role == BLE_MESH_SETTINGS_ROLE_NONE) { + bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_NODE); + } + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS_BACKWARD_COMPATIBILITY) || + role == BLE_MESH_SETTINGS_ROLE_NONE) { + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_store_role(); + } } if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && @@ -197,7 +229,7 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (bearers & BLE_MESH_PROV_GATT)) { - bt_mesh_proxy_prov_enable(); + bt_mesh_proxy_server_prov_enable(); bt_mesh_adv_update(); } @@ -207,9 +239,14 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers) { if (bt_mesh_is_provisioned()) { + BT_WARN("%s, Already provisioned", __func__); return -EALREADY; } + if (prov_bearers_valid(bearers) == false) { + return -EINVAL; + } + bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_NODE); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { @@ -224,7 +261,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers) if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (bearers & BLE_MESH_PROV_GATT)) { - bt_mesh_proxy_prov_disable(true); + bt_mesh_proxy_server_prov_disable(true); } return 0; @@ -254,7 +291,7 @@ int bt_mesh_suspend(void) err = bt_mesh_scan_disable(); if (err) { bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_SUSPENDED); - BT_WARN("%s, Disabling scanning failed (err %d)", __func__, err); + BT_WARN("Disabling scanning failed (err %d)", err); return err; } @@ -295,7 +332,7 @@ int bt_mesh_resume(void) err = bt_mesh_scan_enable(); if (err) { - BT_WARN("%s, Re-enabling scanning failed (err %d)", __func__, err); + BT_WARN("Re-enabling scanning failed (err %d)", err); bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_SUSPENDED); return err; } @@ -336,17 +373,16 @@ int bt_mesh_init(const struct bt_mesh_prov *prov, bt_mesh_gatt_init(); } - if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) { - if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) && - IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || - IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { - bt_mesh_proxy_init(); - } - if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && - IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || - IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { - bt_mesh_proxy_prov_client_init(); - } + if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || + IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { + bt_mesh_proxy_server_init(); + } + + if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || + IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { + bt_mesh_proxy_client_init(); } if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) { @@ -404,23 +440,34 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param) return -EALREADY; } - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV)) { - bt_mesh_beacon_disable(); - bt_mesh_scan_disable(); + bt_mesh_scan_disable(); + bt_mesh_beacon_disable(); + + if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node()) { + if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && + !bt_mesh_is_provisioned()) { + bt_mesh_proxy_server_prov_disable(true); } - if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { - bt_mesh_proxy_prov_disable(true); + if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && + bt_mesh_is_provisioned()) { + bt_mesh_proxy_server_gatt_disable(); + } + + if (bt_mesh_is_provisioned()) { + /* Clear valid flag here in order to perform settings erase */ + bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_VALID); + + bt_mesh_cfg_reset(param->erase); } } if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) { if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { - bt_mesh_provisioner_pb_gatt_disable(); + bt_mesh_proxy_client_prov_disable(); } - bt_mesh_scan_disable(); + /* Clear valid flag here in order to perform settings erase */ bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_VALID_PROV); } @@ -431,40 +478,39 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param) return err; } } + if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER)) { err = bt_mesh_provisioner_prov_deinit(param->erase); if (err) { return err; } + + err = bt_mesh_provisioner_deinit(param->erase); + if (err) { + return err; + } } } bt_mesh_trans_deinit(param->erase); - bt_mesh_net_deinit(param->erase); + bt_mesh_net_deinit(); bt_mesh_beacon_deinit(); - if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) { - if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) { - bt_mesh_proxy_deinit(); - } + if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || + IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { + bt_mesh_proxy_server_deinit(); } if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { - bt_mesh_proxy_prov_client_deinit(); + bt_mesh_proxy_client_deinit(); } bt_mesh_gatt_deinit(); - if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER)) { - err = bt_mesh_provisioner_deinit(param->erase); - if (err) { - return err; - } - } - if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { bt_mesh_friend_deinit(); } @@ -475,17 +521,18 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param) bt_mesh_adv_deinit(); + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_settings_deinit(param->erase); + } + err = bt_mesh_comp_deregister(); if (err) { return err; } - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - if (param->erase) { - bt_mesh_clear_role(); - } - bt_mesh_settings_deinit(); - } + bt_mesh_comp_unprovision(); + + memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags)); bt_mesh_timer_deinit(); @@ -496,10 +543,61 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param) } #if defined(CONFIG_BLE_MESH_PROVISIONER) -int bt_mesh_provisioner_net_start(bt_mesh_prov_bearer_t bearers) +int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers) { + int err = 0; + + if (bt_mesh_is_provisioner_en()) { + BT_WARN("%s, Already", __func__); + return -EALREADY; + } + + if (prov_bearers_valid(bearers) == false) { + return -EINVAL; + } + + /* Add this judgement here in case the device worked as a + * node previously. Before the corresponding information + * of the node is erased from flash, users try to use the + * device as a Provisioner, which will cause the information + * in NVS been handled incorrectly. + */ + u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; + if (role != BLE_MESH_SETTINGS_ROLE_NONE && + role != BLE_MESH_SETTINGS_ROLE_PROV) { + BT_ERR("%s, Mismatch role %u", __func__, role); + return -EIO; + } + + if (role == BLE_MESH_SETTINGS_ROLE_NONE) { + bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_PROVISIONER); + + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_store_role(); + } + } + + /* Enable Provisioner here, because during the following net + * creation, some information needs to be stored in flash. + */ + bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_VALID_PROV); + + err = bt_mesh_provisioner_net_create(); + if (err) { + BT_ERR("Failed to create network"); + return err; + } + + err = bt_mesh_provisioner_init_prov_info(); + if (err) { + BT_ERR("Failed to init prov info"); + return err; + } + bt_mesh_provisioner_set_prov_bearer(bearers, false); + bt_mesh_comp_provision(bt_mesh_provisioner_get_primary_elem_addr()); + #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && (bearers & BLE_MESH_PROV_ADV)) { @@ -514,61 +612,24 @@ int bt_mesh_provisioner_net_start(bt_mesh_prov_bearer_t bearers) } #endif - if ((IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && - (bearers & BLE_MESH_PROV_ADV)) || - (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && - (bearers & BLE_MESH_PROV_GATT))) { - bt_mesh_scan_enable(); - } - if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (bearers & BLE_MESH_PROV_GATT)) { - bt_mesh_provisioner_pb_gatt_enable(); - } - - bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_VALID_PROV); - - if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { - bt_mesh_beacon_enable(); + bt_mesh_proxy_client_prov_enable(); } if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { bt_mesh_friend_init(); } + if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { + bt_mesh_beacon_enable(); + } + + bt_mesh_scan_enable(); + return 0; } -int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers) -{ - int err = 0; - - if (bt_mesh_is_provisioner_en()) { - BT_WARN("%s, Already", __func__); - return -EALREADY; - } - - err = bt_mesh_provisioner_set_prov_info(); - if (err) { - BT_ERR("%s, Failed to set provisioning info", __func__); - return err; - } - - err = bt_mesh_provisioner_net_create(); - if (err) { - BT_ERR("%s, Failed to create network", __func__); - return err; - } - - bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_PROVISIONER); - - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_store_role(); - } - - return bt_mesh_provisioner_net_start(bearers); -} - int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) { bt_mesh_prov_bearer_t enable = 0U; @@ -578,9 +639,13 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) return -EALREADY; } + if (prov_bearers_valid(bearers) == false) { + return -EINVAL; + } + enable = bt_mesh_provisioner_get_prov_bearer(); if (!(enable & bearers)) { - BT_ERR("%s, Bearers mismatch", __func__); + BT_ERR("Mismatch bearers 0x%02x", bearers); return -EINVAL; } @@ -589,7 +654,7 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (enable & BLE_MESH_PROV_GATT) && (bearers & BLE_MESH_PROV_GATT)) { - bt_mesh_provisioner_pb_gatt_disable(); + bt_mesh_proxy_client_prov_disable(); #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL); @@ -628,65 +693,3 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers) return 0; } #endif /* CONFIG_BLE_MESH_PROVISIONER */ - -/* The following API is for fast provisioning */ - -#if CONFIG_BLE_MESH_FAST_PROV -u8_t bt_mesh_set_fast_prov_action(u8_t action) -{ - if (!action || action > ACTION_EXIT) { - return 0x01; - } - - if ((!bt_mesh_is_provisioner_en() && (action == ACTION_SUSPEND || action == ACTION_EXIT)) || - (bt_mesh_is_provisioner_en() && (action == ACTION_ENTER))) { - BT_WARN("%s, Already", __func__); - return 0x0; - } - - if (action == ACTION_ENTER) { -#if 0 - /* If the device is provisioned using PB-GATT and connected to - * the phone with proxy service, proxy_gatt shall not be disabled - * here. The node needs to send some status messages to the phone - * while it is connected. - */ - if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { - bt_mesh_proxy_gatt_disable(); - } -#endif - if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { - bt_mesh_beacon_disable(); - } - if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { - 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); - bt_mesh_provisioner_fast_prov_enable(true); - 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_provisioner_pb_gatt_disable(); - } - if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) { - bt_mesh_beacon_enable(); - } -#if 0 - /* Mesh Proxy GATT will be re-enabled on application layer */ - if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && - bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) { - bt_mesh_proxy_gatt_enable(); - bt_mesh_adv_update(); - } -#endif - bt_mesh_atomic_and(bt_mesh.flags, ~(BIT(BLE_MESH_PROVISIONER) | BIT(BLE_MESH_VALID_PROV))); - bt_mesh_provisioner_fast_prov_enable(false); - if (action == ACTION_EXIT) { - bt_mesh_provisioner_remove_node(NULL); - } - } - - return 0x0; -} -#endif /* CONFIG_BLE_MESH_FAST_PROV */ diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh.h b/components/bt/esp_ble_mesh/mesh_core/mesh.h index 5a409a891..8387470a4 100644 --- a/components/bt/esp_ble_mesh/mesh_core/mesh.h +++ b/components/bt/esp_ble_mesh/mesh_core/mesh.h @@ -2,6 +2,7 @@ /* * Copyright (c) 2017 Intel Corporation + * Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,13 +16,13 @@ extern "C" { #endif -#define BLE_MESH_KEY_PRIMARY 0x0000 -#define BLE_MESH_KEY_ANY 0xffff +#define BLE_MESH_KEY_PRIMARY 0x0000 +#define BLE_MESH_KEY_ANY 0xffff -#define BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) -#define BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00) -#define BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000) -#define BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb) +#define BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) +#define BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00) +#define BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000) +#define BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb) struct bt_mesh_net; diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 548182e31..ab6867833 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -171,7 +171,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy); if (err) { - BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__); + BT_ERR("Unable to generate NID, EncKey & PrivacyKey"); return err; } @@ -184,7 +184,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, err = bt_mesh_k3(key, keys->net_id); if (err) { - BT_ERR("%s, Unable to generate Net ID", __func__); + BT_ERR("Unable to generate Net ID"); return err; } @@ -193,7 +193,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) err = bt_mesh_identity_key(key, keys->identity); if (err) { - BT_ERR("%s, Unable to generate IdentityKey", __func__); + BT_ERR("Unable to generate IdentityKey"); return err; } @@ -202,7 +202,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, err = bt_mesh_beacon_key(key, keys->beacon); if (err) { - BT_ERR("%s, Unable to generate beacon key", __func__); + BT_ERR("Unable to generate beacon key"); return err; } @@ -245,7 +245,7 @@ int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16]) err = bt_mesh_k2(net_key, p, sizeof(p), &cred->cred[idx].nid, cred->cred[idx].enc, cred->cred[idx].privacy); if (err) { - BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__); + BT_ERR("Unable to generate NID, EncKey & PrivacyKey"); return err; } @@ -501,6 +501,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub) BT_DBG("idx 0x%04x", sub->net_idx); memcpy(&sub->keys[0], &sub->keys[1], sizeof(sub->keys[0])); + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { BT_DBG("Store updated NetKey persistently"); bt_mesh_store_subnet(sub); @@ -515,6 +516,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub) memcpy(&key->keys[0], &key->keys[1], sizeof(key->keys[0])); key->updated = false; + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { BT_DBG("Store updated AppKey persistently"); bt_mesh_store_app_key(key); @@ -535,6 +537,12 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key) if (sub->kr_phase == BLE_MESH_KR_PHASE_1) { BT_INFO("Phase 1 -> Phase 2"); sub->kr_phase = BLE_MESH_KR_PHASE_2; + + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + BT_DBG("Storing kr phase persistently"); + bt_mesh_store_subnet(sub); + } + return true; } } else { @@ -553,12 +561,15 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key) */ case BLE_MESH_KR_PHASE_2: BT_INFO("KR Phase 0x%02x -> Normal", sub->kr_phase); + + sub->kr_phase = BLE_MESH_KR_NORMAL; bt_mesh_net_revoke_keys(sub); + if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) || IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { friend_cred_refresh(sub->net_idx); } - sub->kr_phase = BLE_MESH_KR_NORMAL; + return true; } } @@ -582,6 +593,10 @@ void bt_mesh_rpl_reset(void) } else { rpl->old_iv = true; } + + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_store_rpl(rpl); + } } } } @@ -597,7 +612,7 @@ void bt_mesh_iv_update_test(bool enable) bool bt_mesh_iv_update(void) { if (!bt_mesh_is_provisioned()) { - BT_ERR("%s, Not yet provisioned", __func__); + BT_ERR("Not yet provisioned"); return false; } @@ -622,7 +637,7 @@ void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub) if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) { - bt_mesh_proxy_beacon_send(sub); + bt_mesh_proxy_server_beacon_send(sub); } } @@ -778,13 +793,13 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv); if (err) { - BT_ERR("%s, De-obfuscate failed (err %d)", __func__, err); + BT_ERR("De-obfuscate failed (err %d)", err); return err; } err = bt_mesh_net_decrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false); if (err) { - BT_ERR("%s, Decrypt failed (err %d)", __func__, err); + BT_ERR("Decrypt failed (err %d)", err); return err; } @@ -797,18 +812,18 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, err = bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false); if (err) { - BT_ERR("%s, Encrypt failed (err %d)", __func__, err); + BT_ERR("Encrypt failed (err %d)", err); return err; } err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv); if (err) { - BT_ERR("%s, Obfuscate failed (err %d)", __func__, err); + BT_ERR("Obfuscate failed (err %d)", err); return err; } if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && - bt_mesh_proxy_relay(&buf->b, dst) && + bt_mesh_proxy_server_relay(&buf->b, dst) && BLE_MESH_ADDR_IS_UNICAST(dst)) { send_cb_finalize(cb, cb_data); return 0; @@ -838,10 +853,10 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf, int err = 0; if (ctl && net_buf_simple_tailroom(buf) < BLE_MESH_MIC_LONG) { - BT_ERR("%s, Insufficient MIC space for CTL PDU", __func__); + BT_ERR("Insufficient MIC space for CTL PDU"); return -EINVAL; } else if (net_buf_simple_tailroom(buf) < BLE_MESH_MIC_SHORT) { - BT_ERR("%s, Insufficient MIC space for PDU", __func__); + BT_ERR("Insufficient MIC space for PDU"); return -EINVAL; } @@ -913,7 +928,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, */ if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && tx->ctx->send_ttl != 1U) { - if (bt_mesh_proxy_relay(&buf->b, tx->ctx->addr) && + if (bt_mesh_proxy_server_relay(&buf->b, tx->ctx->addr) && BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { /* Notify completion if this only went * through the Mesh Proxy. @@ -925,9 +940,9 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, } } -#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT - if (tx->ctx->send_ttl != 1U) { - if (bt_mesh_proxy_client_send(&buf->b, tx->ctx->addr)) { + if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) && + tx->ctx->send_ttl != 1U) { + if (bt_mesh_proxy_client_relay(&buf->b, tx->ctx->addr)) { /* If Proxy Client succeeds to send messages with GATT bearer, * we can directly finish here. And if not, which means no * connection has been created with Proxy Client, here we will @@ -939,7 +954,6 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, goto done; } } -#endif /* Deliver to local network interface if necessary */ if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && @@ -990,8 +1004,8 @@ static bool auth_match(struct bt_mesh_subnet_keys *keys, } struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags, - u32_t iv_index, const u8_t auth[8], - bool *new_key) + u32_t iv_index, const u8_t auth[8], + bool *new_key) { size_t subnet_size = 0U; int i; @@ -1116,7 +1130,7 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len, for (i = 0; i < array_size; i++) { sub = bt_mesh_rx_netkey_get(i); if (!sub) { - BT_DBG("%s, NULL subnet", __func__); + BT_DBG("Subnet not found"); continue; } @@ -1239,7 +1253,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, #endif if (!buf) { - BT_ERR("%s, Out of relay buffers", __func__); + BT_ERR("Out of relay buffers"); return; } @@ -1269,12 +1283,12 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, * layer nonce includes the IVI. */ if (bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_RX(rx), false)) { - BT_ERR("%s, Re-encrypting failed", __func__); + BT_ERR("Re-encrypting failed"); goto done; } if (bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_RX(rx), priv)) { - BT_ERR("%s, Re-obfuscating failed", __func__); + BT_ERR("Re-obfuscating failed"); goto done; } @@ -1284,7 +1298,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf, if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED || rx->net_if == BLE_MESH_NET_IF_LOCAL)) { - if (bt_mesh_proxy_relay(&buf->b, rx->ctx.recv_dst) && + if (bt_mesh_proxy_server_relay(&buf->b, rx->ctx.recv_dst) && BLE_MESH_ADDR_IS_UNICAST(rx->ctx.recv_dst)) { goto done; } @@ -1355,12 +1369,12 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, if (net_if != BLE_MESH_NET_IF_PROXY_CFG && rx->ctx.recv_dst == BLE_MESH_ADDR_UNASSIGNED) { - BT_ERR("%s, Destination address is unassigned; dropping packet", __func__); + BT_ERR("Destination address is unassigned; dropping packet"); return -EBADMSG; } if (BLE_MESH_ADDR_IS_RFU(rx->ctx.recv_dst)) { - BT_ERR("%s, Destination address is RFU; dropping packet", __func__); + BT_ERR("Destination address is RFU; dropping packet"); return -EBADMSG; } @@ -1447,7 +1461,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && net_if == BLE_MESH_NET_IF_PROXY) { - bt_mesh_proxy_addr_add(data, rx.ctx.addr); + bt_mesh_proxy_server_addr_add(data, rx.ctx.addr); if (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_DISABLED && !rx.local_match) { @@ -1516,7 +1530,7 @@ void bt_mesh_net_start(void) if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) { - bt_mesh_proxy_gatt_enable(); + bt_mesh_proxy_server_gatt_enable(); bt_mesh_adv_update(); } @@ -1558,7 +1572,7 @@ void bt_mesh_net_init(void) k_work_init(&bt_mesh.local_work, bt_mesh_net_local); } -void bt_mesh_net_deinit(bool erase) +void bt_mesh_net_deinit(void) { k_delayed_work_free(&bt_mesh.ivu_timer); @@ -1580,11 +1594,4 @@ void bt_mesh_net_deinit(bool erase) bt_mesh.iv_index = 0U; bt_mesh.seq = 0U; - - memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags)); - - if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_seq(); - bt_mesh_clear_iv(); - } } diff --git a/components/bt/esp_ble_mesh/mesh_core/net.h b/components/bt/esp_ble_mesh/mesh_core/net.h index 2349403b6..23e3d4bc1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.h +++ b/components/bt/esp_ble_mesh/mesh_core/net.h @@ -349,8 +349,8 @@ void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub); struct bt_mesh_subnet *bt_mesh_subnet_get(u16_t net_idx); struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags, - u32_t iv_index, const u8_t auth[8], - bool *new_key); + u32_t iv_index, const u8_t auth[8], + bool *new_key); int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf, bool proxy); @@ -375,7 +375,7 @@ u32_t bt_mesh_next_seq(void); void bt_mesh_net_start(void); void bt_mesh_net_init(void); -void bt_mesh_net_deinit(bool erase); +void bt_mesh_net_deinit(void); void bt_mesh_net_header_parse(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx); diff --git a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index 037296f6c..6d1e06c6a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -21,9 +21,11 @@ #include "services/gap/ble_svc_gap.h" #include "services/gatt/ble_svc_gatt.h" +#include +#include + #include "mesh_hci.h" #include "mesh_common.h" -#include "mesh_aes_encrypt.h" #include "provisioner_prov.h" /** @def BT_UUID_MESH_PROV @@ -161,7 +163,7 @@ static int ble_on_subscribe(uint16_t conn_handle, conn = &bt_mesh_gattc_info[i].conn; if (bt_mesh_gattc_info[i].ccc_handle != attr->handle) { - BT_WARN("%s, gattc ccc_handle is not matched", __func__); + BT_WARN("gattc ccc_handle not matched"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -170,7 +172,7 @@ static int ble_on_subscribe(uint16_t conn_handle, 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("%s, prov_write_descr failed", __func__); + BT_ERR("prov_write_descr failed"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -180,7 +182,7 @@ static int ble_on_subscribe(uint16_t conn_handle, 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("%s, proxy_write_descr failed", __func__); + BT_ERR("proxy_write_descr failed"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -205,7 +207,10 @@ static int dsc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, switch (error->status) { case 0: - bt_mesh_gattc_info[i].ccc_handle = dsc->handle; + if (bt_mesh_gattc_info[i].ccc_handle == 0 && dsc && + BLE_UUID16(&dsc->uuid)->value == BLE_MESH_UUID_GATT_CCC_VAL) { + bt_mesh_gattc_info[i].ccc_handle = dsc->handle; + } break; case BLE_HS_EDONE: @@ -289,7 +294,8 @@ static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error, break; } } - ble_gattc_disc_all_dscs(conn_handle, bt_mesh_gattc_info[j].data_out_handle, 0xffff, dsc_disced, (void *)j); + ble_gattc_disc_all_dscs(conn_handle, bt_mesh_gattc_info[j].data_out_handle, bt_mesh_gattc_info[j].end_handle, + dsc_disced, (void *)j); } else { ble_gattc_disc_all_chrs(conn_handle, bt_mesh_gattc_info[j].start_handle, bt_mesh_gattc_info[j].end_handle, chr_disced, (void *)j); @@ -339,7 +345,7 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, } if (i == ARRAY_SIZE(bt_mesh_gattc_info)) { - BT_ERR("%s, Conn handle is not found", __func__); + BT_ERR("Conn handle 0x%04x not found", conn_handle); return 0; } conn = &bt_mesh_gattc_info[i].conn; @@ -386,7 +392,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) struct net_buf_simple *buf = bt_mesh_alloc_buf(desc->length_data); if (!buf) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return 0; } net_buf_simple_add_mem(buf, desc->data, desc->length_data); @@ -416,22 +422,14 @@ static int disc_cb(struct ble_gap_event *event, void *arg) } } } -#if BLE_MESH_DEV if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { rc = ble_gap_disc(BLE_OWN_ADDR_PUBLIC, BLE_HS_FOREVER, &scan_param, disc_cb, NULL); if (rc != 0) { - BT_ERR("%s, Invalid status %d", __func__, rc); + BT_ERR("Invalid scan status %d", rc); break; } bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING); } -#else - rc = ble_gap_disc(BLE_OWN_ADDR_PUBLIC, BLE_HS_FOREVER, &scan_param, disc_cb, NULL); - if (rc != 0) { - BT_ERR("%s, Invalid status %d", __func__, rc); - break; - } -#endif /* BLE_MESH_DEV */ break; case BLE_GAP_EVENT_DISCONNECT: if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->disconnected != NULL) { @@ -511,7 +509,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) } if (i == ARRAY_SIZE(bt_mesh_gattc_info)) { - BT_ERR("%s, Conn handle is not found", __func__); + BT_ERR("Conn handle 0x%04x not found", event->notify_rx.conn_handle); return 0; } @@ -526,7 +524,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) if (memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN) || (bt_mesh_gattc_info[i].data_out_handle != event->notify_rx.attr_handle) || (event->notify_rx.indication != 0)) { - BT_ERR("%s, Notification error", __func__); + BT_ERR("Notification error"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -539,7 +537,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn, notif_data, notif_len); if (len < 0) { - BT_ERR("%s, prov_notify failed", __func__); + BT_ERR("prov_notify failed"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -549,7 +547,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn, notif_data, notif_len); if (len < 0) { - BT_ERR("%s, proxy_notify failed", __func__); + BT_ERR("proxy_notify failed"); bt_mesh_gattc_disconnect(conn); return 0; } @@ -935,11 +933,10 @@ int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t c { int err; -#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 BLE_MESH_DEV if (param->filter_dup) { @@ -954,26 +951,24 @@ int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t c return err; } -#if BLE_MESH_DEV bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING); -#endif - bt_mesh_scan_dev_found_cb = cb; - return err; + + return 0; } int bt_le_scan_stop(void) { -#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); - ble_gap_disc_cancel(); + if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { + BT_INFO("Scan is already stopped"); + return -EALREADY; } -#else - ble_gap_disc_cancel(); -#endif + ble_gap_disc_cancel(); + + bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING); bt_mesh_scan_dev_found_cb = NULL; + return 0; } @@ -1068,7 +1063,8 @@ 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) { @@ -1094,8 +1090,8 @@ struct gatts_incl { } __packed; ssize_t bt_mesh_gatts_attr_read_included(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_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; @@ -1144,8 +1140,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; @@ -1162,7 +1158,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("%s, No value for characteristic at 0x%04x", __func__, attr->handle); + BT_WARN("No value for characteristic, handle 0x%04x", attr->handle); pdu.value_handle = 0x0000; } else { pdu.value_handle = sys_cpu_to_le16(next->handle); @@ -1192,7 +1188,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("%s, handle = %d", __func__, handle); + BT_DBG("gatts register, handle %d", handle); populate: sys_slist_append(&bt_mesh_gatts_db, &svc->node); @@ -1245,11 +1241,12 @@ int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason) int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc) { assert(svc != NULL); - BT_ERR("%s, Unsupported for NimBLE host", __func__); + BT_ERR("Unsupported for NimBLE host"); 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) { struct os_mbuf *om; @@ -1381,21 +1378,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("%s, Invalid remote address", __func__); + BT_ERR("Invalid remote address"); return -EINVAL; } if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL && service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { - BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid); + BT_ERR("Invalid service uuid 0x%04x", 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("%s, Already create connection with %s", - __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + BT_WARN("Already create connection with %s", + bt_hex(addr->val, BLE_MESH_ADDR_LEN)); return -EALREADY; } } @@ -1413,25 +1410,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("%s, gattc info is full", __func__); + BT_WARN("gattc info is full"); return -ENOMEM; } -#if BLE_MESH_DEV - if (bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { + if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) { rc = ble_gap_disc_cancel(); if (rc != 0) { return -1; } + bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING); } -#else - rc = ble_gap_disc_cancel(); - if (rc != 0) { - return -1; - } -#endif /* BLE_MESH_DEV */ - BT_DBG("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN)); /* Min_interval: 250ms * Max_interval: 250ms @@ -1501,7 +1492,8 @@ 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; @@ -1514,7 +1506,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_g } if (i == ARRAY_SIZE(bt_mesh_gattc_info)) { - BT_ERR("%s, Conn is not found", __func__); + BT_ERR("Conn %p not found", conn); /** Here we return 0 for prov_send() return value check in provisioner.c */ return 0; @@ -1557,7 +1549,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn) } if (i == ARRAY_SIZE(bt_mesh_gattc_info)) { - BT_ERR("%s, Conn is not found", __func__); + BT_ERR("Conn %p not found", conn); return; } ble_gap_terminate(bt_mesh_gattc_info[i].conn.handle, BLE_ERR_REM_USER_CONN_TERM); @@ -1597,7 +1589,7 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, u8_t index = BLE_MESH_GATT_GET_CONN_ID(conn_handle); u16_t len = 0; - BT_DBG("%s, write: handle = %d, len = %d, data = %s", __func__, attr_handle, + BT_DBG("write, handle %d, len %d, data %s", attr_handle, ctxt->om->om_len, bt_hex(ctxt->om->om_data, ctxt->om->om_len)); @@ -1609,7 +1601,7 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, } } } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) { - BT_ERR("%s, Unhandled read request for chr and dsc: opcode - %d", __func__, ctxt->op); + BT_ERR("Unhandled read request for chr and dsc: opcode - %d", ctxt->op); } return 0; } @@ -1780,7 +1772,7 @@ int bt_mesh_rand(void *buf, size_t len) memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t)); } - BT_DBG("%s, rand: %s", __func__, bt_hex(buf, len)); + BT_DBG("Rand %s", bt_hex(buf, len)); return 0; } @@ -1813,7 +1805,7 @@ const u8_t *bt_mesh_pub_key_get(void) int rc = ble_sm_alg_gen_key_pair(bt_mesh_public_key, pri_key); if (rc != 0) { - BT_ERR("%s, Failed to generate the key pair", __func__); + BT_ERR("Failed to generate the key pair"); return NULL; } memcpy(bt_mesh_private_key, pri_key, 32); @@ -1986,7 +1978,7 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info) { - BT_ERR("%s, Unsupported for NimBLE host", __func__); + BT_ERR("Unsupported for NimBLE host"); return 0; } #endif diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.c b/components/bt/esp_ble_mesh/mesh_core/prov.c index dcd990e29..268f83d60 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/prov.c @@ -242,7 +242,7 @@ static void reset_state(void) link.rx.prev_id = XACT_NVAL; #if defined(CONFIG_BLE_MESH_PB_GATT) - link.rx.buf = bt_mesh_proxy_get_buf(); + link.rx.buf = bt_mesh_proxy_server_get_buf(); #else net_buf_simple_reset(&rx_buf); link.rx.buf = &rx_buf; @@ -323,7 +323,7 @@ static struct net_buf *adv_buf_create(void) buf = bt_mesh_adv_create(BLE_MESH_ADV_PROV, PROV_XMIT, BUF_TIMEOUT); if (!buf) { - BT_ERR("%s, Out of provisioning buffers", __func__); + BT_ERR("Out of provisioning buffers"); return NULL; } @@ -447,7 +447,7 @@ static int prov_send_adv(struct net_buf_simple *msg) u8_t xact_id = 0U; s32_t timeout = PROTOCOL_TIMEOUT; - BT_DBG("%s, len %u: %s", __func__, msg->len, bt_hex(msg->data, msg->len)); + BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); prov_clear_tx(); @@ -476,7 +476,7 @@ static int prov_send_adv(struct net_buf_simple *msg) buf = start; for (seg_id = 1U; msg->len > 0; seg_id++) { if (seg_id >= ARRAY_SIZE(link.tx.buf)) { - BT_ERR("%s, Too big message", __func__); + BT_ERR("Too big message (seg_id %d)", seg_id); free_segments(); return -E2BIG; } @@ -530,9 +530,9 @@ static int prov_send_gatt(struct net_buf_simple *msg) /* Changed by Espressif, add provisioning timeout timer operations. * When sending a provisioning PDU successfully, restart the 60s timer. */ - err = bt_mesh_proxy_send(link.conn, BLE_MESH_PROXY_PROV, msg); + err = bt_mesh_proxy_server_send(link.conn, BLE_MESH_PROXY_PROV, msg); if (err) { - BT_ERR("%s, Failed to send provisioning PDU", __func__); + BT_ERR("Failed to send provisioning PDU"); return err; } @@ -617,7 +617,7 @@ static void prov_invite(const u8_t *data) memcpy(&link.conf_inputs[1], &buf.data[1], 11); if (prov_send(&buf)) { - BT_ERR("%s, Failed to send capabilities", __func__); + BT_ERR("Failed to send capabilities"); return; } @@ -795,13 +795,13 @@ static void prov_start(const u8_t *data) BT_INFO("Auth Size: 0x%02x", data[4]); if (data[0] != PROV_ALG_P256) { - BT_ERR("%s, Unknown algorithm 0x%02x", __func__, data[0]); + BT_ERR("Unknown algorithm 0x%02x", data[0]); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } if (data[1] != prov->oob_pub_key) { - BT_ERR("%s, Invalid public key type: 0x%02x", __func__, data[1]); + BT_ERR("Invalid public key type: 0x%02x", data[1]); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -820,9 +820,9 @@ static void prov_start(const u8_t *data) } if (prov_auth(data[2], data[3], data[4]) < 0) { - BT_ERR("%s, Invalid authentication method: 0x%02x; " + BT_ERR("Invalid authentication method: 0x%02x; " "action: 0x%02x; size: 0x%02x", - __func__, data[2], data[3], data[4]); + data[2], data[3], data[4]); prov_send_fail_msg(PROV_ERR_NVAL_FMT); } } @@ -836,7 +836,7 @@ static void send_confirm(void) BT_DBG("ConfInputs[128] %s", bt_hex(&link.conf_inputs[128], 17)); if (bt_mesh_prov_conf_salt(link.conf_inputs, link.conf_salt)) { - BT_ERR("%s, Unable to generate confirmation salt", __func__); + BT_ERR("Unable to generate confirmation salt"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -844,7 +844,7 @@ static void send_confirm(void) BT_DBG("ConfirmationSalt: %s", bt_hex(link.conf_salt, 16)); if (bt_mesh_prov_conf_key(link.dhkey, link.conf_salt, link.conf_key)) { - BT_ERR("%s, Unable to generate confirmation key", __func__); + BT_ERR("Unable to generate confirmation key"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -852,7 +852,7 @@ static void send_confirm(void) BT_DBG("ConfirmationKey: %s", bt_hex(link.conf_key, 16)); if (bt_mesh_rand(link.rand, 16)) { - BT_ERR("%s, Unable to generate random number", __func__); + BT_ERR("Unable to generate random number"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -863,13 +863,13 @@ static void send_confirm(void) if (bt_mesh_prov_conf(link.conf_key, link.rand, link.auth, net_buf_simple_add(&cfm, 16))) { - BT_ERR("%s, Unable to generate confirmation value", __func__); + BT_ERR("Unable to generate confirmation value"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } if (prov_send(&cfm)) { - BT_ERR("%s, Unable to send Provisioning Confirm", __func__); + BT_ERR("Unable to send Provisioning Confirm"); return; } @@ -937,7 +937,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) BT_DBG("%p", key); if (!key) { - BT_ERR("%s, DHKey generation failed", __func__); + BT_ERR("DHKey generation failed"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -972,14 +972,14 @@ static void send_pub_key(void) sys_memcpy_swap(&buf.data[32], &link.conf_inputs[49], 32); if (bt_mesh_dh_key_gen(buf.data, prov_dh_key_cb, 0)) { - BT_ERR("%s, Unable to generate DHKey", __func__); + BT_ERR("Unable to generate DHKey"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } key = bt_mesh_pub_key_get(); if (!key) { - BT_ERR("%s, No public key available", __func__); + BT_ERR("No public key available"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -1014,7 +1014,7 @@ static int bt_mesh_calc_dh_key(void) sys_memcpy_swap(&buf.data[32], &link.conf_inputs[49], 32); if (bt_mesh_dh_key_gen(buf.data, prov_dh_key_cb, 0)) { - BT_ERR("%s, Unable to generate DHKey", __func__); + BT_ERR("Unable to generate DHKey"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return -EIO; } @@ -1059,7 +1059,7 @@ static void prov_pub_key(const u8_t *data) * (3) X = 0, Y = 0 */ if (!bt_mesh_check_public_key(data)) { - BT_ERR("%s, Invalid public key", __func__); + BT_ERR("Invalid public key"); prov_send_fail_msg(PROV_ERR_UNEXP_PDU); return; } @@ -1116,13 +1116,13 @@ static void prov_random(const u8_t *data) BT_DBG("Remote Random: %s", bt_hex(data, 16)); if (bt_mesh_prov_conf(link.conf_key, data, link.auth, conf_verify)) { - BT_ERR("%s, Unable to calculate confirmation verification", __func__); + BT_ERR("Unable to calculate confirmation verification"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } if (memcmp(conf_verify, link.conf, 16)) { - BT_ERR("%s, Invalid confirmation value", __func__); + BT_ERR("Invalid confirmation value"); BT_DBG("Received: %s", bt_hex(link.conf, 16)); BT_DBG("Calculated: %s", bt_hex(conf_verify, 16)); prov_send_fail_msg(PROV_ERR_CFM_FAILED); @@ -1133,13 +1133,13 @@ static void prov_random(const u8_t *data) net_buf_simple_add_mem(&rnd, link.rand, 16); if (prov_send(&rnd)) { - BT_ERR("%s, Failed to send Provisioning Random", __func__); + BT_ERR("Failed to send Provisioning Random"); return; } if (bt_mesh_prov_salt(link.conf_salt, data, link.rand, link.prov_salt)) { - BT_ERR("%s, Failed to generate provisioning salt", __func__); + BT_ERR("Failed to generate provisioning salt"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -1176,7 +1176,7 @@ static void prov_data(const u8_t *data) err = bt_mesh_session_key(link.dhkey, link.prov_salt, session_key); if (err) { - BT_ERR("%s, Unable to generate session key", __func__); + BT_ERR("Unable to generate session key"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -1185,7 +1185,7 @@ static void prov_data(const u8_t *data) err = bt_mesh_prov_nonce(link.dhkey, link.prov_salt, nonce); if (err) { - BT_ERR("%s, Unable to generate session nonce", __func__); + BT_ERR("Unable to generate session nonce"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -1194,14 +1194,14 @@ static void prov_data(const u8_t *data) err = bt_mesh_prov_decrypt(session_key, nonce, data, pdu); if (err) { - BT_ERR("%s, Unable to decrypt provisioning data", __func__); + BT_ERR("Unable to decrypt provisioning data"); prov_send_fail_msg(PROV_ERR_DECRYPT); return; } err = bt_mesh_dev_key(link.dhkey, link.prov_salt, dev_key); if (err) { - BT_ERR("%s, Unable to generate device key", __func__); + BT_ERR("Unable to generate device key"); prov_send_fail_msg(PROV_ERR_UNEXP_ERR); return; } @@ -1328,7 +1328,7 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) BT_DBG("len %u", buf->len); if (buf->len < 16) { - BT_ERR("%s, Too short bearer open message (len %u)", __func__, buf->len); + BT_ERR("Too short bearer open message (len %u)", buf->len); return; } @@ -1403,7 +1403,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf) link_close(rx, buf); break; default: - BT_ERR("%s, Unknown bearer opcode: 0x%02x", __func__, BEARER_CTL(rx->gpc)); + BT_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc)); return; } } @@ -1415,7 +1415,7 @@ static void prov_msg_recv(void) BT_DBG("type 0x%02x len %u", type, link.rx.buf->len); if (!bt_mesh_fcs_check(link.rx.buf, link.rx.fcs)) { - BT_ERR("%s, Incorrect FCS", __func__); + BT_ERR("Incorrect FCS"); return; } @@ -1436,14 +1436,14 @@ static void prov_msg_recv(void) } if (type >= ARRAY_SIZE(prov_handlers)) { - BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type); + BT_ERR("Unknown provisioning PDU type 0x%02x", type); prov_send_fail_msg(PROV_ERR_NVAL_PDU); return; } if (1 + prov_handlers[type].len != link.rx.buf->len) { - BT_ERR("%s, Invalid length %u for type 0x%02x", - __func__, link.rx.buf->len, type); + BT_ERR("Invalid length %u for type 0x%02x", + link.rx.buf->len, type); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -1475,7 +1475,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) } if (seg > link.rx.last_seg) { - BT_ERR("%s, Invalid segment index %u", __func__, seg); + BT_ERR("Invalid segment index %u", seg); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } else if (seg == link.rx.last_seg) { @@ -1484,8 +1484,8 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) expect_len = (link.rx.buf->len - 20U - ((link.rx.last_seg - 1) * 23U)); if (expect_len != buf->len) { - BT_ERR("%s, Incorrect last seg len: %u != %u", - __func__, expect_len, buf->len); + BT_ERR("Incorrect last seg len: %u != %u", + expect_len, buf->len); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -1538,20 +1538,20 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) START_LAST_SEG(rx->gpc), link.rx.buf->len, link.rx.fcs); if (link.rx.buf->len < 1) { - BT_ERR("%s, Ignoring zero-length provisioning PDU", __func__); + BT_ERR("Ignoring zero-length provisioning PDU"); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } if (link.rx.buf->len > link.rx.buf->size) { - BT_ERR("%s, Too large provisioning PDU (%u bytes)", - __func__, link.rx.buf->len); + BT_ERR("Too large provisioning PDU (%u bytes)", + link.rx.buf->len); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20U) { - BT_ERR("%s, Too small total length for multi-segment PDU", __func__); + BT_ERR("Too small total length for multi-segment PDU"); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -1580,7 +1580,7 @@ static const struct { static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf) { if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) { - BT_ERR("%s, Too short GPC message type %u", __func__, GPCF(rx->gpc)); + BT_ERR("Too short GPC message type %u", GPCF(rx->gpc)); return; } @@ -1647,12 +1647,12 @@ int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf) } if (type >= ARRAY_SIZE(prov_handlers)) { - BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type); + BT_ERR("Unknown provisioning PDU type 0x%02x", type); return -EINVAL; } if (prov_handlers[type].len != buf->len) { - BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, buf->len, type); + BT_ERR("Invalid length %u for type 0x%02x", buf->len, type); return -EINVAL; } @@ -1689,7 +1689,7 @@ int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn) BT_DBG("conn %p", conn); if (link.conn != conn) { - BT_ERR("%s, Not connected", __func__); + BT_ERR("Not connected"); return -ENOTCONN; } @@ -1739,23 +1739,23 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info) const u8_t *key = NULL; if (!prov_info) { - BT_ERR("%s, No provisioning context provided", __func__); + BT_ERR("No provisioning context provided"); return -EINVAL; } if (prov_info->static_val_len > BLE_MESH_PROV_STATIC_OOB_MAX_LEN || prov_info->output_size > BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN || prov_info->input_size > BLE_MESH_PROV_INPUT_OOB_MAX_LEN) { - BT_ERR("%s, Invalid auth oob length", __func__); + BT_ERR("Invalid authentication oob length"); return -EINVAL; } - __ASSERT(prov_info->uuid, "%s, Device UUID is not initialized", __func__); + __ASSERT(prov_info->uuid, "Device UUID not initialized"); /* Changed by Espressif. Use micro-ecc to generate public key now. */ key = bt_mesh_pub_key_get(); if (!key) { - BT_ERR("%s, Failed to generate public key", __func__); + BT_ERR("Failed to generate public key"); return -EIO; } @@ -1779,7 +1779,7 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info) int bt_mesh_prov_deinit(void) { if (prov == NULL) { - BT_ERR("%s, No provisioning context provided", __func__); + BT_ERR("No provisioning context provided"); return -EINVAL; } @@ -1806,7 +1806,8 @@ int bt_mesh_prov_deinit(void) return 0; } -void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index) +void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], + u16_t addr, u8_t flags, u32_t iv_index) { if (prov->complete) { prov->complete(net_idx, net_key, addr, flags, iv_index); diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.h b/components/bt/esp_ble_mesh/mesh_core/prov.h index a1872bd84..04466b6ba 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/prov.h @@ -32,7 +32,8 @@ const struct bt_mesh_prov *bt_mesh_prov_get(void); int bt_mesh_prov_init(const struct bt_mesh_prov *prov); int bt_mesh_prov_deinit(void); -void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index); +void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], + u16_t addr, u8_t flags, u32_t iv_index); void bt_mesh_prov_reset(void); #ifdef __cplusplus diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c index 58feece1f..fd6008a8e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c @@ -22,6 +22,7 @@ #include "settings.h" #include "friend.h" #include "transport.h" +#include "foundation.h" #include "mesh_common.h" #include "proxy_client.h" #include "provisioner_prov.h" @@ -79,15 +80,10 @@ int bt_mesh_provisioner_net_create(void) prov = bt_mesh_provisioner_get_prov_info(); if (!prov) { - BT_ERR("%s, NULL provisioning context", __func__); + BT_ERR("No provisioning context provided"); return -EINVAL; } - /* If the device only acts as a Provisioner, need to initialize - * each element's address. - */ - bt_mesh_comp_provision(bt_mesh_provisioner_get_primary_elem_addr()); - if (bt_mesh.p_sub[0]) { /* Provisioner is already enabled (enable -> disable -> enable), * or Provisioner is restored from flash. @@ -99,20 +95,20 @@ int bt_mesh_provisioner_net_create(void) /* Generate the primary netkey */ if (bt_mesh_rand(p_key, 16)) { - BT_ERR("%s, Failed to generate Primary NetKey", __func__); + BT_ERR("Failed to generate Primary NetKey"); return -EIO; } sub = bt_mesh_calloc(sizeof(struct bt_mesh_subnet)); if (!sub) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } sub->kr_flag = BLE_MESH_KEY_REFRESH(prov->flags); if (sub->kr_flag) { if (bt_mesh_net_keys_create(&sub->keys[1], p_key)) { - BT_ERR("%s, Failed to generate net-related keys", __func__); + BT_ERR("Failed to generate net-related keys"); bt_mesh_free(sub); return -EIO; } @@ -120,7 +116,7 @@ int bt_mesh_provisioner_net_create(void) } else { /* Currently provisioner only use keys[0] */ if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) { - BT_ERR("%s, Failed to create net-related keys", __func__); + BT_ERR("Failed to create net-related keys"); bt_mesh_free(sub); return -EIO; } @@ -157,7 +153,7 @@ int bt_mesh_provisioner_net_create(void) } done: - BT_INFO("NetKey Index 0x%03x, NID 0x%02x", sub->net_idx, sub->keys[0].nid); + BT_INFO("NetKeyIndex 0x%03x, NID 0x%02x", sub->net_idx, sub->keys[0].nid); BT_INFO("NetKey %s", bt_hex(sub->keys[0].net, 16)); return 0; @@ -167,28 +163,22 @@ int bt_mesh_provisioner_deinit(bool erase) { int i; - for (i = 0; i < CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT; i++) { + for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) { if (bt_mesh.p_sub[i]) { - if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_p_subnet(bt_mesh.p_sub[i]); - } - bt_mesh_free(bt_mesh.p_sub[i]); - bt_mesh.p_sub[i] = NULL; + bt_mesh_provisioner_local_net_key_del(bt_mesh.p_sub[i]->net_idx, erase); } } - for (i = 0; i < CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT; i++) { - if (bt_mesh.p_app_keys[i]) { - if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_p_app_key(bt_mesh.p_app_keys[i]); - } - bt_mesh_free(bt_mesh.p_app_keys[i]); - bt_mesh.p_app_keys[i] = NULL; - } - } + /* Clear model state that isn't otherwise cleared. E.g. AppKey + * binding and model publication is cleared as a consequence + * of removing all app keys, however model subscription clearing + * must be taken care of here. + */ + bt_mesh_mod_sub_reset(erase); bt_mesh.p_net_idx_next = 0U; bt_mesh.p_app_idx_next = 0U; + if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { bt_mesh_clear_p_net_idx(); bt_mesh_clear_p_app_idx(); @@ -216,13 +206,13 @@ bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_ if (comp_with_own) { comp = bt_mesh_comp_get(); if (!comp) { - BT_ERR("NULL composition data"); + BT_ERR("Invalid composition data"); return true; } primary_addr = bt_mesh_provisioner_get_primary_elem_addr(); if (!BLE_MESH_ADDR_IS_UNICAST(primary_addr)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, primary_addr); + BT_ERR("Invalid unicast address 0x%04x", primary_addr); return true; } } @@ -283,7 +273,7 @@ static int provisioner_store_node(struct bt_mesh_node *node, bool store, u16_t * if (mesh_nodes[i] == NULL) { mesh_nodes[i] = bt_mesh_calloc(sizeof(struct bt_mesh_node)); if (!mesh_nodes[i]) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_provisioner_unlock(); return -ENOMEM; } @@ -318,9 +308,11 @@ int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node) return provisioner_store_node(node, false, NULL); } -int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], u16_t oob_info, - u16_t unicast_addr, u8_t element_num, u16_t net_idx, u8_t flags, - u32_t iv_index, const u8_t dev_key[16], u16_t *index) +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], + u16_t oob_info, u16_t unicast_addr, + u8_t element_num, u16_t net_idx, + u8_t flags, u32_t iv_index, + const u8_t dev_key[16], u16_t *index) { struct bt_mesh_node node = {0}; @@ -331,10 +323,10 @@ int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16 return -EINVAL; } - BT_INFO("unicast_addr 0x%04x, elem_num %d, net_idx 0x%04x", - unicast_addr, element_num, net_idx); - BT_INFO("dev_uuid %s", bt_hex(uuid, 16)); - BT_INFO("dev_key %s", bt_hex(dev_key, 16)); + BT_INFO("Unicast addr 0x%04x, element num %d, NetKeyIndex 0x%04x", + unicast_addr, element_num, net_idx); + BT_INFO("UUID %s", bt_hex(uuid, 16)); + BT_INFO("DevKey %s", bt_hex(dev_key, 16)); memcpy(node.addr, addr->val, BLE_MESH_ADDR_LEN); node.addr_type = addr->type; @@ -404,7 +396,7 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16], BT_DBG("%s", __func__); if (uuid == NULL) { - BT_ERR("%s, Invalid device uuid", __func__); + BT_ERR("Invalid device uuid"); return NULL; } @@ -441,7 +433,7 @@ int bt_mesh_provisioner_remove_node(const u8_t uuid[16]) node = provisioner_find_node_with_uuid(uuid, &index); if (!node) { - BT_WARN("%s, Node not exists, uuid %s", __func__, bt_hex(uuid, 16)); + BT_WARN("Node not found, uuid %s", bt_hex(uuid, 16)); return -ENODEV; } @@ -457,7 +449,7 @@ static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *i BT_DBG("%s", __func__); if (!BLE_MESH_ADDR_IS_UNICAST(addr)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, addr); + BT_ERR("Invalid unicast address 0x%04x", addr); return NULL; } @@ -485,7 +477,7 @@ int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name) node = provisioner_find_node_with_addr(addr, NULL); if (node == NULL) { - BT_ERR("%s, Node not exists, addr 0x%04x", __func__, addr); + BT_ERR("Node not found, addr 0x%04x", addr); return -ENODEV; } @@ -512,7 +504,7 @@ int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16]) node = provisioner_find_node_with_uuid(uuid, &index); if (!node) { - BT_WARN("%s, Node not exists, uuid %s", __func__, bt_hex(uuid, 16)); + BT_WARN("Node not found, uuid %s", bt_hex(uuid, 16)); return -ENODEV; } @@ -527,7 +519,7 @@ int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr) node = provisioner_find_node_with_addr(unicast_addr, &index); if (!node) { - BT_WARN("%s, Node not exists, addr 0x%04x", __func__, unicast_addr); + BT_WARN("Node not found, addr 0x%04x", unicast_addr); return -ENODEV; } @@ -550,57 +542,57 @@ int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr) return -ENODEV; } -static int provisioner_check_node_index(u16_t index) +static struct bt_mesh_node **provisioner_find_node_with_name(const char *name) { - BT_DBG("%s", __func__); - - if (index >= ARRAY_SIZE(mesh_nodes)) { - BT_ERR("%s, Too big node index %d", __func__, index); - return -EINVAL; - } - - if (mesh_nodes[index] == NULL) { - BT_ERR("%s, Node not exists, index %d", __func__, index); - return -ENODEV; - } - - return 0; -} - -int bt_mesh_provisioner_set_node_name(u16_t index, const char *name) -{ - size_t length = 0U, name_len = 0U; + size_t length = 0U; int i; - BT_DBG("%s", __func__); + BT_DBG("node name %s", name); - if (!name) { - BT_ERR("%s, Invalid parameter", __func__); - return -EINVAL; - } + length = MIN(strlen(name), BLE_MESH_NODE_NAME_SIZE); - if (provisioner_check_node_index(index)) { - return -EINVAL; - } + bt_mesh_provisioner_lock(); - BT_DBG("len %d, name %s", strlen(name), name); - - length = (strlen(name) <= BLE_MESH_NODE_NAME_SIZE) ? strlen(name) : BLE_MESH_NODE_NAME_SIZE; for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) { if (mesh_nodes[i]) { - name_len = strlen(mesh_nodes[i]->name); - if (length != name_len) { + if (strlen(mesh_nodes[i]->name) != length) { continue; } if (!strncmp(mesh_nodes[i]->name, name, length)) { - BT_WARN("Node name %s exists", name); - return -EEXIST; + bt_mesh_provisioner_unlock(); + return &mesh_nodes[i]; } } } + bt_mesh_provisioner_unlock(); + return NULL; +} + +int bt_mesh_provisioner_set_node_name(u16_t index, const char *name) +{ + if (index >= ARRAY_SIZE(mesh_nodes)) { + BT_ERR("Invalid node index %d", index); + return -EINVAL; + } + + if (mesh_nodes[index] == NULL) { + BT_ERR("Node not exists, index %d", index); + return -EINVAL; + } + + if (name == NULL) { + BT_ERR("Invalid node name"); + return -EINVAL; + } + + if (provisioner_find_node_with_name(name)) { + BT_WARN("Node name \"%s\" already exists", name); + return -EEXIST; + } + memset(mesh_nodes[index]->name, 0, sizeof(mesh_nodes[index]->name)); - strncpy(mesh_nodes[index]->name, name, length); + strncpy(mesh_nodes[index]->name, name, BLE_MESH_NODE_NAME_SIZE); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { bt_mesh_store_node_name(mesh_nodes[index]); @@ -611,9 +603,13 @@ int bt_mesh_provisioner_set_node_name(u16_t index, const char *name) const char *bt_mesh_provisioner_get_node_name(u16_t index) { - BT_DBG("%s", __func__); + if (index >= ARRAY_SIZE(mesh_nodes)) { + BT_ERR("Invalid node index %d", index); + return NULL; + } - if (provisioner_check_node_index(index)) { + if (mesh_nodes[index] == NULL) { + BT_ERR("Node not exists, index %d", index); return NULL; } @@ -622,31 +618,43 @@ const char *bt_mesh_provisioner_get_node_name(u16_t index) u16_t bt_mesh_provisioner_get_node_index(const char *name) { - size_t length = 0U, name_len = 0U; - int i; + struct bt_mesh_node **node = NULL; - BT_DBG("%s", __func__); - - if (!name) { - BT_ERR("%s, Invalid parameter", __func__); + if (name == NULL) { + BT_ERR("Invalid node name"); return BLE_MESH_INVALID_NODE_INDEX; } - length = (strlen(name) <= BLE_MESH_NODE_NAME_SIZE) ? strlen(name) : BLE_MESH_NODE_NAME_SIZE; - for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) { - if (mesh_nodes[i]) { - name_len = strlen(mesh_nodes[i]->name); - if (length != name_len) { - continue; - } - if (!strncmp(mesh_nodes[i]->name, name, length)) { - return (u16_t)i; - } - } + node = provisioner_find_node_with_name(name); + if (node == NULL) { + BT_ERR("Node name \"%s\" not exists", name); + return BLE_MESH_INVALID_NODE_INDEX; } - BT_ERR("Node name %s not exists", name); - return BLE_MESH_INVALID_NODE_INDEX; + return (node - mesh_nodes); +} + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_name(const char *name) +{ + struct bt_mesh_node **node = NULL; + + if (name == NULL) { + BT_ERR("Invalid node name"); + return NULL; + } + + node = provisioner_find_node_with_name(name); + if (node == NULL) { + BT_ERR("Node name \"%s\" not exists", name); + return NULL; + } + + return *node; +} + +const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void) +{ + return (const struct bt_mesh_node **)mesh_nodes; } #define COMP_DATA_PAGE_0_MIN_LEN 16 @@ -656,24 +664,24 @@ static int store_node_comp_data(u16_t addr, const u8_t *data, u16_t length, bool struct bt_mesh_node *node = NULL; if (!BLE_MESH_ADDR_IS_UNICAST(addr)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, addr); + BT_ERR("Invalid unicast address 0x%04x", addr); return -EINVAL; } if (data == NULL || (length % 2) || length < COMP_DATA_PAGE_0_MIN_LEN) { - BT_ERR("%s, Invalid composition data", __func__); + BT_ERR("Invalid composition data"); return -EINVAL; } node = provisioner_find_node_with_addr(addr, NULL); if (node == NULL) { - BT_ERR("%s, Node not exists, addr 0x%04x", __func__, addr); + BT_ERR("Node not found, addr 0x%04x", addr); return -ENODEV; } node->comp_data = bt_mesh_calloc(length); if (node->comp_data == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -775,7 +783,7 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst) BT_DBG("%s", __func__); if (!BLE_MESH_ADDR_IS_UNICAST(dst)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst); + BT_ERR("Invalid unicast address 0x%04x", dst); return NULL; } @@ -931,7 +939,8 @@ static int provisioner_check_net_key_full(void) return -ENOMEM; } -int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, u16_t *app_idx) +int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], + u16_t net_idx, u16_t *app_idx) { struct bt_mesh_app_keys *keys = NULL; struct bt_mesh_app_key *key = NULL; @@ -939,7 +948,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, int add = -1; if (bt_mesh.p_app_idx_next >= 0x1000) { - BT_ERR("No AppKey Index available"); + BT_ERR("No AppKeyIndex available"); return -EIO; } @@ -950,19 +959,19 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, /* Check if the same application key already exists */ if (provisioner_check_app_key(app_key, app_idx)) { - BT_WARN("AppKey exists, AppKey Index updated"); + BT_WARN("AppKey exists, AppKeyIndex updated"); return 0; } /* Check if the net_idx exists */ if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -ENODEV; } /* Check if the same app_idx already exists */ if (provisioner_check_app_idx(*app_idx, true)) { - BT_ERR("%s, AppKey Index 0x%03x exists", __func__, *app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", *app_idx); return -EEXIST; } @@ -983,13 +992,13 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, key = bt_mesh_calloc(sizeof(struct bt_mesh_app_key)); if (!key) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } keys = &key->keys[0]; if (bt_mesh_app_id(p_key, &keys->id)) { - BT_ERR("%s, Failed to generate AID", __func__); + BT_ERR("Failed to generate AID"); bt_mesh_free(key); return -EIO; } @@ -1004,7 +1013,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, if (provisioner_check_app_idx(key->app_idx, true)) { key->app_idx = (++bt_mesh.p_app_idx_next); if (key->app_idx >= 0x1000) { - BT_ERR("No AppKey Index available"); + BT_ERR("No AppKeyIndex available"); bt_mesh_free(key); return -EIO; } @@ -1013,6 +1022,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, } } *app_idx = key->app_idx; + bt_mesh.p_app_idx_next++; } key->updated = false; @@ -1026,13 +1036,14 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, return 0; } -int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_idx, u16_t app_idx) +int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], + u16_t net_idx, u16_t app_idx) { struct bt_mesh_app_keys *keys = NULL; struct bt_mesh_app_key *key = NULL; if (app_key == NULL) { - BT_ERR("%s, Invalid AppKey", __func__); + BT_ERR("Invalid AppKey"); return -EINVAL; } @@ -1040,19 +1051,19 @@ int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_i /* Check if the net_idx exists */ if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -ENODEV; } key = bt_mesh_provisioner_app_key_find(app_idx); if (key == NULL) { - BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); return -ENODEV; } keys = &key->keys[0]; if (bt_mesh_app_id(app_key, &keys->id)) { - BT_ERR("%s, Failed to generate AID", __func__); + BT_ERR("Failed to generate AID"); return -EIO; } @@ -1077,12 +1088,12 @@ const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx) BT_DBG("%s", __func__); if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return NULL; } if (provisioner_check_app_idx(app_idx, false)) { - BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); return NULL; } @@ -1100,7 +1111,7 @@ const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx) return NULL; } -static void model_pub_clear(struct bt_mesh_model *model) +static void model_pub_clear(struct bt_mesh_model *model, bool store) { if (!model->pub) { return; @@ -1122,14 +1133,14 @@ static void model_pub_clear(struct bt_mesh_model *model) k_delayed_work_cancel(&model->pub->timer); } - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && store) { bt_mesh_store_mod_pub(model); } return; } -static void model_unbind(struct bt_mesh_model *model, u16_t app_idx) +static void model_unbind(struct bt_mesh_model *model, u16_t app_idx, bool store) { int i; @@ -1142,36 +1153,42 @@ static void model_unbind(struct bt_mesh_model *model, u16_t app_idx) model->keys[i] = BLE_MESH_KEY_UNUSED; - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && store) { bt_mesh_store_mod_bind(model); } - model_pub_clear(model); + model_pub_clear(model, store); } } +struct unbind_data { + u16_t app_idx; + bool store; +}; + static void _model_unbind(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, bool vnd, bool primary, void *user_data) { - u16_t app_idx = *(u16_t *)user_data; + struct unbind_data *data = user_data; - model_unbind(mod, app_idx); + model_unbind(mod, data->app_idx, data->store); } -int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx) +int bt_mesh_provisioner_local_app_key_del(u16_t net_idx, u16_t app_idx, bool store) { + struct unbind_data data = { .app_idx = app_idx, .store = store }; struct bt_mesh_app_key *key = NULL; int i; BT_DBG("%s", __func__); if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -ENODEV; } if (provisioner_check_app_idx(app_idx, false)) { - BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); return -ENODEV; } @@ -1180,10 +1197,10 @@ int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx) if (key && key->net_idx == net_idx && key->app_idx == app_idx) { /* Remove the AppKey from the models if they are bound with it */ - bt_mesh_model_foreach(_model_unbind, &app_idx); + bt_mesh_model_foreach(_model_unbind, &data); - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_p_app_key(key); + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && store) { + bt_mesh_clear_p_app_key(app_idx); } bt_mesh_free(bt_mesh.p_app_keys[i]); @@ -1203,7 +1220,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx int add = -1; if (bt_mesh.p_net_idx_next >= 0x1000) { - BT_ERR("No NetKey Index available"); + BT_ERR("No NetKeyIndex available"); return -EIO; } @@ -1214,13 +1231,13 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx /* Check if the same network key already exists */ if (provisioner_check_net_key(net_key, net_idx)) { - BT_WARN("NetKey exists, NetKey Index updated"); + BT_WARN("NetKey exists, NetKeyIndex updated"); return 0; } /* Check if the same net_idx already exists */ if (provisioner_check_net_idx(*net_idx, true)) { - BT_ERR("%s, NetKey Index 0x%03x exists", __func__, *net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", *net_idx); return -EEXIST; } @@ -1241,12 +1258,12 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx sub = bt_mesh_calloc(sizeof(struct bt_mesh_subnet)); if (!sub) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) { - BT_ERR("%s, Failed to generate NID", __func__); + BT_ERR("Failed to generate NID"); bt_mesh_free(sub); return -EIO; } @@ -1259,7 +1276,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx if (provisioner_check_net_idx(sub->net_idx, true)) { sub->net_idx = (++bt_mesh.p_net_idx_next); if (sub->net_idx >= 0x1000) { - BT_ERR("No NetKey Index available"); + BT_ERR("No NetKeyIndex available"); bt_mesh_free(sub); return -EIO; } @@ -1268,6 +1285,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx } } *net_idx = sub->net_idx; + bt_mesh.p_net_idx_next++; } sub->kr_phase = BLE_MESH_KR_NORMAL; sub->kr_flag = false; @@ -1289,7 +1307,7 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i int err = 0; if (net_key == NULL) { - BT_ERR("%s, Invalid NetKey", __func__); + BT_ERR("Invalid NetKey"); return -EINVAL; } @@ -1297,13 +1315,13 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i sub = bt_mesh_provisioner_subnet_get(net_idx); if (sub == NULL) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -ENODEV; } err = bt_mesh_net_keys_create(&sub->keys[0], net_key); if (err) { - BT_ERR("%s, Failed to generate NID", __func__); + BT_ERR("Failed to generate NID"); return -EIO; } @@ -1316,7 +1334,7 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i err = bt_mesh_net_beacon_update(sub); if (err) { - BT_ERR("%s, Failed to update secure beacon", __func__); + BT_ERR("Failed to update secure beacon"); return -EIO; } @@ -1335,7 +1353,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx) BT_DBG("%s", __func__); if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return NULL; } @@ -1352,7 +1370,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx) return NULL; } -int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx) +int bt_mesh_provisioner_local_net_key_del(u16_t net_idx, bool store) { struct bt_mesh_subnet *sub = NULL; int i, j; @@ -1360,7 +1378,7 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx) BT_DBG("%s", __func__); if (provisioner_check_net_idx(net_idx, false)) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -ENODEV; } @@ -1370,13 +1388,14 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx) /* Delete any app keys bound to this NetKey index */ for (j = 0; j < ARRAY_SIZE(bt_mesh.p_app_keys); j++) { struct bt_mesh_app_key *key = bt_mesh.p_app_keys[j]; + if (key && key->net_idx == sub->net_idx) { - bt_mesh_provisioner_local_app_key_delete(key->net_idx, key->app_idx); + bt_mesh_provisioner_local_app_key_del(key->net_idx, key->app_idx, store); } } - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_p_subnet(sub); + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && store) { + bt_mesh_clear_p_subnet(net_idx); } bt_mesh_free(bt_mesh.p_sub[i]); @@ -1390,7 +1409,7 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx) } int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx) + u16_t cid, u16_t app_idx) { struct bt_mesh_model *model = NULL; struct bt_mesh_elem *elem = NULL; @@ -1398,7 +1417,7 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, elem = bt_mesh_elem_find(elem_addr); if (!elem) { - BT_ERR("%s, No element found, addr 0x%04x", __func__, elem_addr); + BT_ERR("No element found, addr 0x%04x", elem_addr); return -ENODEV; } @@ -1408,12 +1427,12 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, model = bt_mesh_model_find_vnd(elem, cid, mod_id); } if (!model) { - BT_ERR("%s, No model is found", __func__); + BT_ERR("No model found, model id 0x%04x, cid 0x%04x", mod_id, cid); return -ENODEV; } if (provisioner_check_app_idx(app_idx, false)) { - BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); return -ENODEV; } @@ -1448,7 +1467,7 @@ int bt_mesh_print_local_composition_data(void) comp = bt_mesh_comp_get(); if (!comp) { - BT_ERR("%s, NULL composition data", __func__); + BT_ERR("Invalid composition data"); return -EINVAL; } @@ -1486,33 +1505,33 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node) } if (!BLE_MESH_ADDR_IS_UNICAST(node->unicast_addr)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, node->unicast_addr); + BT_ERR("Invalid unicast address 0x%04x", node->unicast_addr); return -EINVAL; } if (node->element_num == 0) { - BT_ERR("%s, Invalid element count %d", __func__, node->element_num); + BT_ERR("Invalid element count %d", node->element_num); return -EINVAL; } if (bt_mesh_provisioner_check_is_addr_dup(node->unicast_addr, node->element_num, true)) { - BT_ERR("%s, Unicast address 0x%04x is duplicated", __func__, node->unicast_addr); + BT_ERR("Duplicate unicast address 0x%04x", node->unicast_addr); return -EINVAL; } if (node->unicast_addr + node->element_num - 1 > 0x7FFF) { - BT_ERR("%s, Not enough unicast address for the node", __func__); + BT_ERR("Not enough unicast address for the node"); return -EIO; } if (bt_mesh_provisioner_net_key_get(node->net_idx) == NULL) { - BT_ERR("%s, Invalid NetKey Index 0x%03x", __func__, node->net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", node->net_idx); return -EINVAL; } err = provisioner_store_node(node, true, NULL); if (err) { - BT_ERR("%s, Failed to store node info", __func__); + BT_ERR("Failed to store node info"); return err; } @@ -1522,149 +1541,3 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node) #endif /* CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK */ #endif /* CONFIG_BLE_MESH_PROVISIONER */ - -/* The following APIs are for fast provisioning */ - -#if CONFIG_BLE_MESH_FAST_PROV - -const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst) -{ - struct bt_mesh_node *node = NULL; - int i; - - BT_DBG("%s", __func__); - - if (!BLE_MESH_ADDR_IS_UNICAST(dst)) { - BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst); - return NULL; - } - - if (dst == bt_mesh_primary_addr()) { - return bt_mesh.dev_key; - } - - for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) { - node = mesh_nodes[i]; - if (node && node->unicast_addr == dst) { - return node->dev_key; - } - } - - return NULL; -} - -struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx) -{ - struct bt_mesh_subnet *sub = NULL; - int i; - - BT_DBG("%s", __func__); - - for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) { - sub = &bt_mesh.sub[i]; - if (sub->net_idx == net_idx) { - return sub; - } - } - - for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) { - sub = bt_mesh.p_sub[i]; - if (sub && sub->net_idx == net_idx) { - return sub; - } - } - - return NULL; -} - -struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx) -{ - struct bt_mesh_app_key *key = NULL; - int i; - - BT_DBG("%s", __func__); - - for (i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) { - key = &bt_mesh.app_keys[i]; - if (key->net_idx != BLE_MESH_KEY_UNUSED && - key->app_idx == app_idx) { - return key; - } - } - - for (i = 0; i < ARRAY_SIZE(bt_mesh.p_app_keys); i++) { - key = bt_mesh.p_app_keys[i]; - if (key && key->net_idx != BLE_MESH_KEY_UNUSED && - key->app_idx == app_idx) { - return key; - } - } - - return NULL; -} - -u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx) -{ - struct bt_mesh_subnet_keys *key = NULL; - struct bt_mesh_subnet *sub = NULL; - - sub = bt_mesh_fast_prov_subnet_get(net_idx); - if (sub) { - key = BLE_MESH_KEY_REFRESH(sub->kr_flag) ? &sub->keys[1] : &sub->keys[0]; - return bt_mesh_provisioner_set_fast_prov_net_idx(key->net, net_idx); - } - - /* If net_idx is not found, set net_idx to fast_prov first, - * and wait for primary provisioner to add net_key */ - return bt_mesh_provisioner_set_fast_prov_net_idx(NULL, net_idx); -} - -u8_t bt_mesh_add_fast_prov_net_key(const u8_t net_key[16]) -{ - const u8_t *keys = NULL; - u16_t net_idx = 0U; - int err = 0; - - net_idx = bt_mesh_provisioner_get_fast_prov_net_idx(); - bt_mesh.p_net_idx_next = net_idx; - - err = bt_mesh_provisioner_local_net_key_add(net_key, &net_idx); - if (err) { - return 0x01; /* status: add net_key fail */ - }; - - keys = bt_mesh_provisioner_local_net_key_get(net_idx); - if (!keys) { - return 0x01; /* status: add net_key fail */ - } - - return bt_mesh_provisioner_set_fast_prov_net_idx(keys, net_idx); -} - -const u8_t *bt_mesh_get_fast_prov_net_key(u16_t net_idx) -{ - struct bt_mesh_subnet *sub = NULL; - - sub = bt_mesh_fast_prov_subnet_get(net_idx); - if (!sub) { - BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx); - return NULL; - } - - return (sub->kr_flag ? sub->keys[1].net : sub->keys[0].net); -} - -const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx) -{ - struct bt_mesh_app_key *key = NULL; - - key = bt_mesh_fast_prov_app_key_find(app_idx); - if (!key) { - BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx); - return NULL; - } - - return (key->updated ? key->keys[1].val : key->keys[0].val); -} - -#endif /* CONFIG_BLE_MESH_FAST_PROV */ diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h index f5552cd24..5cc6490d5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h @@ -59,9 +59,11 @@ u16_t bt_mesh_provisioner_get_node_count(void); int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node); -int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], u16_t oob_info, - u16_t unicast_addr, u8_t element_num, u16_t net_idx, u8_t flags, - u32_t iv_index, const u8_t dev_key[16], u16_t *index); +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], + u16_t oob_info, u16_t unicast_addr, + u8_t element_num, u16_t net_idx, + u8_t flags, u32_t iv_index, + const u8_t dev_key[16], u16_t *index); int bt_mesh_provisioner_remove_node(const u8_t uuid[16]); @@ -85,6 +87,10 @@ const char *bt_mesh_provisioner_get_node_name(u16_t index); u16_t bt_mesh_provisioner_get_node_index(const char *name); +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_name(const char *name); + +const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void); + int bt_mesh_provisioner_store_node_comp_data(u16_t addr, const u8_t *data, u16_t length); const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx); @@ -97,13 +103,15 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst); struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx); -int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx, u16_t *app_idx); +int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], + u16_t net_idx, u16_t *app_idx); -int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], u16_t net_idx, u16_t app_idx); +int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], + u16_t net_idx, u16_t app_idx); const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx); -int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx); +int bt_mesh_provisioner_local_app_key_del(u16_t net_idx, u16_t app_idx, bool store); int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx); @@ -111,33 +119,17 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx); -int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx); +int bt_mesh_provisioner_local_net_key_del(u16_t net_idx, bool store); /* Provisioner bind local client model with proper appkey index */ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx); + u16_t cid, u16_t app_idx); /* Provisioner print own element information */ int bt_mesh_print_local_composition_data(void); int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node); -/* The following APIs are for fast provisioning */ - -const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst); - -struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx); - -struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx); - -u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx); - -u8_t bt_mesh_add_fast_prov_net_key(const u8_t net_key[16]); - -const u8_t *bt_mesh_get_fast_prov_net_key(u16_t net_idx); - -const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c index d385eb701..e9fcd1278 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c @@ -20,6 +20,7 @@ #include "mesh.h" #include "access.h" #include "settings.h" +#include "fast_prov.h" #include "mesh_common.h" #include "proxy_client.h" #include "provisioner_prov.h" @@ -236,7 +237,7 @@ struct bt_mesh_prov_ctx { u16_t curr_net_idx; /* Current flags going to be used in provisioning data */ - u16_t curr_flags; + u8_t curr_flags; /* Current iv_index going to be used in provisioning data */ u16_t curr_iv_index; @@ -276,7 +277,6 @@ struct bt_mesh_prov_ctx { struct { bool enable; u16_t net_idx; - const u8_t *net_key; u8_t flags; u32_t iv_index; u16_t unicast_addr_min; @@ -447,7 +447,7 @@ void bt_mesh_provisioner_clear_link_info(const u8_t addr[6]) return; } - BT_DBG("%s, Clear device %s info", __func__, bt_hex(addr, BLE_MESH_ADDR_LEN)); + BT_DBG("Clear device info, addr %s", bt_hex(addr, BLE_MESH_ADDR_LEN)); for (i = CONFIG_BLE_MESH_PBA_SAME_TIME; i < BLE_MESH_PROV_SAME_TIME; i++) { if (!memcmp(link[i].addr.val, addr, BLE_MESH_ADDR_LEN)) { @@ -464,7 +464,7 @@ void bt_mesh_provisioner_clear_link_info(const u8_t addr[6]) } } - BT_WARN("Device address %s is not found", bt_hex(addr, BLE_MESH_ADDR_LEN)); + BT_WARN("Device not found, addr %s", bt_hex(addr, BLE_MESH_ADDR_LEN)); return; } #endif @@ -520,7 +520,7 @@ static int provisioner_dev_find(const bt_mesh_addr_t *addr, const u8_t uuid[16], } if (!uuid_match && !addr_match) { - BT_DBG("%s, Device does not exist in queue", __func__); + BT_DBG("Device not exists in queue"); return -ENODEV; } @@ -568,7 +568,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16]) if (link[i].connecting || bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) { #endif if (!memcmp(link[i].uuid, uuid, 16)) { - BT_DBG("%s, Device is being provisioned", __func__); + BT_DBG("Device is being provisioning"); return true; } } @@ -598,7 +598,7 @@ static int provisioner_check_unprov_dev_info(const u8_t uuid[16], bt_mesh_prov_b /* Check if the device uuid matches configured value */ if (is_unprov_dev_uuid_match(uuid) == false) { - BT_DBG("%s, Device uuid mismatch", __func__); + BT_DBG("Device uuid mismatch"); return -EIO; } @@ -685,7 +685,7 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr } } - BT_ERR("%s, No PB-ADV link is available", __func__); + BT_ERR("No PB-ADV link available"); bt_mesh_pb_adv_unlock(); return -ENOMEM; @@ -753,7 +753,7 @@ static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], const bt_mesh_add } } - BT_ERR("%s, No PB-GATT link is available", __func__); + BT_ERR("No PB-GATT link available"); bt_mesh_pb_gatt_unlock(); return -ENOMEM; @@ -785,31 +785,31 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u if ((add_dev->bearer & BLE_MESH_PROV_ADV) && (add_dev->bearer & BLE_MESH_PROV_GATT) && (flags & START_PROV_NOW)) { - BT_ERR("%s, Can not start PB-ADV & PB-GATT simultaneously", __func__); + BT_ERR("Can not start PB-ADV & PB-GATT simultaneously"); return -EINVAL; } if ((uuid_cmp == 0) && (flags & START_PROV_NOW)) { - BT_ERR("%s, Can not start provisioning with zero uuid", __func__); + BT_ERR("Can not start provisioning with zero uuid"); return -EINVAL; } if ((add_dev->bearer & BLE_MESH_PROV_GATT) && (flags & START_PROV_NOW) && ((addr_cmp == 0) || add_dev->addr_type > BLE_MESH_ADDR_RANDOM)) { - BT_ERR("%s, Invalid device address for PB-GATT", __func__); + BT_ERR("Invalid device address for PB-GATT"); return -EINVAL; } if (add_dev->bearer & BLE_MESH_PROV_GATT) { #if !CONFIG_BLE_MESH_PB_GATT - BT_ERR("%s, Not support PB-GATT", __func__); + BT_ERR("Not support PB-GATT"); return -EINVAL; #endif } if (add_dev->bearer & BLE_MESH_PROV_ADV) { #if !CONFIG_BLE_MESH_PB_ADV - BT_ERR("%s, Not support PB-ADV", __func__); + BT_ERR("Not support PB-ADV"); return -EINVAL; #endif } @@ -872,7 +872,7 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u } } - BT_ERR("%s, Unprovisioned device queue is full", __func__); + BT_ERR("Unprovisioned device queue is full"); return -ENOMEM; start: @@ -920,32 +920,32 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad int err = 0; if (uuid == NULL) { - BT_ERR("%s, NULL device uuid", __func__); + BT_ERR("Invalid device uuid"); return -EINVAL; } if (bearer != BLE_MESH_PROV_ADV && bearer != BLE_MESH_PROV_GATT) { - BT_ERR("%s, Invalid provisioning bearer 0x%02x", __func__, bearer); + BT_ERR("Invalid provisioning bearer 0x%02x", bearer); return -EINVAL; } if (!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && bearer == BLE_MESH_PROV_ADV) { - BT_ERR("%s, Not support PB-ADV", __func__); + BT_ERR("Not support PB-ADV"); return -ENOTSUP; } if (!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && bearer == BLE_MESH_PROV_GATT) { - BT_ERR("%s, Not support PB-GATT", __func__); + BT_ERR("Not support PB-GATT"); return -ENOTSUP; } if (bearer == BLE_MESH_PROV_GATT && (addr == NULL || addr_type > BLE_MESH_ADDR_RANDOM)) { - BT_ERR("%s, Invalid device address info", __func__); + BT_ERR("Invalid device address info"); return -EINVAL; } if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) { - BT_ERR("%s, Invalid unicast address 0x%04x", __func__, unicast_addr); + BT_ERR("Invalid unicast address 0x%04x", unicast_addr); return -EINVAL; } @@ -1001,18 +1001,10 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) { - /** - * Three Situations: - * 1. device is not being/been provisioned, just remove from device queue. - * 2. device is being provisioned, need to close link & remove from device queue. - * 3. device is been provisioned, need to send config_node_reset and may need to - * remove from device queue. config _node_reset can be added in function - * provisioner_reset_node() in provisioner_main.c. - */ bt_mesh_addr_t del_addr = {0}; - u8_t zero[16] = {0}; bool addr_match = false; bool uuid_match = false; + u8_t zero[16] = {0}; int addr_cmp = 0; int uuid_cmp = 0; u16_t i = 0U; @@ -1037,7 +1029,7 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) /* First: find if the device is in the device queue */ err = provisioner_dev_find(&del_addr, del_dev->uuid, &i); if (err) { - BT_DBG("%s, Device is not in the queue", __func__); + BT_DBG("Device not in queue"); } else { memset(&unprov_dev[i], 0x0, sizeof(struct unprov_dev_queue)); } @@ -1046,7 +1038,7 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) for (i = 0U; i < ARRAY_SIZE(link); i++) { if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) { if (!memcmp(link[i].addr.val, del_dev->addr, BLE_MESH_ADDR_LEN) && - link[i].addr.type == del_dev->addr_type) { + link[i].addr.type == del_dev->addr_type) { addr_match = true; } } @@ -1061,20 +1053,11 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) } } - /* Third: find if the device is been provisioned */ - if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) { - bt_mesh_provisioner_delete_node_with_dev_addr(&del_addr); - } - - if (uuid_cmp) { - bt_mesh_provisioner_delete_node_with_uuid(del_dev->uuid); - } - return 0; } int bt_mesh_provisioner_set_dev_uuid_match(u8_t offset, u8_t length, - const u8_t *match, bool prov_flag) + const u8_t *match, bool prov_flag) { if (length && (!match || (offset + length > 16))) { BT_ERR("%s, Invalid parameter", __func__); @@ -1115,7 +1098,7 @@ int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info) if (info->flag & NET_IDX_FLAG) { key = bt_mesh_provisioner_net_key_get(info->net_idx); if (!key) { - BT_ERR("%s, Failed to get NetKey", __func__); + BT_ERR("Failed to get NetKey"); return -EINVAL; } prov_ctx.curr_net_idx = info->net_idx; @@ -1128,24 +1111,27 @@ int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info) return 0; } -int bt_mesh_provisioner_set_prov_info(void) +int bt_mesh_provisioner_init_prov_info(void) { - const struct bt_mesh_comp *comp = NULL; - if (prov_ctx.primary_addr == BLE_MESH_ADDR_UNASSIGNED) { /* If unicast address of primary element of Provisioner has not been set * before, then the following initialization procedure will be used. */ - if (!BLE_MESH_ADDR_IS_UNICAST(prov->prov_unicast_addr) || - !BLE_MESH_ADDR_IS_UNICAST(prov->prov_start_address)) { - BT_ERR("%s, Invalid address, own 0x%04x, start 0x%04x", - __func__, prov->prov_unicast_addr, prov->prov_start_address); + if (prov == NULL) { + BT_ERR("No provisioning context provided"); return -EINVAL; } - comp = bt_mesh_comp_get(); + if (!BLE_MESH_ADDR_IS_UNICAST(prov->prov_unicast_addr) || + !BLE_MESH_ADDR_IS_UNICAST(prov->prov_start_address)) { + BT_ERR("Invalid address, own 0x%04x, start 0x%04x", + prov->prov_unicast_addr, prov->prov_start_address); + return -EINVAL; + } + + const struct bt_mesh_comp *comp = bt_mesh_comp_get(); if (!comp) { - BT_ERR("%s, NULL composition data", __func__); + BT_ERR("Invalid composition data"); return -EINVAL; } @@ -1156,15 +1142,19 @@ int bt_mesh_provisioner_set_prov_info(void) } else { prov_ctx.curr_alloc_addr = prov->prov_start_address; } + + /* Update primary element address with the initialized value here. */ prov_ctx.primary_addr = prov->prov_unicast_addr; if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { bt_mesh_store_prov_info(prov_ctx.primary_addr, prov_ctx.curr_alloc_addr); } } + prov_ctx.curr_net_idx = BLE_MESH_KEY_PRIMARY; - prov_ctx.curr_flags = prov->flags; - prov_ctx.curr_iv_index = prov->iv_index; + struct bt_mesh_subnet *sub = bt_mesh_provisioner_subnet_get(BLE_MESH_KEY_PRIMARY); + prov_ctx.curr_flags = bt_mesh_net_flags(sub); + prov_ctx.curr_iv_index = bt_mesh.iv_index; return 0; } @@ -1195,7 +1185,7 @@ int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length) /* Make sure Static OOB is not being used. */ for (i = 0; i < BLE_MESH_PROV_SAME_TIME; i++) { if (link[i].auth_method == AUTH_METHOD_STATIC) { - BT_ERR("%s, Static OOB is being used", __func__); + BT_ERR("Static OOB is being used"); return -EINVAL; } } @@ -1224,7 +1214,7 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr) comp = bt_mesh_comp_get(); if (!comp) { - BT_ERR("NULL composition data"); + BT_ERR("Invalid composition data"); return -EINVAL; } @@ -1241,7 +1231,8 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr) if (addr + comp->elem_count > prov_ctx.curr_alloc_addr) { prov_ctx.curr_alloc_addr = addr + comp->elem_count; } - BT_INFO("Provisioner primary address updated, old 0x%04x, new 0x%04x", prov_ctx.primary_addr, addr); + + BT_INFO("Primary address updated, old 0x%04x, new 0x%04x", prov_ctx.primary_addr, addr); prov_ctx.primary_addr = addr; if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { @@ -1259,7 +1250,7 @@ int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element u16_t max_addr = FAST_PROV_ENABLE() ? prov_ctx.fast_prov.unicast_addr_max : PROV_MAX_ADDR_TO_ASSIGN; if (unicast_addr + element_num > max_addr) { - BT_WARN("%s, Not enough unicast address to allocate", __func__); + BT_WARN("Not enough unicast address to allocate"); prov_ctx.curr_alloc_addr = BLE_MESH_ADDR_UNASSIGNED; } else { prov_ctx.curr_alloc_addr = unicast_addr + element_num; @@ -1280,17 +1271,9 @@ void bt_mesh_provisioner_fast_prov_enable(bool enable) prov_ctx.fast_prov.enable = enable; } -u8_t bt_mesh_provisioner_set_fast_prov_net_idx(const u8_t *net_key, u16_t net_idx) +void bt_mesh_provisioner_set_fast_prov_net_idx(u16_t net_idx) { prov_ctx.fast_prov.net_idx = net_idx; - prov_ctx.fast_prov.net_key = net_key; - - if (!net_key) { - BT_WARN("Wait for NetKey for fast provisioning"); - return 0x01; /*status: wait for net_key */ - } - - return 0x0; /* status: success */ } u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void) @@ -1301,17 +1284,17 @@ u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void) u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max) { if (!BLE_MESH_ADDR_IS_UNICAST(min) || !BLE_MESH_ADDR_IS_UNICAST(max)) { - BT_ERR("%s, Not a unicast address", __func__); + BT_ERR("Invalid unicast address, min 0x%04x, max 0x%04x", min, max); return 0x01; /* status: not a unicast address */ } if (min > max) { - BT_ERR("%s, Min bigger than max", __func__); + BT_ERR("Unicast address min is bigger than max"); return 0x02; /* status: min is bigger than max */ } if (min <= prov_ctx.fast_prov.unicast_addr_max) { - BT_ERR("%s, Address overlap", __func__); + BT_ERR("Unicast address overlap"); return 0x03; /* status: address overlaps with current value */ } @@ -1628,7 +1611,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg) u8_t xact_id = 0U; s32_t timeout = PROVISION_TIMEOUT; - BT_DBG("%s, len %u: %s", __func__, msg->len, bt_hex(msg->data, msg->len)); + BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); prov_clear_tx(idx); @@ -1657,7 +1640,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg) buf = start; for (seg_id = 1; msg->len > 0; seg_id++) { if (seg_id >= ARRAY_SIZE(link[idx].tx.buf)) { - BT_ERR("%s, Too big message", __func__); + BT_ERR("Too big message (seg_id %d)", seg_id); free_segments(idx); return -E2BIG; } @@ -1706,9 +1689,9 @@ static int prov_send_gatt(const u8_t idx, struct net_buf_simple *msg) return -ENOTCONN; } - err = bt_mesh_proxy_prov_client_send(link[idx].conn, BLE_MESH_PROXY_PROV, msg); + err = bt_mesh_proxy_client_send(link[idx].conn, BLE_MESH_PROXY_PROV, msg); if (err) { - BT_ERR("%s, Failed to send PB-GATT pdu", __func__); + BT_ERR("Failed to send PB-GATT pdu"); return err; } @@ -1738,7 +1721,7 @@ static inline int prov_send(const u8_t idx, struct net_buf_simple *buf) } #endif - BT_ERR("%s, Invalid link index %d", __func__, idx); + BT_ERR("Invalid link index %d", idx); return -EINVAL; } @@ -1774,7 +1757,7 @@ static void send_invite(const u8_t idx) link[idx].conf_inputs[0] = prov->prov_attention; if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Invite", __func__); + BT_ERR("Failed to send Provisioning Invite"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -1793,7 +1776,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) element_num = data[0]; BT_INFO("Elements: 0x%02x", element_num); if (!element_num) { - BT_ERR("%s, Invalid element number", __func__); + BT_ERR("Invalid element number %d", element_num); goto fail; } link[idx].element_num = element_num; @@ -1801,14 +1784,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) algorithms = sys_get_be16(&data[1]); BT_INFO("Algorithms: 0x%04x", algorithms); if (algorithms != BIT(PROV_ALG_P256)) { - BT_ERR("%s, Invalid algorithms", __func__); + BT_ERR("Invalid algorithms 0x%04x", algorithms); goto fail; } pub_key_oob = data[3]; BT_INFO("Public Key Type: 0x%02x", pub_key_oob); if (pub_key_oob > 0x01) { - BT_ERR("%s, Invalid public key type", __func__); + BT_ERR("Invalid public key type 0x%02x", pub_key_oob); goto fail; } pub_key_oob = ((prov->prov_pub_key_oob && @@ -1817,7 +1800,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) static_oob = data[4]; BT_INFO("Static OOB Type: 0x%02x", static_oob); if (static_oob > 0x01) { - BT_ERR("%s, Invalid Static OOB type", __func__); + BT_ERR("Invalid Static OOB type 0x%02x", static_oob); goto fail; } static_oob = (prov_ctx.static_oob_len ? static_oob : 0x00); @@ -1825,14 +1808,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) output_size = data[5]; BT_INFO("Output OOB Size: 0x%02x", output_size); if (output_size > 0x08) { - BT_ERR("%s, Invalid Output OOB size", __func__); + BT_ERR("Invalid Output OOB size %d", output_size); goto fail; } output_action = sys_get_be16(&data[6]); BT_INFO("Output OOB Action: 0x%04x", output_action); if (output_action > 0x1f) { - BT_ERR("%s, Invalid Output OOB action", __func__); + BT_ERR("Invalid Output OOB action 0x%04x", output_action); goto fail; } @@ -1847,14 +1830,14 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) input_size = data[8]; BT_INFO("Input OOB Size: 0x%02x", input_size); if (input_size > 0x08) { - BT_ERR("%s, Invalid Input OOB size", __func__); + BT_ERR("Invalid Input OOB size %d", input_size); goto fail; } input_action = sys_get_be16(&data[9]); BT_INFO("Input OOB Action: 0x%04x", input_action); if (input_action > 0x0f) { - BT_ERR("%s, Invalid Input OOB action", __func__); + BT_ERR("Invalid Input OOB action 0x%04x", input_action); goto fail; } @@ -1905,7 +1888,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) memcpy(&link[idx].conf_inputs[12], &buf.data[1], 5); if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Start", __func__); + BT_ERR("Failed to send Provisioning Start"); goto fail; } @@ -1919,7 +1902,7 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) */ if (pub_key_oob) { if (prov->prov_pub_key_oob_cb(idx)) { - BT_ERR("%s, Failed to notify input OOB Public Key", __func__); + BT_ERR("Failed to notify input OOB Public Key"); goto fail; } } @@ -1983,7 +1966,7 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size) link[idx].auth = (u8_t *)bt_mesh_calloc(PROV_AUTH_VAL_SIZE); if (!link[idx].auth) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); return -ENOMEM; } @@ -2072,25 +2055,25 @@ static void send_confirm(const u8_t idx) link[idx].conf_salt = (u8_t *)bt_mesh_calloc(PROV_CONF_SALT_SIZE); if (!link[idx].conf_salt) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); goto fail; } link[idx].conf_key = (u8_t *)bt_mesh_calloc(PROV_CONF_KEY_SIZE); if (!link[idx].conf_key) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); goto fail; } if (bt_mesh_prov_conf_salt(link[idx].conf_inputs, link[idx].conf_salt)) { - BT_ERR("%s, Failed to generate confirmation salt", __func__); + BT_ERR("Failed to generate confirmation salt"); goto fail; } BT_DBG("ConfirmationSalt: %s", bt_hex(link[idx].conf_salt, 16)); if (bt_mesh_prov_conf_key(link[idx].dhkey, link[idx].conf_salt, link[idx].conf_key)) { - BT_ERR("%s, Failed to generate confirmation key", __func__); + BT_ERR("Failed to generate confirmation key"); goto fail; } @@ -2102,7 +2085,7 @@ static void send_confirm(const u8_t idx) */ if (!(prov_ctx.rand_gen_done & BIT(0))) { if (bt_mesh_rand(prov_ctx.random, 16)) { - BT_ERR("%s, Failed to generate random number", __func__); + BT_ERR("Failed to generate random number"); goto fail; } link[idx].rand = prov_ctx.random; @@ -2118,12 +2101,12 @@ static void send_confirm(const u8_t idx) if (bt_mesh_prov_conf(link[idx].conf_key, link[idx].rand, link[idx].auth, net_buf_simple_add(&buf, 16))) { - BT_ERR("%s, Failed to generate confirmation value", __func__); + BT_ERR("Failed to generate confirmation value"); goto fail; } if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Confirm", __func__); + BT_ERR("Failed to send Provisioning Confirm"); goto fail; } @@ -2148,7 +2131,7 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool * input by provisioner is number or string. */ if (!link[idx].auth) { - BT_ERR("%s, Link auth is NULL", __func__); + BT_ERR("Invalid link auth"); return -EINVAL; } @@ -2167,7 +2150,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool return 0; } -int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_t size, bool num_flag) +int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, + u8_t size, bool num_flag) { /** This function should be called in the prov_output_num * callback, after the data has been output by provisioner. @@ -2184,7 +2168,7 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_ } if (!link[idx].auth) { - BT_ERR("%s, link auth is NULL", __func__); + BT_ERR("Invalid link auth"); return -EINVAL; } @@ -2205,10 +2189,11 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_ return 0; } -int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], const u8_t pub_key_y[32]) +int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], + const u8_t pub_key_y[32]) { if (!link[idx].conf_inputs) { - BT_ERR("%s, Link conf_inputs is NULL", __func__); + BT_ERR("Invalid link conf_inputs"); return -EINVAL; } @@ -2230,13 +2215,13 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) BT_DBG("%p", key); if (!key) { - BT_ERR("%s, Failed to generate DHKey", __func__); + BT_ERR("Failed to generate DHKey"); goto fail; } link[idx].dhkey = (u8_t *)bt_mesh_calloc(PROV_DH_KEY_SIZE); if (!link[idx].dhkey) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); goto fail; } sys_memcpy_swap(link[idx].dhkey, key, 32); @@ -2254,7 +2239,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) */ if (prov_auth(idx, link[idx].auth_method, link[idx].auth_action, link[idx].auth_size) < 0) { - BT_ERR("%s, Failed to authenticate", __func__); + BT_ERR("Failed to authenticate"); goto fail; } if (link[idx].auth_method == AUTH_METHOD_OUTPUT || @@ -2283,7 +2268,7 @@ static void prov_gen_dh_key(const u8_t idx) sys_memcpy_swap(&pub_key[32], &link[idx].conf_inputs[113], 32); if (bt_mesh_dh_key_gen(pub_key, prov_dh_key_cb, idx)) { - BT_ERR("%s, Failed to generate DHKey", __func__); + BT_ERR("Failed to generate DHKey"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2296,7 +2281,7 @@ static void send_pub_key(const u8_t idx, u8_t oob) key = bt_mesh_pub_key_get(); if (!key) { - BT_ERR("%s, No public key available", __func__); + BT_ERR("No public key available"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2315,7 +2300,7 @@ static void send_pub_key(const u8_t idx, u8_t oob) memcpy(&link[idx].conf_inputs[17], &buf.data[1], 64); if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Public Key", __func__); + BT_ERR("Failed to send Provisioning Public Key"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2399,7 +2384,7 @@ static void prov_confirm(const u8_t idx, const u8_t *data) link[idx].conf = (u8_t *)bt_mesh_calloc(PROV_CONFIRM_SIZE); if (!link[idx].conf) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2418,7 +2403,7 @@ static void prov_confirm(const u8_t idx, const u8_t *data) net_buf_simple_add_mem(&buf, link[idx].rand, 16); if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Random", __func__); + BT_ERR("Failed to send Provisioning Random"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2440,14 +2425,14 @@ static void send_prov_data(const u8_t idx) err = bt_mesh_session_key(link[idx].dhkey, link[idx].prov_salt, session_key); if (err) { - BT_ERR("%s, Failed to generate session key", __func__); + BT_ERR("Failed to generate session key"); goto fail; } BT_DBG("SessionKey: %s", bt_hex(session_key, 16)); err = bt_mesh_prov_nonce(link[idx].dhkey, link[idx].prov_salt, nonce); if (err) { - BT_ERR("%s, Failed to generate session nonce", __func__); + BT_ERR("Failed to generate session nonce"); goto fail; } BT_DBG("Nonce: %s", bt_hex(nonce, 13)); @@ -2456,10 +2441,10 @@ static void send_prov_data(const u8_t idx) * will be added to the primary subnet, and may add an API to choose to which * subnet will the device be provisioned later. */ - if (FAST_PROV_ENABLE()) { - netkey = prov_ctx.fast_prov.net_key; + if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && FAST_PROV_ENABLE()) { + netkey = bt_mesh_fast_prov_net_key_get(prov_ctx.fast_prov.net_idx); if (!netkey) { - BT_ERR("%s, Failed to get NetKey for fast provisioning", __func__); + BT_ERR("No NetKey for fast provisioning"); goto fail; } memcpy(pdu, netkey, 16); @@ -2469,7 +2454,7 @@ static void send_prov_data(const u8_t idx) } else { netkey = bt_mesh_provisioner_net_key_get(prov_ctx.curr_net_idx); if (!netkey) { - BT_ERR("%s, Failed to get NetKey for provisioning data", __func__); + BT_ERR("No NetKey for provisioning data"); goto fail; } memcpy(pdu, netkey, 16); @@ -2512,14 +2497,14 @@ static void send_prov_data(const u8_t idx) } else { /* If this device to be provisioned is a new device */ if (prov_ctx.curr_alloc_addr == BLE_MESH_ADDR_UNASSIGNED) { - BT_ERR("%s, No unicast address can be allocated", __func__); + BT_ERR("Not enough unicast address to be allocated"); goto fail; } alloc_addr = prov_ctx.curr_alloc_addr; } if (alloc_addr + link[idx].element_num - 1 > max_addr) { - BT_ERR("%s, Not enough unicast address for the device", __func__); + BT_ERR("Not enough unicast address for the device"); goto fail; } @@ -2528,7 +2513,7 @@ static void send_prov_data(const u8_t idx) * any unicast address of Provisioner. */ if (bt_mesh_provisioner_check_is_addr_dup(alloc_addr, link[idx].element_num, true)) { - BT_ERR("%s, Assigned address 0x%04x is duplicated", __func__, alloc_addr); + BT_ERR("Duplicate assigned address 0x%04x", alloc_addr); goto fail; } @@ -2540,12 +2525,12 @@ static void send_prov_data(const u8_t idx) err = bt_mesh_prov_encrypt(session_key, nonce, pdu, net_buf_simple_add(&buf, 33)); if (err) { - BT_ERR("%s, Failed to encrypt provisioning data", __func__); + BT_ERR("Failed to encrypt provisioning data"); goto fail; } if (prov_send(idx, &buf)) { - BT_ERR("%s, Failed to send Provisioning Data", __func__); + BT_ERR("Failed to send Provisioning Data"); goto fail; } @@ -2580,7 +2565,7 @@ static void send_prov_data(const u8_t idx) } } - if (FAST_PROV_ENABLE()) { + if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && FAST_PROV_ENABLE()) { link[idx].ki_flags = prov_ctx.fast_prov.flags; link[idx].iv_index = prov_ctx.fast_prov.iv_index; } else { @@ -2603,12 +2588,12 @@ static void prov_random(const u8_t idx, const u8_t *data) BT_DBG("Remote Random: %s", bt_hex(data, 16)); if (bt_mesh_prov_conf(link[idx].conf_key, data, link[idx].auth, conf_verify)) { - BT_ERR("%s, Failed to calculate confirmation verification", __func__); + BT_ERR("Failed to calculate confirmation verification"); goto fail; } if (memcmp(conf_verify, link[idx].conf, 16)) { - BT_ERR("%s, Invalid confirmation value", __func__); + BT_ERR("Invalid confirmation value"); BT_DBG("Received: %s", bt_hex(link[idx].conf, 16)); BT_DBG("Calculated: %s", bt_hex(conf_verify, 16)); goto fail; @@ -2628,13 +2613,13 @@ static void prov_random(const u8_t idx, const u8_t *data) */ link[idx].prov_salt = (u8_t *)bt_mesh_calloc(PROV_PROV_SALT_SIZE); if (!link[idx].prov_salt) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); goto fail; } if (bt_mesh_prov_salt(link[idx].conf_salt, link[idx].rand, data, link[idx].prov_salt)) { - BT_ERR("%s, Failed to generate ProvisioningSalt", __func__); + BT_ERR("Failed to generate ProvisioningSalt"); goto fail; } @@ -2663,12 +2648,12 @@ static void prov_complete(const u8_t idx, const u8_t *data) err = bt_mesh_dev_key(link[idx].dhkey, link[idx].prov_salt, device_key); if (err) { - BT_ERR("%s, Failed to generate device key", __func__); + BT_ERR("Failed to generate device key"); close_link(idx, CLOSE_REASON_FAILED); return; } - if (FAST_PROV_ENABLE()) { + if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV) && FAST_PROV_ENABLE()) { net_idx = prov_ctx.fast_prov.net_idx; } else { net_idx = prov_ctx.curr_net_idx; @@ -2677,7 +2662,7 @@ static void prov_complete(const u8_t idx, const u8_t *data) link[idx].unicast_addr, link[idx].element_num, net_idx, link[idx].ki_flags, link[idx].iv_index, device_key, &index); if (err) { - BT_ERR("%s, Failed to store node info", __func__); + BT_ERR("Failed to store node info"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2693,7 +2678,7 @@ static void prov_complete(const u8_t idx, const u8_t *data) memset(&unprov_dev[rm], 0, sizeof(struct unprov_dev_queue)); } } else if (err == -ENODEV) { - BT_DBG("Device is not found in queue"); + BT_DBG("Device not found in queue"); } else { BT_ERR("Failed to remove device from queue"); } @@ -2703,7 +2688,7 @@ static void prov_complete(const u8_t idx, const u8_t *data) static void prov_failed(const u8_t idx, const u8_t *data) { - BT_WARN("%s, Error 0x%02x", __func__, data[0]); + BT_WARN("Error 0x%02x", data[0]); close_link(idx, CLOSE_REASON_FAILED); } @@ -2746,7 +2731,7 @@ static void close_link(const u8_t idx, u8_t reason) } #endif - BT_ERR("%s, Invalid link index %d", __func__, idx); + BT_ERR("Invalid link idx %d", idx); return; } @@ -2824,19 +2809,19 @@ static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple * BT_DBG("len %u", buf->len); if (buf->len) { - BT_ERR("%s, Invalid Link ACK length", __func__); + BT_ERR("Invalid Link ACK length %d", buf->len); close_link(idx, CLOSE_REASON_FAILED); return; } if (link[idx].expect == PROV_CAPABILITIES) { - BT_INFO("%s, Link ACK is already received", __func__); + BT_INFO("Link ACK is already received"); return; } link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); if (!link[idx].conf_inputs) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -2878,7 +2863,7 @@ static void gen_prov_ctl(const u8_t idx, struct prov_rx *rx, struct net_buf_simp break; default: - BT_ERR("%s, Unknown bearer opcode 0x%02x", __func__, BEARER_CTL(rx->gpc)); + BT_ERR("Unknown bearer opcode 0x%02x", BEARER_CTL(rx->gpc)); return; } } @@ -2894,22 +2879,22 @@ static void prov_msg_recv(const u8_t idx) * Provisioning PDU. If the check succeeds then check fcs. */ if (type != PROV_FAILED && type != link[idx].expect) { - BT_ERR("%s, Unexpected msg 0x%02x != 0x%02x", __func__, type, link[idx].expect); + BT_ERR("Unexpected msg 0x%02x != 0x%02x", type, link[idx].expect); goto fail; } if (type >= 0x0A) { - BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type); + BT_ERR("Unknown provisioning PDU type 0x%02x", type); goto fail; } if (1 + prov_handlers[type].len != link[idx].rx.buf->len) { - BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, link[idx].rx.buf->len, type); + BT_ERR("Invalid length %u for type 0x%02x", link[idx].rx.buf->len, type); goto fail; } if (!bt_mesh_fcs_check(link[idx].rx.buf, link[idx].rx.fcs)) { - BT_ERR("%s, Incorrect FCS", __func__); + BT_ERR("Incorrect FCS"); goto fail; } @@ -2932,7 +2917,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim BT_DBG("len %u, seg_index %u", buf->len, seg); if (!link[idx].rx.seg && link[idx].rx.prev_id == rx->xact_id) { - BT_INFO("%s, Resending ack", __func__); + BT_INFO("Resending ack"); gen_prov_ack_send(idx, rx->xact_id); return; } @@ -2944,7 +2929,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim } if (seg > link[idx].rx.last_seg) { - BT_ERR("%s, Invalid segment index %u", __func__, seg); + BT_ERR("Invalid segment index %u", seg); goto fail; } else if (seg == link[idx].rx.last_seg) { u8_t expect_len = 0U; @@ -2952,14 +2937,14 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim expect_len = (link[idx].rx.buf->len - 20 - (23 * (link[idx].rx.last_seg - 1))); if (expect_len != buf->len) { - BT_ERR("%s, Incorrect last seg len: %u != %u", - __func__, expect_len, buf->len); + BT_ERR("Incorrect last seg len: %u != %u", + expect_len, buf->len); goto fail; } } if (!(link[idx].rx.seg & BIT(seg))) { - BT_INFO("%s, Ignore already received segment", __func__); + BT_INFO("Ignore already received segment"); return; } @@ -3012,12 +2997,12 @@ static void gen_prov_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simp static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { if (link[idx].rx.seg) { - BT_INFO("%s, Get Start while there are unreceived segments", __func__); + BT_INFO("Get Start while there are unreceived segments"); return; } if (link[idx].rx.prev_id == rx->xact_id) { - BT_INFO("%s, Resending ack", __func__); + BT_INFO("Resending ack"); gen_prov_ack_send(idx, rx->xact_id); return; } @@ -3031,20 +3016,20 @@ static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_si /* Provisioner can not receive zero-length provisioning pdu */ if (link[idx].rx.buf->len < 1) { - BT_ERR("%s, Ignoring zero-length provisioning PDU", __func__); + BT_ERR("Ignoring zero-length provisioning PDU"); close_link(idx, CLOSE_REASON_FAILED); return; } if (link[idx].rx.buf->len > link[idx].rx.buf->size) { - BT_ERR("%s, Too large provisioning PDU (%u bytes)", - __func__, link[idx].rx.buf->len); + BT_ERR("Too large provisioning PDU (%u bytes)", + link[idx].rx.buf->len); close_link(idx, CLOSE_REASON_FAILED); return; } if (START_LAST_SEG(rx->gpc) > 0 && link[idx].rx.buf->len <= 20) { - BT_ERR("%s, Too small total length for multi-segment PDU", __func__); + BT_ERR("Too small total length for multi-segment PDU"); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -3073,7 +3058,7 @@ static const struct { static void gen_prov_recv(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) { - BT_ERR("%s, Too short GPC message type %u", __func__, GPCF(rx->gpc)); + BT_ERR("Too short GPC message type %u", GPCF(rx->gpc)); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -3118,12 +3103,12 @@ void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf) rx.link_id = net_buf_simple_pull_be32(buf); if (find_link(rx.link_id, &idx) < 0) { - BT_DBG("%s, Data for unexpected link", __func__); + BT_DBG("Data for unexpected link"); return; } if (buf->len < 2) { - BT_ERR("%s, Too short provisioning packet (len %u)", __func__, buf->len); + BT_ERR("Too short provisioning packet (len %u)", buf->len); close_link(idx, CLOSE_REASON_FAILED); return; } @@ -3165,28 +3150,28 @@ int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_s BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); if (!find_conn(conn, &idx)) { - BT_ERR("%s, Data for unexpected connection", __func__); + BT_ERR("Data for unexpected connection"); return -ENOTCONN; } if (buf->len < 1) { - BT_ERR("%s, Too short provisioning packet (len %u)", __func__, buf->len); + BT_ERR("Too short provisioning packet (len %u)", buf->len); goto fail; } type = net_buf_simple_pull_u8(buf); if (type != PROV_FAILED && type != link[idx].expect) { - BT_ERR("%s, Unexpected msg 0x%02x != 0x%02x", __func__, type, link[idx].expect); + BT_ERR("Unexpected msg 0x%02x != 0x%02x", type, link[idx].expect); goto fail; } if (type >= 0x0A) { - BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type); + BT_ERR("Unknown provisioning PDU type 0x%02x", type); goto fail; } if (prov_handlers[type].len != buf->len) { - BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, buf->len, type); + BT_ERR("Invalid length %u for type 0x%02x", buf->len, type); goto fail; } @@ -3216,7 +3201,7 @@ int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *c } } - BT_ERR("%s, Address %s is not found", __func__, bt_hex(addr, BLE_MESH_ADDR_LEN)); + BT_ERR("Addr %s not found", bt_hex(addr, BLE_MESH_ADDR_LEN)); return -ENOMEM; } @@ -3241,7 +3226,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) } if (i == BLE_MESH_PROV_SAME_TIME) { - BT_ERR("%s, Link is not found", __func__); + BT_ERR("Link not found"); return -ENOTCONN; } @@ -3268,7 +3253,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); if (!link[idx].conf_inputs) { /* Disconnect this connection, clear corresponding informations */ - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); return -ENOMEM; } @@ -3284,7 +3269,7 @@ int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason) BT_DBG("conn %p", conn); if (!find_conn(conn, &idx)) { - BT_ERR("%s, Conn %p is not found", __func__, conn); + BT_ERR("Conn %p not found", conn); return -ENOTCONN; } @@ -3314,13 +3299,13 @@ int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info) int i; if (!prov_info) { - BT_ERR("%s, No provisioning context provided", __func__); + BT_ERR("No provisioning context provided"); return -EINVAL; } key = bt_mesh_pub_key_get(); if (!key) { - BT_ERR("%s, Failed to generate Public Key", __func__); + BT_ERR("Failed to generate Public Key"); return -EIO; } @@ -3368,7 +3353,7 @@ int bt_mesh_provisioner_prov_deinit(bool erase) int i; if (prov == NULL) { - BT_ERR("%s, No provisioning context provided", __func__); + BT_ERR("No provisioning context provided"); return -EINVAL; } @@ -3424,7 +3409,7 @@ static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, BLE_MESH_ADV_NONCONN_IND : BLE_MESH_ADV_IND; if (provisioner_dev_find(addr, uuid, &index)) { - BT_DBG("%s, Device is not in queue, notify to upper layer", __func__); + BT_DBG("Device not in queue, notify to app layer"); if (notify_unprov_adv_pkt_cb) { notify_unprov_adv_pkt_cb(addr->val, addr->type, adv_type, uuid, oob_info, bearer, rssi); } @@ -3452,16 +3437,16 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss u16_t oob_info = 0U; if (!(prov_ctx.bearers & BLE_MESH_PROV_ADV)) { - BT_WARN("Provisioner not support PB-ADV bearer"); + BT_WARN("Not support PB-ADV bearer"); return; } if (buf->len != 0x12 && buf->len != 0x16) { - BT_ERR("%s, Invalid Unprovisioned Device Beacon length", __func__); + BT_ERR("Invalid Unprovisioned Device Beacon length %d", buf->len); return; } - addr = bt_mesh_pba_get_addr(); + addr = bt_mesh_get_unprov_dev_addr(); uuid = buf->data; net_buf_simple_pull(buf, 16); /* Mesh beacon uses big-endian to send beacon data */ @@ -3480,14 +3465,15 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss #endif /* CONFIG_BLE_MESH_PB_ADV */ } -void bt_mesh_provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi) +void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, s8_t rssi) { #if defined(CONFIG_BLE_MESH_PB_GATT) const u8_t *uuid = NULL; u16_t oob_info = 0U; if (!(prov_ctx.bearers & BLE_MESH_PROV_GATT)) { - BT_WARN("Provisioner not support PB-GATT bearer"); + BT_WARN("Not support PB-GATT bearer"); return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h index 4b74b425e..04c961e9f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h @@ -164,7 +164,8 @@ int bt_mesh_provisioner_prov_deinit(bool erase); */ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rssi); -void bt_mesh_provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi); +void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, s8_t rssi); /** * @brief This function gets the bt_mesh_prov pointer. @@ -234,7 +235,7 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev); * @return Zero - success, otherwise - fail */ int bt_mesh_provisioner_set_dev_uuid_match(u8_t offset, u8_t length, - const u8_t *match, bool prov_flag); + const u8_t *match, bool prov_flag); /** @brief Callback for provisioner receiving advertising packet from unprovisioned devices which are * not in the unprovisioned device queue. @@ -276,12 +277,12 @@ int bt_mesh_provisioner_adv_pkt_cb_register(unprov_adv_pkt_cb_t cb); int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info); /** - * @brief This function sets the provisioning information needed by Provisioner, - * including unicast address, IV Index, etc. + * @brief This function initializes the provisioning information needed by Provisioner, + * including NetKey Index, flags, IV Index, etc. * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_prov_info(void); +int bt_mesh_provisioner_init_prov_info(void); /** * @brief This function sets the provisioning bearer type used by Provisioner. @@ -359,7 +360,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_t size, bool num_flag); +int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, + u8_t size, bool num_flag); /** * @brief This function is called to read unprovisioned device's oob public key. @@ -370,7 +372,8 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, u8_ * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], const u8_t pub_key_y[32]); +int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], + const u8_t pub_key_y[32]); /* The following APIs are for fast provisioning */ @@ -386,12 +389,11 @@ void bt_mesh_provisioner_fast_prov_enable(bool enable); /** * @brief This function is called to set netkey index used for fast provisioning. * - * @param[in] net_key: Netkey value * @param[in] net_idx: Netkey index * - * @return status for set netkey index msg + * @return None */ -u8_t bt_mesh_provisioner_set_fast_prov_net_idx(const u8_t *net_key, u16_t net_idx); +void bt_mesh_provisioner_set_fast_prov_net_idx(u16_t net_idx); /** * @brief This function is called to get netkey index used for fast provisioning. diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c index 215b443ce..c9072ba87 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c @@ -18,6 +18,7 @@ #include "mesh.h" #include "access.h" #include "beacon.h" +#include "transport.h" #include "mesh_common.h" #include "foundation.h" #include "proxy_client.h" @@ -80,7 +81,7 @@ static void proxy_sar_timeout(struct k_work *work) server = CONTAINER_OF(work, struct bt_mesh_proxy_server, sar_timer.work); if (!server || !server->conn) { - BT_ERR("%s, Invalid proxy server parameter", __func__); + BT_ERR("Invalid proxy server parameter"); return; } @@ -126,19 +127,19 @@ static void filter_status(struct bt_mesh_proxy_server *server, u16_t list_size = 0U; if (buf->len != 3) { - BT_ERR("%s, Invalid Proxy Filter Status length %d", __func__, buf->len); + BT_ERR("Invalid Proxy Filter Status length %d", buf->len); return; } filter_type = net_buf_simple_pull_u8(buf); if (filter_type > 0x01) { - BT_ERR("%s, Invalid filter type 0x%02x", __func__, filter_type); + BT_ERR("Invalid proxy filter type 0x%02x", filter_type); return; } list_size = net_buf_simple_pull_be16(buf); - BT_INFO("%s, filter_type 0x%02x list_size %d", __func__, filter_type, list_size); + BT_INFO("filter_type 0x%02x, list_size %d", filter_type, list_size); if (proxy_client_filter_status_recv_cb) { proxy_client_filter_status_recv_cb(server - servers, rx->ctx.addr, server->net_idx, filter_type, list_size); @@ -154,15 +155,28 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server) u8_t opcode = 0U; int err = 0; + if (server->buf.len > 29) { + BT_ERR("Too large proxy cfg pdu (len %d)", server->buf.len); + return; + } + err = bt_mesh_net_decode(&server->buf, BLE_MESH_NET_IF_PROXY_CFG, &rx, &buf); if (err) { - BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err); + BT_ERR("Failed to decode Proxy Configuration (err %d)", err); return; } if (!BLE_MESH_ADDR_IS_UNICAST(rx.ctx.addr)) { - BT_ERR("%s, Proxy Configuration from non-unicast addr 0x%04x", __func__, rx.ctx.addr); + BT_ERR("Proxy Configuration from non-unicast addr 0x%04x", rx.ctx.addr); + return; + } + + rx.local_match = 1U; + + if (bt_mesh_rpl_check(&rx, NULL)) { + BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", + rx.ctx.addr, rx.ctx.recv_dst, rx.seq); return; } @@ -231,7 +245,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn, u16_t srvc_uuid = 0U; if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } @@ -242,7 +256,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn, srvc_uuid = bt_mesh_gattc_get_service_uuid(conn); if (!srvc_uuid) { - BT_ERR("%s, No service uuid found", __func__); + BT_ERR("No service uuid found"); return -ENOTCONN; } @@ -338,7 +352,7 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, mtu = bt_mesh_gattc_get_mtu_info(conn); if (!mtu) { - BT_ERR("%s, Conn used to get mtu does not exist", __func__); + BT_ERR("Conn %p used to get mtu not exists", conn); return -ENOTCONN; } @@ -368,18 +382,18 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, return err; } -int bt_mesh_proxy_prov_client_send(struct bt_mesh_conn *conn, u8_t type, - struct net_buf_simple *msg) +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type, + struct net_buf_simple *msg) { struct bt_mesh_proxy_server *server = find_server(conn); if (!server) { - BT_ERR("$%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } if ((server->conn_type == PROV) != (type == BLE_MESH_PROXY_PROV)) { - BT_ERR("%s, Invalid PDU type for Proxy Server", __func__); + BT_ERR("Invalid PDU type for Proxy Server"); return -EINVAL; } @@ -395,7 +409,7 @@ static void proxy_connected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int } if (!server) { - BT_ERR("%s, No free Proxy Server objects", __func__); + BT_ERR("No free Proxy Server objects"); /** Disconnect current connection, clear part of prov_link * information, like uuid, dev_addr, linking flag, etc. */ @@ -418,7 +432,7 @@ static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, BT_DBG("conn %p, handle is %d, reason 0x%02x", conn, conn->handle, reason); if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return; } @@ -452,7 +466,7 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) struct bt_mesh_proxy_server *server = find_server(conn); if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } @@ -460,7 +474,6 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) server->conn_type = PROV; if (bt_mesh_provisioner_set_prov_conn(addr->val, server->conn)) { - BT_ERR("%s, bt_mesh_provisioner_set_prov_conn failed", __func__); bt_mesh_gattc_disconnect(server->conn); return -EIO; } @@ -475,7 +488,7 @@ static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) struct bt_mesh_proxy_server *server = find_server(conn); if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } @@ -486,7 +499,7 @@ static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) return -EINVAL; } -int bt_mesh_provisioner_pb_gatt_enable(void) +int bt_mesh_proxy_client_prov_enable(void) { int i; @@ -501,7 +514,7 @@ int bt_mesh_provisioner_pb_gatt_enable(void) return 0; } -int bt_mesh_provisioner_pb_gatt_disable(void) +int bt_mesh_proxy_client_prov_disable(void) { int i; @@ -526,7 +539,7 @@ static ssize_t proxy_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) struct bt_mesh_proxy_server *server = find_server(conn); if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } @@ -547,7 +560,7 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) struct bt_mesh_proxy_server *server = find_server(conn); if (!server) { - BT_ERR("%s, No Proxy Server object found", __func__); + BT_ERR("No Proxy Server object found"); return -ENOTCONN; } @@ -559,14 +572,14 @@ static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) } /** - * Currently proxy client doesn't need bt_mesh_proxy_client_enable() and - * bt_mesh_proxy_client_disable() functions, and once they are used, - * proxy client can be enabled to parse node_id_adv and net_id_adv in - * order to support proxy client role. + * Currently proxy client doesn't need bt_mesh_proxy_client_gatt_enable() + * and bt_mesh_proxy_client_gatt_disable() functions, and once they are + * used, proxy client can be enabled to parse node_id_adv and net_id_adv + * in order to support proxy client role. * And if gatt proxy is disabled, proxy client can stop handling these * two kinds of connectable advertising packets. */ -int bt_mesh_proxy_client_enable(void) +int bt_mesh_proxy_client_gatt_enable(void) { int i; @@ -588,7 +601,7 @@ int bt_mesh_proxy_client_enable(void) return 0; } -int bt_mesh_proxy_client_disable(void) +int bt_mesh_proxy_client_gatt_disable(void) { int i; @@ -645,7 +658,8 @@ static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8]) return NULL; } -void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi) +void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, s8_t rssi) { bt_mesh_proxy_adv_ctx_t ctx = {0}; u8_t type = 0U; @@ -683,7 +697,7 @@ void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh */ return; default: - BT_DBG("%s, Unknown Mesh Proxy adv type 0x%02x", __func__, type); + BT_DBG("Unknown Mesh Proxy adv type 0x%02x", type); return; } @@ -728,7 +742,7 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle) conn = servers[conn_handle].conn; if (!conn) { - BT_ERR("%s, Not connected, conn_handle %d", __func__, conn_handle); + BT_ERR("Not connected, conn handle %d", conn_handle); return -ENOTCONN; } @@ -736,7 +750,7 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle) return 0; } -bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst) +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst) { bool send = false; int err = 0; @@ -756,9 +770,9 @@ bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst) net_buf_simple_init(&msg, 1); net_buf_simple_add_mem(&msg, buf->data, buf->len); - err = bt_mesh_proxy_prov_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg); + err = bt_mesh_proxy_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg); if (err) { - BT_ERR("%s, Failed to send proxy net message (err %d)", __func__, err); + BT_ERR("Failed to send proxy network message (err %d)", err); } else { BT_INFO("%u bytes to dst 0x%04x", buf->len, dst); send = true; @@ -775,7 +789,7 @@ static int beacon_send(struct bt_mesh_conn *conn, struct bt_mesh_subnet *sub) net_buf_simple_init(&buf, 1); bt_mesh_beacon_create(sub, &buf); - return bt_mesh_proxy_prov_client_send(conn, BLE_MESH_PROXY_BEACON, &buf); + return bt_mesh_proxy_client_send(conn, BLE_MESH_PROXY_BEACON, &buf); } bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub) @@ -813,7 +827,7 @@ bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub) if (servers[i].conn && servers[i].conn_type == PROXY) { err = beacon_send(servers[i].conn, sub); if (err) { - BT_ERR("%s, Failed to send proxy beacon message (err %d)", __func__, err); + BT_ERR("Failed to send proxy beacon message (err %d)", err); } else { send = true; } @@ -845,14 +859,14 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me tx.sub = bt_mesh_provisioner_subnet_get(net_idx); } if (!tx.sub) { - BT_ERR("%s, Failed to find subnet", __func__); + BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx); return -EIO; } switch (cfg->opcode) { case BLE_MESH_PROXY_CFG_FILTER_SET: if (cfg->set.filter_type > 0x01) { - BT_ERR("%s, Invalid filter type 0x%02x", __func__, cfg->set.filter_type); + BT_ERR("Invalid proxy filter type 0x%02x", cfg->set.filter_type); return -EINVAL; } @@ -860,7 +874,7 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me break; case BLE_MESH_PROXY_CFG_FILTER_ADD: if (cfg->add.addr == NULL || cfg->add.addr_num == 0) { - BT_ERR("%s, Add address list is NULL", __func__); + BT_ERR("Empty proxy addr list to add"); return -EINVAL; } @@ -868,14 +882,14 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me break; case BLE_MESH_PROXY_CFG_FILTER_REMOVE: if (cfg->remove.addr == NULL || cfg->remove.addr_num == 0) { - BT_ERR("%s, Remove address list is NULL", __func__); + BT_ERR("Empty proxy addr list to remove"); return -EINVAL; } alloc_len = sizeof(cfg->opcode) + (cfg->remove.addr_num << 1); break; default: - BT_ERR("%s, Unknown Proxy Configuration opcode 0x%02x", __func__, cfg->opcode); + BT_ERR("Unknown Proxy Configuration opcode 0x%02x", cfg->opcode); return -EINVAL; } @@ -908,25 +922,26 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me break; } - BT_DBG("%s, len %u bytes: %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("len %u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); err = bt_mesh_net_encode(&tx, buf, true); if (err) { - BT_ERR("%s, Encoding Proxy message failed (err %d)", __func__, err); + BT_ERR("Encoding proxy message failed (err %d)", err); bt_mesh_free_buf(buf); return err; } - err = bt_mesh_proxy_prov_client_send(conn, BLE_MESH_PROXY_CONFIG, buf); + err = bt_mesh_proxy_client_send(conn, BLE_MESH_PROXY_CONFIG, buf); if (err) { - BT_ERR("%s, Failed to send proxy cfg message (err %d)", __func__, err); + BT_ERR("Failed to send proxy cfg message (err %d)", err); } bt_mesh_free_buf(buf); return err; } -int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu) +int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx, + struct bt_mesh_proxy_cfg_pdu *pdu) { struct bt_mesh_conn *conn = NULL; @@ -939,7 +954,7 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes conn = servers[conn_handle].conn; if (!conn) { - BT_ERR("%s, Not connected, conn_handle %d", __func__, conn_handle); + BT_ERR("Not connected, conn handle %d", conn_handle); return -ENOTCONN; } @@ -948,8 +963,8 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes * with the one added when creating proxy connection. */ if (servers[conn_handle].net_idx != net_idx) { - BT_ERR("%s, NetKey Index 0x%04x mismatch, expect 0x%04x", - __func__, net_idx, servers[conn_handle].net_idx); + BT_ERR("NetKeyIndex 0x%04x mismatch, expect 0x%04x", + net_idx, servers[conn_handle].net_idx); return -EIO; } @@ -957,7 +972,7 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes } #endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */ -int bt_mesh_proxy_prov_client_init(void) +int bt_mesh_proxy_client_init(void) { int i; @@ -983,7 +998,7 @@ int bt_mesh_proxy_prov_client_init(void) return 0; } -int bt_mesh_proxy_prov_client_deinit(void) +int bt_mesh_proxy_client_deinit(void) { int i; diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.h b/components/bt/esp_ble_mesh/mesh_core/proxy_client.h index 5ca3ea703..bbead7a91 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.h +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.h @@ -74,35 +74,44 @@ typedef struct { }; } bt_mesh_proxy_client_pdu_t; -int bt_mesh_proxy_prov_client_send(struct bt_mesh_conn *conn, u8_t type, struct net_buf_simple *msg); +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type, + struct net_buf_simple *msg); -int bt_mesh_provisioner_pb_gatt_enable(void); -int bt_mesh_provisioner_pb_gatt_disable(void); +int bt_mesh_proxy_client_prov_enable(void); +int bt_mesh_proxy_client_prov_disable(void); -int bt_mesh_proxy_client_enable(void); -int bt_mesh_proxy_client_disable(void); +int bt_mesh_proxy_client_gatt_enable(void); +int bt_mesh_proxy_client_gatt_disable(void); -typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, u8_t type, bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi); -typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, u16_t net_idx); -typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, u16_t net_idx, u8_t reason); -typedef void (*proxy_client_recv_filter_status_cb_t)(u8_t conn_handle, u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size); +typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, u8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi); +typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, + u8_t conn_handle, u16_t net_idx); +typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, + u16_t net_idx, u8_t reason); +typedef void (*proxy_client_recv_filter_status_cb_t)(u8_t conn_handle, u16_t src, u16_t net_idx, + u8_t filter_type, u16_t list_size); void bt_mesh_proxy_client_set_adv_recv_cb(proxy_client_recv_adv_cb_t cb); void bt_mesh_proxy_client_set_conn_cb(proxy_client_connect_cb_t cb); void bt_mesh_proxy_client_set_disconn_cb(proxy_client_disconnect_cb_t cb); void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_cb_t cb); -void bt_mesh_proxy_client_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, s8_t rssi); +void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, s8_t rssi); int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_idx); int bt_mesh_proxy_client_disconnect(u8_t conn_handle); bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub); -bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst); -int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu); -int bt_mesh_proxy_prov_client_init(void); -int bt_mesh_proxy_prov_client_deinit(void); +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst); + +int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx, + struct bt_mesh_proxy_cfg_pdu *pdu); + +int bt_mesh_proxy_client_init(void); +int bt_mesh_proxy_client_deinit(void); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c index 5f1ef084f..0ae040e73 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c @@ -16,6 +16,7 @@ #include "prov.h" #include "beacon.h" #include "access.h" +#include "transport.h" #include "foundation.h" #include "proxy_server.h" @@ -119,7 +120,7 @@ int bt_mesh_set_device_name(const char *name) } if (strlen(name) > DEVICE_NAME_SIZE) { - BT_ERR("%s, Too long device name", __func__); + BT_ERR("Too long device name (len %d)", strlen(name)); return -EINVAL; } @@ -150,7 +151,7 @@ static void proxy_sar_timeout(struct k_work *work) client = CONTAINER_OF(work, struct bt_mesh_proxy_client, sar_timer.work); if (!client || !client->conn) { - BT_ERR("%s, Invalid proxy client parameter", __func__); + BT_ERR("Invalid proxy client parameter"); return; } @@ -176,7 +177,7 @@ static int filter_set(struct bt_mesh_proxy_client *client, } type = net_buf_simple_pull_u8(buf); - BT_DBG("type 0x%02x", type); + BT_INFO("Set filter type 0x%02x", type); switch (type) { case 0x00: @@ -214,9 +215,12 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr) for (i = 0; i < ARRAY_SIZE(client->filter); i++) { if (client->filter[i] == BLE_MESH_ADDR_UNASSIGNED) { client->filter[i] = addr; + BT_INFO("Add filter addr 0x%04x", addr); return; } } + + BT_WARN("Proxy filter is full!"); } static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr) @@ -232,6 +236,7 @@ static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr) for (i = 0; i < ARRAY_SIZE(client->filter); i++) { if (client->filter[i] == addr) { client->filter[i] = BLE_MESH_ADDR_UNASSIGNED; + BT_INFO("Remove filter addr 0x%04x", addr); return; } } @@ -275,13 +280,13 @@ static void send_filter_status(struct bt_mesh_proxy_client *client, err = bt_mesh_net_encode(&tx, buf, true); if (err) { - BT_ERR("%s, Encoding Proxy cfg message failed (err %d)", __func__, err); + BT_ERR("Encoding proxy cfg message failed (err %d)", err); return; } err = proxy_segment_and_send(client->conn, BLE_MESH_PROXY_CONFIG, buf); if (err) { - BT_ERR("%s, Failed to send proxy cfg message (err %d)", __func__, err); + BT_ERR("Failed to send proxy cfg message (err %d)", err); } } @@ -292,10 +297,23 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) u8_t opcode = 0U; int err = 0; + if (client->buf.len > 29) { + BT_ERR("Too large proxy cfg pdu (len %d)", client->buf.len); + return; + } + err = bt_mesh_net_decode(&client->buf, BLE_MESH_NET_IF_PROXY_CFG, &rx, &buf); if (err) { - BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err); + BT_ERR("Failed to decode Proxy Configuration (err %d)", err); + return; + } + + rx.local_match = 1U; + + if (bt_mesh_rpl_check(&rx, NULL)) { + BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", + rx.ctx.addr, rx.ctx.recv_dst, rx.seq); return; } @@ -365,7 +383,7 @@ static void proxy_send_beacons(struct k_work *work) } } -void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub) +void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub) { int i; @@ -373,7 +391,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub) /* NULL means we send on all subnets */ for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) { if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) { - bt_mesh_proxy_beacon_send(&bt_mesh.sub[i]); + bt_mesh_proxy_server_beacon_send(&bt_mesh.sub[i]); } } @@ -387,7 +405,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub) } } -void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub) +void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub) { sub->node_id = BLE_MESH_NODE_IDENTITY_RUNNING; sub->node_id_start = k_uptime_get_32(); @@ -396,7 +414,7 @@ void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub) next_idx = sub - bt_mesh.sub; } -void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub) +void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub) { sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED; sub->node_id_start = 0U; @@ -423,7 +441,7 @@ int bt_mesh_proxy_identity_enable(void) continue; } - bt_mesh_proxy_identity_start(sub); + bt_mesh_proxy_server_identity_start(sub); count++; } @@ -580,7 +598,7 @@ static void proxy_connected(struct bt_mesh_conn *conn, u8_t err) } if (!client) { - BT_ERR("%s, No free Proxy Client objects", __func__); + BT_ERR("No free Proxy Client objects"); return; } @@ -619,7 +637,7 @@ static void proxy_disconnected(struct bt_mesh_conn *conn, u8_t reason) bt_mesh_adv_update(); } -struct net_buf_simple *bt_mesh_proxy_get_buf(void) +struct net_buf_simple *bt_mesh_proxy_server_get_buf(void) { struct net_buf_simple *buf = &clients[0].buf; @@ -651,7 +669,10 @@ static ssize_t prov_ccc_write(struct bt_mesh_conn *conn, /* If a connection exists there must be a client */ client = find_client(conn); - __ASSERT(client, "No client for connection"); + if (!client) { + BT_ERR("No client for connection %p", conn); + return 0; + } if (client->filter_type == NONE) { client->filter_type = PROV; @@ -692,7 +713,7 @@ static struct bt_mesh_gatt_attr prov_attrs[] = { struct bt_mesh_gatt_service prov_svc = BLE_MESH_GATT_SERVICE(prov_attrs); -int bt_mesh_proxy_prov_enable(void) +int bt_mesh_proxy_server_prov_enable(void) { int i; @@ -722,7 +743,7 @@ int bt_mesh_proxy_prov_enable(void) return 0; } -int bt_mesh_proxy_prov_disable(bool disconnect) +int bt_mesh_proxy_server_prov_disable(bool disconnect) { int i; @@ -786,7 +807,10 @@ static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn, /* If a connection exists there must be a client */ client = find_client(conn); - __ASSERT(client, "No client for connection"); + if (!client) { + BT_ERR("No client for connection %p", conn); + return 0; + } if (client->filter_type == NONE) { client->filter_type = WHITELIST; @@ -827,7 +851,7 @@ static struct bt_mesh_gatt_attr proxy_attrs[] = { struct bt_mesh_gatt_service proxy_svc = BLE_MESH_GATT_SERVICE(proxy_attrs); -int bt_mesh_proxy_gatt_enable(void) +int bt_mesh_proxy_server_gatt_enable(void) { int i; @@ -855,7 +879,7 @@ int bt_mesh_proxy_gatt_enable(void) return 0; } -void bt_mesh_proxy_gatt_disconnect(void) +void bt_mesh_proxy_server_gatt_disconnect(void) { int i; @@ -872,7 +896,7 @@ void bt_mesh_proxy_gatt_disconnect(void) } } -int bt_mesh_proxy_gatt_disable(void) +int bt_mesh_proxy_server_gatt_disable(void) { BT_DBG("%s", __func__); @@ -886,7 +910,7 @@ int bt_mesh_proxy_gatt_disable(void) return -EBUSY; } - bt_mesh_proxy_gatt_disconnect(); + bt_mesh_proxy_server_gatt_disconnect(); bt_mesh_gatts_service_stop(&proxy_svc); gatt_svc = MESH_GATT_NONE; @@ -894,12 +918,12 @@ int bt_mesh_proxy_gatt_disable(void) return 0; } -void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr) +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr) { struct bt_mesh_proxy_client *client = CONTAINER_OF(buf, struct bt_mesh_proxy_client, buf); - BT_INFO("filter_type %u addr 0x%04x", client->filter_type, addr); + BT_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); if (client->filter_type == WHITELIST) { filter_add(client, addr); @@ -940,7 +964,7 @@ static bool client_filter_match(struct bt_mesh_proxy_client *client, return false; } -bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst) +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst) { bool relayed = false; int i; @@ -965,7 +989,7 @@ bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst) net_buf_simple_reserve(&msg, 1); net_buf_simple_add_mem(&msg, buf->data, buf->len); - bt_mesh_proxy_send(client->conn, BLE_MESH_PROXY_NET_PDU, &msg); + bt_mesh_proxy_server_send(client->conn, BLE_MESH_PROXY_NET_PDU, &msg); relayed = true; } @@ -1027,18 +1051,18 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, return 0; } -int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type, - struct net_buf_simple *msg) +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type, + struct net_buf_simple *msg) { struct bt_mesh_proxy_client *client = find_client(conn); if (!client) { - BT_ERR("%s, No Proxy Client found", __func__); + BT_ERR("No Proxy Client found"); return -ENOTCONN; } if ((client->filter_type == PROV) != (type == BLE_MESH_PROXY_PROV)) { - BT_ERR("%s, Invalid PDU type for Proxy Client", __func__); + BT_ERR("Invalid PDU type for Proxy Client"); return -EINVAL; } @@ -1246,7 +1270,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) active, remaining); node_id_adv(sub); } else { - bt_mesh_proxy_identity_stop(sub); + bt_mesh_proxy_server_identity_stop(sub); BT_DBG("Node ID stopped"); } } @@ -1325,7 +1349,7 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2]) } #endif /* CONFIG_BLE_MESH_PB_GATT */ -s32_t bt_mesh_proxy_adv_start(void) +s32_t bt_mesh_proxy_server_adv_start(void) { BT_DBG("%s", __func__); @@ -1369,7 +1393,7 @@ s32_t bt_mesh_proxy_adv_start(void) return K_FOREVER; } -void bt_mesh_proxy_adv_stop(void) +void bt_mesh_proxy_server_adv_stop(void) { int err = 0; @@ -1381,7 +1405,7 @@ void bt_mesh_proxy_adv_stop(void) err = bt_le_adv_stop(); if (err) { - BT_ERR("%s, Failed to stop advertising (err %d)", __func__, err); + BT_ERR("Failed to stop advertising (err %d)", err); } else { proxy_adv_enabled = false; } @@ -1392,7 +1416,7 @@ static struct bt_mesh_conn_cb conn_callbacks = { .disconnected = proxy_disconnected, }; -int bt_mesh_proxy_init(void) +int bt_mesh_proxy_server_init(void) { int i; @@ -1420,7 +1444,7 @@ int bt_mesh_proxy_init(void) return bt_mesh_gatts_set_local_device_name(device_name); } -int bt_mesh_proxy_deinit(void) +int bt_mesh_proxy_server_deinit(void) { int i; diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.h b/components/bt/esp_ble_mesh/mesh_core/proxy_server.h index 724561f41..c8c277027 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.h +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.h @@ -40,31 +40,32 @@ extern "C" { int bt_mesh_set_device_name(const char *name); -int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type, - struct net_buf_simple *msg); +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type, + struct net_buf_simple *msg); -int bt_mesh_proxy_prov_enable(void); -int bt_mesh_proxy_prov_disable(bool disconnect); +int bt_mesh_proxy_server_prov_enable(void); +int bt_mesh_proxy_server_prov_disable(bool disconnect); -int bt_mesh_proxy_gatt_enable(void); -int bt_mesh_proxy_gatt_disable(void); -void bt_mesh_proxy_gatt_disconnect(void); +int bt_mesh_proxy_server_gatt_enable(void); +int bt_mesh_proxy_server_gatt_disable(void); -void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub); +void bt_mesh_proxy_server_gatt_disconnect(void); -struct net_buf_simple *bt_mesh_proxy_get_buf(void); +void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub); -s32_t bt_mesh_proxy_adv_start(void); -void bt_mesh_proxy_adv_stop(void); +struct net_buf_simple *bt_mesh_proxy_server_get_buf(void); -void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub); -void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub); +s32_t bt_mesh_proxy_server_adv_start(void); +void bt_mesh_proxy_server_adv_stop(void); -bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst); -void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr); +void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub); +void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); -int bt_mesh_proxy_init(void); -int bt_mesh_proxy_deinit(void); +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst); +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr); + +int bt_mesh_proxy_server_init(void); +int bt_mesh_proxy_server_deinit(void); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index ea15e02a9..ccd1bdaa1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -19,6 +19,7 @@ #include "cfg_srv.h" #include "mesh_common.h" #include "settings_nvs.h" +#include "settings.h" #include "provisioner_main.h" #include "provisioner_prov.h" @@ -64,6 +65,7 @@ static struct key_update { } key_updates[CONFIG_BLE_MESH_APP_KEY_COUNT + CONFIG_BLE_MESH_SUBNET_COUNT]; static struct k_delayed_work pending_store; +static void store_pending(struct k_work *work); /* Mesh network storage information */ struct net_val { @@ -167,7 +169,29 @@ struct node_info { u8_t dev_key[16]; } __packed; -#define DEVICE_ROLE_BITS (BIT(BLE_MESH_NODE) | BIT(BLE_MESH_PROVISIONER)) +static bt_mesh_mutex_t settings_lock; + +static void bt_mesh_settings_mutex_new(void) +{ + if (settings_lock.mutex == NULL) { + bt_mesh_mutex_create(&settings_lock); + } +} + +static void bt_mesh_settings_mutex_free(void) +{ + bt_mesh_mutex_free(&settings_lock); +} + +void bt_mesh_settings_lock(void) +{ + bt_mesh_mutex_lock(&settings_lock); +} + +void bt_mesh_settings_unlock(void) +{ + bt_mesh_mutex_unlock(&settings_lock); +} static int role_set(const char *name) { @@ -249,7 +273,7 @@ static int iv_set(const char *name) bt_mesh_atomic_set_bit_to(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS, iv.iv_update); bt_mesh.ivu_duration = iv.iv_duration; - BT_INFO("Restored IV Index 0x%04x (IV Update Flag %u) duration %u hours", + BT_INFO("Restored IV Index 0x%08x (IV Update Flag %u) duration %u hours", iv.iv_index, iv.iv_update, iv.iv_duration); return 0; @@ -340,13 +364,18 @@ static int rpl_set(const char *name) for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { u16_t src = net_buf_simple_pull_le16(buf); + + if (!BLE_MESH_ADDR_IS_UNICAST(src)) { + BT_ERR("Invalid source address 0x%04x", src); + continue; + } + sprintf(get, "mesh/rpl/%04x", src); err = bt_mesh_load_core_settings(get, (u8_t *)&rpl, sizeof(rpl), &exist); if (err) { BT_ERR("Failed to load RPL entry 0x%04x", src); - bt_mesh_rpl_reset(); - goto free; + continue; } if (exist == false) { @@ -357,16 +386,17 @@ static int rpl_set(const char *name) if (!entry) { entry = rpl_alloc(src); if (!entry) { - BT_ERR("%s, No space for a new RPL 0x%04x", __func__, src); + BT_ERR("No space for a new RPL 0x%04x", src); err = -ENOMEM; goto free; } } - BT_INFO("Restored RPL entry 0x%04x: seq 0x%06x, old_iv %u", src, rpl.seq, rpl.old_iv); entry->src = src; entry->seq = rpl.seq; entry->old_iv = rpl.old_iv; + + BT_INFO("Restored RPL entry 0x%04x: seq 0x%06x, old_iv %u", src, rpl.seq, rpl.old_iv); } free: @@ -414,8 +444,8 @@ static int net_key_set(const char *name) err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); if (err) { - BT_ERR("%s, Failed to load NetKey 0x%03x", __func__, net_idx); - goto free; + BT_ERR("Failed to load NetKey 0x%03x", net_idx); + continue; } if (exist == false) { @@ -426,7 +456,7 @@ static int net_key_set(const char *name) if (!sub) { sub = subnet_alloc(net_idx); if (!sub) { - BT_ERR("%s, No space for a new subnet 0x%03x", __func__, net_idx); + BT_ERR("No space for a new subnet 0x%03x", net_idx); err = -ENOMEM; goto free; } @@ -438,7 +468,7 @@ static int net_key_set(const char *name) memcpy(sub->keys[0].net, &key.val[0], 16); memcpy(sub->keys[1].net, &key.val[1], 16); - BT_INFO("Restored NetKey Index 0x%03x", sub->net_idx); + BT_INFO("Restored NetKeyIndex 0x%03x", sub->net_idx); BT_INFO("Restored NetKey %s", bt_hex(sub->keys[0].net, 16)); } @@ -474,8 +504,8 @@ static int app_key_set(const char *name) err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); if (err) { - BT_ERR("%s, Failed to load AppKey 0x%03x", __func__, app_idx); - goto free; + BT_ERR("Failed to load AppKey 0x%03x", app_idx); + continue; } if (exist == false) { @@ -484,16 +514,15 @@ static int app_key_set(const char *name) sub = bt_mesh_subnet_get(key.net_idx); if (!sub) { - BT_ERR("%s, Failed to find subnet 0x%03x", __func__, key.net_idx); - err = -ENOENT; - goto free; + BT_ERR("Failed to find subnet 0x%03x", key.net_idx); + continue; } app = bt_mesh_app_key_find(app_idx); if (!app) { app = bt_mesh_app_key_alloc(app_idx); if (!app) { - BT_ERR("%s, No space for a new app key 0x%03x", __func__, app_idx); + BT_ERR("No space for a new appkey 0x%03x", app_idx); err = -ENOMEM; goto free; } @@ -507,7 +536,7 @@ static int app_key_set(const char *name) bt_mesh_app_id(app->keys[0].val, &app->keys[0].id); bt_mesh_app_id(app->keys[1].val, &app->keys[1].id); - BT_INFO("Restored AppKey Index 0x%03x, NetKey Index 0x%03x", + BT_INFO("Restored AppKeyIndex 0x%03x, NetKeyIndex 0x%03x", app->app_idx, app->net_idx); BT_INFO("Restored AppKey %s", bt_hex(app->keys[0].val, 16)); } @@ -527,7 +556,7 @@ static int hb_pub_set(const char *name) BT_DBG("%s", __func__); if (!hb_pub) { - BT_ERR("%s, NULL cfg hb pub", __func__); + BT_ERR("Invalid heartbeat publication"); return -EINVAL; } @@ -557,7 +586,8 @@ static int hb_pub_set(const char *name) hb_pub->count = 0U; } - BT_INFO("Restored Heartbeat Publication, dst 0x%04x", hb_pub->dst); + BT_INFO("Restored Heartbeat Publication, dst 0x%04x, period %d, net_idx 0x%03x", + hb_pub->dst, hb_pub->period, hb_pub->net_idx); return 0; } @@ -572,7 +602,7 @@ static int cfg_set(const char *name) BT_DBG("%s", __func__); if (!cfg) { - BT_ERR("%s, NULL cfg", __func__); + BT_ERR("Invalid configuration"); stored_cfg.valid = false; return -EINVAL; } @@ -590,7 +620,10 @@ static int cfg_set(const char *name) memcpy(&stored_cfg.cfg, &val, sizeof(val)); stored_cfg.valid = true; - BT_INFO("Restored Configuration State"); + + BT_INFO("Restored Configuration, ttl %d, transmit 0x%02x, retransmit 0x%02x", + val.default_ttl, val.net_transmit, val.relay_retransmit); + return 0; } @@ -613,6 +646,10 @@ static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key return -EIO; } + if (exist == true) { + BT_INFO("Restored Model Bound AppKey, index %s", bt_hex(model->keys, sizeof(model->keys))); + } + return 0; } @@ -635,6 +672,10 @@ static int model_set_sub(bool vnd, struct bt_mesh_model *model, u16_t model_key) return -EIO; } + if (exist == true) { + BT_INFO("Restored Model Subscription, address %s", bt_hex(model->groups, sizeof(model->groups))); + } + return 0; } @@ -662,7 +703,7 @@ static int model_set_pub(bool vnd, struct bt_mesh_model *model, u16_t model_key) model->pub->period = 0U; model->pub->retransmit = 0U; model->pub->count = 0U; - return 0; + return -EIO; } if (exist == false) { @@ -677,8 +718,7 @@ static int model_set_pub(bool vnd, struct bt_mesh_model *model, u16_t model_key) model->pub->retransmit = pub.retransmit; model->pub->count = 0U; - BT_INFO("Restored Model Publication, address 0x%04x, app_idx 0x%03x", - pub.addr, pub.key); + BT_INFO("Restored Model Publication, address 0x%04x, app_idx 0x%03x", pub.addr, pub.key); return 0; } @@ -689,7 +729,6 @@ static int model_set(bool vnd, const char *name) struct net_buf_simple *buf = NULL; u8_t elem_idx = 0U, model_idx = 0U; size_t length = 0U; - int err = 0; int i; BT_DBG("%s", __func__); @@ -703,6 +742,7 @@ static int model_set(bool vnd, const char *name) for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { u16_t model_key = net_buf_simple_pull_le16(buf); + elem_idx = BLE_MESH_GET_ELEM_IDX(model_key); model_idx = BLE_MESH_GET_MODEL_IDX(model_key); @@ -710,29 +750,16 @@ static int model_set(bool vnd, const char *name) if (!model) { BT_ERR("%s model not found, elem_idx %u, model_idx %u", vnd ? "vnd" : "sig", elem_idx, model_idx); - err = -ENOENT; - goto free; + continue; } - err = model_set_bind(vnd, model, model_key); - if (err) { - goto free; - } - - err = model_set_sub(vnd, model, model_key); - if (err) { - goto free; - } - - err = model_set_pub(vnd, model, model_key); - if (err) { - goto free; - } + model_set_bind(vnd, model, model_key); + model_set_sub(vnd, model, model_key); + model_set_pub(vnd, model, model_key); } -free: bt_mesh_free_buf(buf); - return err; + return 0; } static int sig_mod_set(const char *name) @@ -773,7 +800,7 @@ static int va_set(const char *name) err = bt_mesh_load_core_settings(get, (u8_t *)&va, sizeof(va), &exist); if (err) { BT_ERR("Failed to load virtual address 0x%04x", index); - goto free; + continue; } if (exist == false) { @@ -782,12 +809,12 @@ static int va_set(const char *name) if (va.ref == 0) { BT_DBG("Ignore virtual address %s with ref = 0", get); - goto free; + continue; } lab = get_label(index); if (lab == NULL) { - BT_WARN("%s, Out of labels buffers", __func__); + BT_WARN("Out of labels buffers"); err = -ENOBUFS; goto free; } @@ -826,7 +853,7 @@ static int p_prov_set(const char *name) bt_mesh_provisioner_restore_prov_info(val.primary_addr, val.alloc_addr); - BT_INFO("Restored Primary Address 0x%04x, next address allocation 0x%04x", + BT_INFO("Restored Primary Address 0x%04x, next address alloc 0x%04x", val.primary_addr, val.alloc_addr); return 0; @@ -842,7 +869,7 @@ static int p_net_idx_set(const char *name) err = bt_mesh_load_core_settings(name, (u8_t *)&net_idx, sizeof(net_idx), &exist); if (err) { - BT_ERR("Failed to load next net_idx allocation"); + BT_ERR("Failed to load next NetKeyIndex alloc"); return 0; } @@ -852,7 +879,7 @@ static int p_net_idx_set(const char *name) bt_mesh.p_net_idx_next = net_idx; - BT_INFO("Restored next NetKey Index allocation 0x%03x", bt_mesh.p_net_idx_next); + BT_INFO("Restored next NetKeyIndex alloc 0x%03x", bt_mesh.p_net_idx_next); return 0; } @@ -867,7 +894,7 @@ static int p_app_idx_set(const char *name) err = bt_mesh_load_core_settings(name, (u8_t *)&app_idx, sizeof(app_idx), &exist); if (err) { - BT_ERR("Failed to load next app_idx allocation"); + BT_ERR("Failed to load next AppKeyIndex alloc"); return 0; } @@ -877,7 +904,7 @@ static int p_app_idx_set(const char *name) bt_mesh.p_app_idx_next = app_idx; - BT_INFO("Restored next AppKey Index allocation 0x%03x", bt_mesh.p_app_idx_next); + BT_INFO("Restored next AppKeyIndex alloc 0x%03x", bt_mesh.p_app_idx_next); return 0; } @@ -890,7 +917,7 @@ static struct bt_mesh_subnet *p_subnet_alloc(void) if (bt_mesh.p_sub[i] == NULL) { bt_mesh.p_sub[i] = bt_mesh_calloc(sizeof(struct bt_mesh_subnet)); if (!bt_mesh.p_sub[i]) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return NULL; } @@ -909,7 +936,7 @@ static struct bt_mesh_app_key *p_appkey_alloc(void) if (bt_mesh.p_app_keys[i] == NULL) { bt_mesh.p_app_keys[i] = bt_mesh_calloc(sizeof(struct bt_mesh_app_key)); if (!bt_mesh.p_app_keys[i]) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return NULL; } @@ -946,8 +973,8 @@ static int p_net_key_set(const char *name) err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); if (err) { - BT_ERR("%s, Failed to load NetKey 0x%03x", __func__, net_idx); - goto free; + BT_ERR("Failed to load NetKey 0x%03x", net_idx); + continue; } if (exist == false) { @@ -958,7 +985,7 @@ static int p_net_key_set(const char *name) if (!sub) { sub = p_subnet_alloc(); if (!sub) { - BT_ERR("%s, No space for a new subnet 0x%03x", __func__, net_idx); + BT_ERR("No space for a new subnet 0x%03x", net_idx); err = -ENOMEM; goto free; } @@ -970,7 +997,7 @@ static int p_net_key_set(const char *name) memcpy(sub->keys[0].net, &key.val[0], 16); memcpy(sub->keys[1].net, &key.val[1], 16); - BT_INFO("Restored NetKey Index 0x%03x", sub->net_idx); + BT_INFO("Restored NetKeyIndex 0x%03x", sub->net_idx); BT_INFO("Restored NetKey %s", bt_hex(sub->keys[0].net, 16)); } @@ -1006,8 +1033,8 @@ static int p_app_key_set(const char *name) err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); if (err) { - BT_ERR("%s, Failed to load AppKey 0x%03x", __func__, app_idx); - goto free; + BT_ERR("Failed to load AppKey 0x%03x", app_idx); + continue; } if (exist == false) { @@ -1016,16 +1043,15 @@ static int p_app_key_set(const char *name) sub = bt_mesh_provisioner_subnet_get(key.net_idx); if (!sub) { - BT_ERR("%s, Failed to find subnet 0x%03x", __func__, key.net_idx); - err = -ENOENT; - goto free; + BT_ERR("Failed to find subnet 0x%03x", key.net_idx); + continue; } app = bt_mesh_provisioner_app_key_find(app_idx); if (!app) { app = p_appkey_alloc(); if (!app) { - BT_ERR("%s, No space for a new app key 0x%03x", __func__, app_idx); + BT_ERR("No space for a new appkey 0x%03x", app_idx); err = -ENOMEM; goto free; } @@ -1039,7 +1065,7 @@ static int p_app_key_set(const char *name) bt_mesh_app_id(app->keys[0].val, &app->keys[0].id); bt_mesh_app_id(app->keys[1].val, &app->keys[1].id); - BT_INFO("Restored AppKey Index 0x%03x, NetKey Index 0x%03x", + BT_INFO("Restored AppKeyIndex 0x%03x, NetKeyIndex 0x%03x", app->app_idx, app->net_idx); BT_INFO("Restored AppKey %s", bt_hex(app->keys[0].val, 16)); } @@ -1158,7 +1184,7 @@ static int p_node_set(const char *name) for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { u16_t addr = net_buf_simple_pull_le16(buf); if (!BLE_MESH_ADDR_IS_UNICAST(addr)) { - BT_ERR("%s, 0x%04x is not a unicast address", __func__, addr); + BT_ERR("Invalid unicast address 0x%04x", addr); continue; } @@ -1188,43 +1214,44 @@ const struct bt_mesh_setting { const char *name; int (*func)(const char *name); } settings[] = { - { "mesh/role", role_set }, - { "mesh/net", net_set }, - { "mesh/iv", iv_set }, - { "mesh/seq", seq_set }, - { "mesh/rpl", rpl_set }, - { "mesh/netkey", net_key_set }, - { "mesh/appkey", app_key_set }, - { "mesh/hb_pub", hb_pub_set }, - { "mesh/cfg", cfg_set }, - { "mesh/sig", sig_mod_set }, - { "mesh/vnd", vnd_mod_set }, + { "mesh/role", role_set }, /* For Node & Provisioner */ + { "mesh/net", net_set }, /* For Node */ + { "mesh/iv", iv_set }, /* For Node & Provisioner */ + { "mesh/seq", seq_set }, /* For Node & Provisioner */ + { "mesh/rpl", rpl_set }, /* For Node & Provisioner */ + { "mesh/netkey", net_key_set }, /* For Node */ + { "mesh/appkey", app_key_set }, /* For Node */ + { "mesh/hb_pub", hb_pub_set }, /* For Node */ + { "mesh/cfg", cfg_set }, /* For Node */ + { "mesh/sig", sig_mod_set }, /* For Node & Provisioner */ + { "mesh/vnd", vnd_mod_set }, /* For Node & Provisioner */ #if CONFIG_BLE_MESH_LABEL_COUNT > 0 - { "mesh/vaddr", va_set }, + { "mesh/vaddr", va_set }, /* For Node */ #endif #if CONFIG_BLE_MESH_PROVISIONER - { "mesh/p_prov", p_prov_set }, - { "mesh/p_netidx", p_net_idx_set }, - { "mesh/p_appidx", p_app_idx_set }, - { "mesh/p_netkey", p_net_key_set }, - { "mesh/p_appkey", p_app_key_set }, - { "mesh/p_node", p_node_set }, + { "mesh/p_prov", p_prov_set }, /* For Provisioner */ + { "mesh/p_netidx", p_net_idx_set }, /* For Provisioner */ + { "mesh/p_appidx", p_app_idx_set }, /* For Provisioner */ + { "mesh/p_netkey", p_net_key_set }, /* For Provisioner */ + { "mesh/p_appkey", p_app_key_set }, /* For Provisioner */ + { "mesh/p_node", p_node_set }, /* For Provisioner */ #endif }; /** * For Provisioner, the load operation needs the following actions: + * role_set: Need, restore the device role * net_set: Not needed - * iv_set: Need, although Provisioner will do some initialization of IV Index - * during startup, but we need to restore the last IV Index status + * iv_set: Need, restore the last IV Index status * seq_set: Need, restore the previous sequence number * rpl_set: Need, restore the previous Replay Protection List - * net_key_set: Need, restore the previous network keys - * app_key_set: Need, restore the previous application keys + * net_key_set: Not needed + * app_key_set: Not needed * hb_pub_set: Not needed currently * cfg_set: Not needed currently * sig_mod_set: Need, restore SIG models related info (app, sub, pub) * vnd_mod_set: Need, restore vendor models related info (app, sub, pub) + * va_set: Not needed currently */ int settings_core_load(void) { @@ -1237,7 +1264,8 @@ int settings_core_load(void) !strcmp(settings[i].name, "mesh/netkey") || !strcmp(settings[i].name, "mesh/appkey") || !strcmp(settings[i].name, "mesh/hb_pub") || - !strcmp(settings[i].name, "mesh/cfg")) && + !strcmp(settings[i].name, "mesh/cfg") || + !strcmp(settings[i].name, "mesh/vaddr")) && (!IS_ENABLED(CONFIG_BLE_MESH_NODE) || bt_mesh_is_provisioner())) { BT_DBG("Not restoring %s for Provisioner", settings[i].name); continue; @@ -1257,15 +1285,15 @@ int settings_core_load(void) settings[i].func(settings[i].name); if (!strcmp(settings[i].name, "mesh/role")) { - u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & DEVICE_ROLE_BITS; + u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; switch (role) { - case 0U: + case BLE_MESH_SETTINGS_ROLE_NONE: BT_INFO("Mesh device just starts up, no restore"); return 0; - case BIT(BLE_MESH_NODE): + case BLE_MESH_SETTINGS_ROLE_NODE: BT_INFO("Restored mesh device role: Node"); break; - case BIT(BLE_MESH_PROVISIONER): + case BLE_MESH_SETTINGS_ROLE_PROV: BT_INFO("Restored mesh device role: Provisioner"); break; default: @@ -1284,14 +1312,14 @@ static int subnet_init(struct bt_mesh_subnet *sub) err = bt_mesh_net_keys_create(&sub->keys[0], sub->keys[0].net); if (err) { - BT_ERR("%s, Unable to generate keys for subnet", __func__); + BT_ERR("Unable to generate keys for subnet"); return -EIO; } if (sub->kr_phase != BLE_MESH_KR_NORMAL) { err = bt_mesh_net_keys_create(&sub->keys[1], sub->keys[1].net); if (err) { - BT_ERR("%s, Unable to generate keys for subnet", __func__); + BT_ERR("Unable to generate keys for subnet"); (void)memset(&sub->keys[0], 0, sizeof(sub->keys[0])); return -EIO; } @@ -1330,15 +1358,15 @@ int settings_core_commit(void) #if defined(CONFIG_BLE_MESH_NODE) if (bt_mesh_is_node()) { - BT_INFO("sub[0].net_idx 0x%03x", bt_mesh.sub[0].net_idx); - if (bt_mesh.sub[0].net_idx == BLE_MESH_KEY_UNUSED) { /* Nothing to do since we're not yet provisioned */ return 0; } + BT_INFO("Settings commit, sub[0].net_idx 0x%03x", bt_mesh.sub[0].net_idx); + if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) { - bt_mesh_proxy_prov_disable(true); + bt_mesh_proxy_server_prov_disable(true); } for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) { @@ -1350,7 +1378,7 @@ int settings_core_commit(void) err = subnet_init(sub); if (err) { - BT_ERR("%s, Failed to init subnet 0x%03x", __func__, sub->net_idx); + BT_ERR("Failed to init subnet 0x%03x", sub->net_idx); } } } @@ -1363,9 +1391,7 @@ int settings_core_commit(void) return 0; } - BT_INFO("p_sub[0]->net_idx 0x%03x", bt_mesh.p_sub[0]->net_idx); - - bt_mesh_comp_provision(bt_mesh_provisioner_get_primary_elem_addr()); + BT_INFO("Settings commit, p_sub[0]->net_idx 0x%03x", bt_mesh.p_sub[0]->net_idx); for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) { sub = bt_mesh.p_sub[i]; @@ -1376,18 +1402,19 @@ int settings_core_commit(void) err = subnet_init(sub); if (err) { - BT_ERR("%s, Failed to init subnet 0x%03x", __func__, sub->net_idx); + BT_ERR("Failed to init subnet 0x%03x", sub->net_idx); } - sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED; } } #endif /* CONFIG_BLE_MESH_PROVISIONER */ - if (bt_mesh.ivu_duration < BLE_MESH_IVU_MIN_HOURS) { - k_delayed_work_submit(&bt_mesh.ivu_timer, BLE_MESH_IVU_TIMEOUT); - } + if (bt_mesh_is_node() || bt_mesh_is_provisioner()) { + if (bt_mesh.ivu_duration < BLE_MESH_IVU_MIN_HOURS) { + k_delayed_work_submit(&bt_mesh.ivu_timer, BLE_MESH_IVU_TIMEOUT); + } - bt_mesh_model_foreach(commit_model, NULL); + bt_mesh_model_foreach(commit_model, NULL); + } #if defined(CONFIG_BLE_MESH_NODE) if (bt_mesh_is_node()) { @@ -1417,12 +1444,6 @@ int settings_core_commit(void) } #endif /* CONFIG_BLE_MESH_NODE */ -#if defined(CONFIG_BLE_MESH_PROVISIONER) - if (bt_mesh_is_provisioner()) { - bt_mesh_provisioner_net_start(BLE_MESH_PROV_ADV | BLE_MESH_PROV_GATT); - } -#endif /* CONFIG_BLE_MESH_PROVISIONER */ - return 0; } @@ -1443,6 +1464,14 @@ static void schedule_store(int flag) bt_mesh_atomic_set_bit(bt_mesh.flags, flag); + /* When Node is not provisioned OR Provisioner is disabled, + * we will directly erase the stored information. + */ + if (!bt_mesh_is_provisioned() && !bt_mesh_is_provisioner_en()) { + store_pending(NULL); + return; + } + if (bt_mesh_atomic_get(bt_mesh.flags) & NO_WAIT_PENDING_BITS) { timeout = K_NO_WAIT; } else if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_RPL_PENDING) && @@ -1459,7 +1488,7 @@ static void schedule_store(int flag) return; } - BT_INFO("Waiting %d seconds", timeout / MSEC_PER_SEC); + BT_INFO("Settings store, waiting %d seconds", timeout / MSEC_PER_SEC); if (timeout) { k_delayed_work_submit(&pending_store, timeout); @@ -1468,16 +1497,10 @@ static void schedule_store(int flag) } } -static void clear_iv(void) -{ - BT_DBG("Clearing IV"); - bt_mesh_save_core_settings("mesh/iv", NULL, 0); -} - static void clear_net(void) { BT_DBG("Clearing Network"); - bt_mesh_save_core_settings("mesh/net", NULL, 0); + bt_mesh_erase_core_settings("mesh/net"); } static void store_pending_net(void) @@ -1495,7 +1518,7 @@ static void store_pending_net(void) void bt_mesh_store_role(void) { - BT_DBG("Store, device role %lu", bt_mesh_atomic_get(bt_mesh.flags) & DEVICE_ROLE_BITS); + BT_DBG("Store, device role %lu", bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK); bt_mesh_save_core_settings("mesh/role", (const u8_t *)bt_mesh.flags, sizeof(bt_mesh.flags)); } @@ -1526,9 +1549,10 @@ void bt_mesh_store_iv(bool only_duration) } } -void bt_mesh_clear_iv(void) +static void clear_iv(void) { - clear_iv(); + BT_DBG("Clearing IV"); + bt_mesh_erase_core_settings("mesh/iv"); } static void store_pending_seq(void) @@ -1552,7 +1576,8 @@ void bt_mesh_store_seq(void) void bt_mesh_clear_seq(void) { - bt_mesh_save_core_settings("mesh/seq", NULL, 0); + BT_DBG("Clearing Seq"); + bt_mesh_erase_core_settings("mesh/seq"); } static void store_rpl(struct bt_mesh_rpl *entry) @@ -1591,11 +1616,9 @@ static void clear_rpl(void) BT_DBG("%s", __func__); - bt_mesh_rpl_clear(); - buf = bt_mesh_get_core_settings_item("mesh/rpl"); if (!buf) { - bt_mesh_save_core_settings("mesh/rpl", NULL, 0); + bt_mesh_erase_core_settings("mesh/rpl"); return; } @@ -1603,11 +1626,17 @@ static void clear_rpl(void) for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { src = net_buf_simple_pull_le16(buf); + + if (!BLE_MESH_ADDR_IS_UNICAST(src)) { + BT_ERR("Invalid source address 0x%04x", src); + continue; + } + sprintf(name, "mesh/rpl/%04x", src); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); } - bt_mesh_save_core_settings("mesh/rpl", NULL, 0); + bt_mesh_erase_core_settings("mesh/rpl"); bt_mesh_free_buf(buf); return; @@ -1635,7 +1664,7 @@ static void store_pending_hb_pub(void) struct hb_pub_val val = {0}; if (!hb_pub) { - BT_WARN("NULL heartbeat publication"); + BT_ERR("Invalid heartbeat publication"); return; } @@ -1649,6 +1678,12 @@ static void store_pending_hb_pub(void) bt_mesh_save_core_settings("mesh/hb_pub", (const u8_t *)&val, sizeof(val)); } +static void clear_hb_pub(void) +{ + BT_DBG("Clear heartbeat publication"); + bt_mesh_erase_core_settings("mesh/hb_pub"); +} + static void store_pending_cfg(void) { struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get(); @@ -1673,7 +1708,7 @@ static void store_pending_cfg(void) static void clear_cfg(void) { BT_DBG("Clearing configuration"); - bt_mesh_save_core_settings("mesh/cfg", NULL, 0); + bt_mesh_erase_core_settings("mesh/cfg"); } static void clear_app_key(u16_t app_idx) @@ -1684,11 +1719,11 @@ static void clear_app_key(u16_t app_idx) BT_DBG("AppKeyIndex 0x%03x", app_idx); sprintf(name, "mesh/ak/%04x", app_idx); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); err = bt_mesh_remove_core_settings_item("mesh/appkey", app_idx); if (err) { - BT_ERR("%s, Failed to remove 0x%03x from mesh/appkey", __func__, app_idx); + BT_ERR("Failed to remove 0x%03x from mesh/appkey", app_idx); } return; @@ -1702,11 +1737,11 @@ static void clear_net_key(u16_t net_idx) BT_DBG("NetKeyIndex 0x%03x", net_idx); sprintf(name, "mesh/nk/%04x", net_idx); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); err = bt_mesh_remove_core_settings_item("mesh/netkey", net_idx); if (err) { - BT_ERR("%s, Failed to remove 0x%03x from mesh/netkey", __func__, net_idx); + BT_ERR("Failed to remove 0x%03x from mesh/netkey", net_idx); } return; @@ -1729,7 +1764,7 @@ static void store_net_key(struct bt_mesh_subnet *sub) sprintf(name, "mesh/nk/%04x", sub->net_idx); err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); if (err) { - BT_ERR("%s, Failed to store NetKey 0x%03x", __func__, sub->net_idx); + BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx); return; } @@ -1755,7 +1790,7 @@ static void store_app_key(struct bt_mesh_app_key *app) sprintf(name, "mesh/ak/%04x", app->app_idx); err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); if (err) { - BT_ERR("%s, Failed to store AppKey 0x%03x", __func__, app->app_idx); + BT_ERR("Failed to store AppKey 0x%03x", app->app_idx); return; } @@ -1815,15 +1850,8 @@ static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd) int err = 0; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); - sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && - !bt_mesh_is_provisioned()) { - bt_mesh_save_core_settings(name, NULL, 0); - return; - } - err = bt_mesh_save_core_settings(name, (const u8_t *)model->keys, sizeof(model->keys)); if (err) { BT_ERR("Failed to store %s", name); @@ -1846,15 +1874,8 @@ static void store_pending_mod_sub(struct bt_mesh_model *model, bool vnd) int err = 0; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); - sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && - !bt_mesh_is_provisioned()) { - bt_mesh_save_core_settings(name, NULL, 0); - return; - } - err = bt_mesh_save_core_settings(name, (const u8_t *)model->groups, sizeof(model->groups)); if (err) { BT_ERR("Failed to store %s", name); @@ -1882,6 +1903,9 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd) return; } + model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); + sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); + pub.addr = model->pub->addr; pub.key = model->pub->key; pub.ttl = model->pub->ttl; @@ -1890,16 +1914,6 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd) pub.period_div = model->pub->period_div; pub.cred = model->pub->cred; - model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); - - sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); - - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && - !bt_mesh_is_provisioned()) { - bt_mesh_save_core_settings(name, NULL, 0); - return; - } - err = bt_mesh_save_core_settings(name, (const u8_t *)&pub, sizeof(pub)); if (err) { BT_ERR("Failed to store %s", name); @@ -1939,6 +1953,66 @@ static void store_pending_mod(struct bt_mesh_model *model, } } +static void clear_mod_bind(struct bt_mesh_model *model, bool vnd) +{ + char name[16] = {'\0'}; + u16_t model_key = 0U; + + model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); + sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); + + bt_mesh_erase_core_settings(name); + bt_mesh_remove_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); +} + +static void clear_mod_sub(struct bt_mesh_model *model, bool vnd) +{ + char name[16] = {'\0'}; + u16_t model_key = 0U; + + model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); + sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); + + bt_mesh_erase_core_settings(name); + bt_mesh_remove_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); +} + +static void clear_mod_pub(struct bt_mesh_model *model, bool vnd) +{ + char name[16] = {'\0'}; + u16_t model_key = 0U; + + model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); + sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); + + bt_mesh_erase_core_settings(name); + bt_mesh_remove_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); +} + +static void clear_pending_mod(struct bt_mesh_model *model, + struct bt_mesh_elem *elem, bool vnd, + bool primary, void *user_data) +{ + if (!model->flags) { + return; + } + + if (model->flags & BLE_MESH_MOD_BIND_PENDING) { + model->flags &= ~BLE_MESH_MOD_BIND_PENDING; + clear_mod_bind(model, vnd); + } + + if (model->flags & BLE_MESH_MOD_SUB_PENDING) { + model->flags &= ~BLE_MESH_MOD_SUB_PENDING; + clear_mod_sub(model, vnd); + } + + if (model->flags & BLE_MESH_MOD_PUB_PENDING) { + model->flags &= ~BLE_MESH_MOD_PUB_PENDING; + clear_mod_pub(model, vnd); + } +} + #define IS_VA_DEL(_label) ((_label)->ref == 0) static void store_pending_va(void) { @@ -1957,7 +2031,7 @@ static void store_pending_va(void) sprintf(name, "mesh/va/%04x", i); if (IS_VA_DEL(lab)) { - err = bt_mesh_save_core_settings(name, NULL, 0); + err = bt_mesh_erase_core_settings(name); } else { va.ref = lab->ref; va.addr = lab->addr; @@ -1990,7 +2064,7 @@ static void store_pending(struct k_work *work) BT_DBG("%s", __func__); if (bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_RPL_PENDING)) { - if (!IS_ENABLED(CONFIG_BLE_MESH_NODE) || bt_mesh_is_provisioned()) { + if (bt_mesh_is_provisioned() || bt_mesh_is_provisioner_en()) { store_pending_rpl(); } else { clear_rpl(); @@ -2012,7 +2086,7 @@ static void store_pending(struct k_work *work) } if (bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_IV_PENDING)) { - if (!IS_ENABLED(CONFIG_BLE_MESH_NODE) || bt_mesh_is_provisioned()) { + if (bt_mesh_is_provisioned() || bt_mesh_is_provisioner_en()) { store_pending_iv(); } else { clear_iv(); @@ -2020,12 +2094,20 @@ static void store_pending(struct k_work *work) } if (bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_SEQ_PENDING)) { - store_pending_seq(); + if (bt_mesh_is_provisioned() || bt_mesh_is_provisioner_en()) { + store_pending_seq(); + } else { + bt_mesh_clear_seq(); + } } if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_HB_PUB_PENDING)) { - store_pending_hb_pub(); + if (bt_mesh_is_provisioned()) { + store_pending_hb_pub(); + } else { + clear_hb_pub(); + } } if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && @@ -2038,15 +2120,17 @@ static void store_pending(struct k_work *work) } if (bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_MOD_PENDING)) { - bt_mesh_model_foreach(store_pending_mod, NULL); - if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && - !bt_mesh_is_provisioned()) { - bt_mesh_save_core_settings("mesh/sig", NULL, 0); - bt_mesh_save_core_settings("mesh/vnd", NULL, 0); + if (bt_mesh_is_provisioned() || bt_mesh_is_provisioner_en()) { + bt_mesh_model_foreach(store_pending_mod, NULL); + } else { + bt_mesh_model_foreach(clear_pending_mod, NULL); + bt_mesh_erase_core_settings("mesh/sig"); + bt_mesh_erase_core_settings("mesh/vnd"); } } - if (bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_VA_PENDING)) { + if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node() && + bt_mesh_atomic_test_and_clear_bit(bt_mesh.flags, BLE_MESH_VA_PENDING)) { store_pending_va(); } } @@ -2152,7 +2236,7 @@ void bt_mesh_store_cfg(void) void bt_mesh_clear_role(void) { BT_DBG("Clear device role"); - bt_mesh_save_core_settings("mesh/role", NULL, 0); + bt_mesh_erase_core_settings("mesh/role"); } void bt_mesh_clear_net(void) @@ -2272,35 +2356,8 @@ void bt_mesh_store_prov_info(u16_t primary_addr, u16_t alloc_addr) void bt_mesh_clear_prov_info(void) { - bt_mesh_save_core_settings("mesh/p_prov", NULL, 0); -} - -static void clear_p_net_key(u16_t net_idx) -{ - char name[16] = {'\0'}; - int err = 0; - - sprintf(name, "mesh/pnk/%04x", net_idx); - bt_mesh_save_core_settings(name, NULL, 0); - - err = bt_mesh_remove_core_settings_item("mesh/p_netkey", net_idx); - if (err) { - BT_ERR("Failed to remove 0x%03x from mesh/p_netkey", net_idx); - } -} - -static void clear_p_app_key(u16_t app_idx) -{ - char name[16] = {'\0'}; - int err = 0; - - sprintf(name, "mesh/pak/%04x", app_idx); - bt_mesh_save_core_settings(name, NULL, 0); - - err = bt_mesh_remove_core_settings_item("mesh/p_appkey", app_idx); - if (err) { - BT_ERR("Failed to remove 0x%03x from mesh/p_appkey", app_idx); - } + BT_DBG("Clearing prov info"); + bt_mesh_erase_core_settings("mesh/p_prov"); } static void store_p_net_key(struct bt_mesh_subnet *sub) @@ -2317,7 +2374,7 @@ static void store_p_net_key(struct bt_mesh_subnet *sub) sprintf(name, "mesh/pnk/%04x", sub->net_idx); err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); if (err) { - BT_ERR("%s, Failed to store NetKey 0x%03x", __func__, sub->net_idx); + BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx); return; } @@ -2341,7 +2398,7 @@ static void store_p_app_key(struct bt_mesh_app_key *app) sprintf(name, "mesh/pak/%04x", app->app_idx); err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); if (err) { - BT_ERR("%s, Failed to store AppKey 0x%03x", __func__, app->app_idx); + BT_ERR("Failed to store AppKey 0x%03x", app->app_idx); return; } @@ -2353,7 +2410,7 @@ static void store_p_app_key(struct bt_mesh_app_key *app) void bt_mesh_store_p_net_idx(void) { - BT_DBG("p_net_idx_next 0x%03x", bt_mesh.p_net_idx_next); + BT_DBG("Store, p_net_idx_next 0x%03x", bt_mesh.p_net_idx_next); bt_mesh_save_core_settings("mesh/p_netidx", (const u8_t *)&bt_mesh.p_net_idx_next, sizeof(bt_mesh.p_net_idx_next)); @@ -2361,12 +2418,13 @@ void bt_mesh_store_p_net_idx(void) void bt_mesh_clear_p_net_idx(void) { - bt_mesh_save_core_settings("mesh/p_netidx", NULL, 0); + BT_DBG("Clearing NetKey Index"); + bt_mesh_erase_core_settings("mesh/p_netidx"); } void bt_mesh_store_p_app_idx(void) { - BT_DBG("p_app_idx_next 0x%03x", bt_mesh.p_app_idx_next); + BT_DBG("Store, p_app_idx_next 0x%03x", bt_mesh.p_app_idx_next); bt_mesh_save_core_settings("mesh/p_appidx", (const u8_t *)&bt_mesh.p_app_idx_next, sizeof(bt_mesh.p_app_idx_next)); @@ -2374,13 +2432,14 @@ void bt_mesh_store_p_app_idx(void) void bt_mesh_clear_p_app_idx(void) { - bt_mesh_save_core_settings("mesh/p_appidx", NULL, 0); + BT_DBG("Clearing AppKey Index"); + bt_mesh_erase_core_settings("mesh/p_appidx"); } void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub) { if (sub == NULL) { - BT_ERR("%s, Invalid subnet",__func__); + BT_ERR("Invalid subnet"); return; } @@ -2393,7 +2452,7 @@ void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub) void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key) { if (key == NULL) { - BT_ERR("%s, Invalid AppKey",__func__); + BT_ERR("Invalid AppKey"); return; } @@ -2403,28 +2462,36 @@ void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key) store_p_app_key(key); } -void bt_mesh_clear_p_subnet(struct bt_mesh_subnet *sub) +void bt_mesh_clear_p_subnet(u16_t net_idx) { - if (sub == NULL) { - BT_ERR("%s, Invalid subnet",__func__); - return; + char name[16] = {'\0'}; + int err = 0; + + BT_DBG("NetKeyIndex 0x%03x", net_idx); + + sprintf(name, "mesh/pnk/%04x", net_idx); + bt_mesh_erase_core_settings(name); + + err = bt_mesh_remove_core_settings_item("mesh/p_netkey", net_idx); + if (err) { + BT_ERR("Failed to remove 0x%04x from mesh/p_netkey", net_idx); } - - BT_DBG("NetKeyIndex 0x%03x", sub->net_idx); - - clear_p_net_key(sub->net_idx); } -void bt_mesh_clear_p_app_key(struct bt_mesh_app_key *key) +void bt_mesh_clear_p_app_key(u16_t app_idx) { - if (key == NULL) { - BT_ERR("%s, Invalid AppKey",__func__); - return; + char name[16] = {'\0'}; + int err = 0; + + BT_DBG("AppKeyIndex 0x%03x", app_idx); + + sprintf(name, "mesh/pak/%04x", app_idx); + bt_mesh_erase_core_settings(name); + + err = bt_mesh_remove_core_settings_item("mesh/p_appkey", app_idx); + if (err) { + BT_ERR("Failed to remove 0x%04x from mesh/p_appkey", app_idx); } - - BT_DBG("AppKeyIndex 0x%03x", key->app_idx); - - clear_p_app_key(key->app_idx); } void bt_mesh_clear_rpl_single(u16_t src) @@ -2433,12 +2500,12 @@ void bt_mesh_clear_rpl_single(u16_t src) int err = 0; if (!BLE_MESH_ADDR_IS_UNICAST(src)) { - BT_ERR("%s, Invalid source address 0x%04x", __func__, src); + BT_ERR("Invalid src 0x%04x", src); return; } sprintf(name, "mesh/rpl/%04x", src); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); err = bt_mesh_remove_core_settings_item("mesh/rpl", src); if (err) { @@ -2453,7 +2520,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node) int err = 0; if (node == NULL) { - BT_ERR("%s, Invalid node", __func__); + BT_ERR("Invalid node info"); return; } @@ -2488,15 +2555,15 @@ static void clear_node(u16_t addr) /* Clear node information */ sprintf(name, "mesh/pn/%04x/i", addr); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); /* Clear node name */ sprintf(name, "mesh/pn/%04x/n", addr); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); /* Clear node composition data */ sprintf(name, "mesh/pn/%04x/c", addr); - bt_mesh_save_core_settings(name, NULL, 0); + bt_mesh_erase_core_settings(name); err = bt_mesh_remove_core_settings_item("mesh/p_node", addr); if (err) { @@ -2507,7 +2574,7 @@ static void clear_node(u16_t addr) void bt_mesh_clear_node_info(u16_t unicast_addr) { if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) { - BT_ERR("%s, Invalid unicast address 0x%04x", __func__, unicast_addr); + BT_ERR("Invalid unicast address 0x%04x", unicast_addr); return; } @@ -2523,7 +2590,7 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node) int err = 0; if (node == NULL) { - BT_ERR("%s, Invalid node", __func__); + BT_ERR("Invalid node info"); return; } @@ -2542,7 +2609,7 @@ void bt_mesh_store_node_comp_data(struct bt_mesh_node *node) int err = 0; if (!node || !node->comp_data || node->comp_length == 0U) { - BT_ERR("%s, Invalid node info", __func__); + BT_ERR("Invalid node info"); return; } @@ -2556,33 +2623,40 @@ void bt_mesh_store_node_comp_data(struct bt_mesh_node *node) int settings_core_init(void) { - BT_DBG("%s", __func__); - k_delayed_work_init(&pending_store, store_pending); - - return 0; -} - -int bt_mesh_settings_init(void) -{ - BT_DBG("%s", __func__); - - bt_mesh_settings_foreach(); - return 0; } int settings_core_deinit(void) { k_delayed_work_free(&pending_store); - return 0; } -int bt_mesh_settings_deinit(void) +int settings_core_erase(void) { - bt_mesh_settings_deforeach(); + /* Erase here must not use the pending_store timer. + * This is used for erasing the information which + * could not be erased during the previous deinit + * operations. + */ + bt_mesh_clear_net(); + bt_mesh_clear_seq(); + bt_mesh_clear_role(); + return 0; +} +int bt_mesh_settings_init(void) +{ + bt_mesh_settings_mutex_new(); + bt_mesh_settings_init_foreach(); + return 0; +} + +int bt_mesh_settings_deinit(bool erase) +{ + bt_mesh_settings_deinit_foreach(erase); + bt_mesh_settings_mutex_free(); return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.h b/components/bt/esp_ble_mesh/mesh_core/settings.h index 52a7b2cd0..22bb153f1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.h +++ b/components/bt/esp_ble_mesh/mesh_core/settings.h @@ -14,15 +14,14 @@ extern "C" { #endif -int settings_core_init(void); -int settings_core_load(void); -int settings_core_commit(void); -int settings_core_deinit(void); +#define BLE_MESH_SETTINGS_ROLE_NONE 0 +#define BLE_MESH_SETTINGS_ROLE_NODE (BIT(BLE_MESH_NODE)) +#define BLE_MESH_SETTINGS_ROLE_PROV (BIT(BLE_MESH_PROVISIONER)) +#define BLE_MESH_SETTINGS_ROLE_BIT_MASK (BIT(BLE_MESH_NODE) | BIT(BLE_MESH_PROVISIONER)) void bt_mesh_store_role(void); void bt_mesh_store_net(void); void bt_mesh_store_iv(bool only_duration); -void bt_mesh_clear_iv(void); void bt_mesh_store_seq(void); void bt_mesh_clear_seq(void); void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl); @@ -50,8 +49,8 @@ void bt_mesh_store_p_app_idx(void); void bt_mesh_clear_p_app_idx(void); void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub); void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key); -void bt_mesh_clear_p_subnet(struct bt_mesh_subnet *sub); -void bt_mesh_clear_p_app_key(struct bt_mesh_app_key *key); +void bt_mesh_clear_p_subnet(u16_t net_idx); +void bt_mesh_clear_p_app_key(u16_t app_idx); void bt_mesh_clear_rpl_single(u16_t src); void bt_mesh_store_node_info(struct bt_mesh_node *node); void bt_mesh_clear_node_info(u16_t unicast_addr); @@ -59,8 +58,17 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node); void bt_mesh_store_node_comp_data(struct bt_mesh_node *node); #endif +void bt_mesh_settings_lock(void); +void bt_mesh_settings_unlock(void); + +int settings_core_init(void); +int settings_core_load(void); +int settings_core_commit(void); +int settings_core_deinit(void); +int settings_core_erase(void); + int bt_mesh_settings_init(void); -int bt_mesh_settings_deinit(void); +int bt_mesh_settings_deinit(bool erase); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c index 400eac9ce..af84ab4d7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c @@ -15,9 +15,6 @@ #include #include -#include "nvs.h" -#include "nvs_flash.h" - #include "mesh_common.h" #include "settings_nvs.h" #include "settings.h" @@ -26,12 +23,11 @@ enum settings_type { SETTINGS_CORE, - SETTINGS_SERVER, }; struct settings_context { char *nvs_name; - nvs_handle handle; + bt_mesh_nvs_handle_t handle; int (*settings_init)(void); int (*settings_load)(void); @@ -47,18 +43,13 @@ static struct settings_context settings_ctx[] = { .settings_load = settings_core_load, .settings_commit = settings_core_commit, .settings_deinit = settings_core_deinit, - }, - [SETTINGS_SERVER] = { - .nvs_name = "mesh_server", - .settings_init = NULL, - .settings_load = NULL, - .settings_commit = NULL, + .settings_erase = settings_core_erase, }, }; /* API used to initialize, load and commit BLE Mesh related settings */ -void bt_mesh_settings_foreach(void) +void bt_mesh_settings_init_foreach(void) { int err = 0; int i; @@ -80,28 +71,28 @@ void bt_mesh_settings_foreach(void) err = nvs_open(ctx->nvs_name, NVS_READWRITE, &ctx->handle); #endif if (err != ESP_OK) { - BT_ERR("%s, Open nvs failed, name %s, err %d", __func__, ctx->nvs_name, err); + BT_ERR("Open nvs failed, name %s, err %d", ctx->nvs_name, err); continue; } if (ctx->settings_init && ctx->settings_init()) { - BT_ERR("%s, Init settings failed, name %s", __func__, ctx->nvs_name); + BT_ERR("Init settings failed, name %s", ctx->nvs_name); continue; } if (ctx->settings_load && ctx->settings_load()) { - BT_ERR("%s, Load settings failed, name %s", __func__, ctx->nvs_name); + BT_ERR("Load settings failed, name %s", ctx->nvs_name); continue; } if (ctx->settings_commit && ctx->settings_commit()) { - BT_ERR("%s, Commit settings failed, name %s", __func__, ctx->nvs_name); + BT_ERR("Commit settings failed, name %s", ctx->nvs_name); continue; } } } -void bt_mesh_settings_deforeach(void) +void bt_mesh_settings_deinit_foreach(bool erase) { int i; @@ -109,7 +100,12 @@ void bt_mesh_settings_deforeach(void) struct settings_context *ctx = &settings_ctx[i]; if (ctx->settings_deinit && ctx->settings_deinit()) { - BT_ERR("%s, Deinit settings failed, name %s", __func__, ctx->nvs_name); + BT_ERR("Deinit settings failed, name %s", ctx->nvs_name); + continue; + } + + if (erase && ctx->settings_erase && ctx->settings_erase()) { + BT_ERR("Erase settings failed, name %s", ctx->nvs_name); continue; } @@ -123,14 +119,14 @@ void bt_mesh_settings_deforeach(void) /* API used to get BLE Mesh related nvs handle */ -static inline nvs_handle settings_get_nvs_handle(enum settings_type type) +static inline bt_mesh_nvs_handle_t settings_get_nvs_handle(enum settings_type type) { return settings_ctx[type].handle; } /* API used to store/erase BLE Mesh related settings */ -static int settings_save(nvs_handle handle, const char *key, const u8_t *val, size_t len) +static int settings_save(bt_mesh_nvs_handle_t handle, const char *key, const u8_t *val, size_t len) { int err = 0; @@ -139,41 +135,61 @@ static int settings_save(nvs_handle handle, const char *key, const u8_t *val, si return -EINVAL; } - BT_DBG("%s, nvs %s, key %s", __func__, val ? "set" : "erase", key); + BT_DBG("nvs %s, key %s", val ? "set" : "erase", key); if (val) { err = nvs_set_blob(handle, key, val, len); } else { err = nvs_erase_key(handle, key); if (err == ESP_ERR_NVS_NOT_FOUND) { - BT_DBG("%s, %s does not exist", __func__, key); + BT_DBG("%s not exists", key); return 0; } } if (err != ESP_OK) { - BT_ERR("%s, Failed to %s %s data (err %d)", __func__, - val ? "set" : "erase", key, err); + BT_ERR("Failed to %s %s data (err %d)", + val ? "set" : "erase", key, err); return -EIO; } err = nvs_commit(handle); if (err != ESP_OK) { - BT_ERR("%s, Failed to commit settings (err %d)", __func__, err); + BT_ERR("Failed to commit settings (err %d)", err); return -EIO; } return 0; } +int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, + const u8_t *val, size_t len) +{ + int err = 0; + bt_mesh_settings_lock(); + err = settings_save(handle, key, val, len); + bt_mesh_settings_unlock(); + return err; +} + int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len) { - nvs_handle handle = settings_get_nvs_handle(SETTINGS_CORE); - return settings_save(handle, key, val, len); + bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); + return bt_mesh_save_settings(handle, key, val, len); +} + +int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key) +{ + return bt_mesh_save_settings(handle, key, NULL, 0); +} + +int bt_mesh_erase_core_settings(const char *key) +{ + return bt_mesh_save_core_settings(key, NULL, 0); } /* API used to load BLE Mesh related settings */ -static int settings_load(nvs_handle handle, const char *key, +static int settings_load(bt_mesh_nvs_handle_t handle, const char *key, u8_t *buf, size_t buf_len, bool *exist) { int err = 0; @@ -186,12 +202,12 @@ static int settings_load(nvs_handle handle, const char *key, err = nvs_get_blob(handle, key, buf, &buf_len); if (err != ESP_OK) { if (err == ESP_ERR_NVS_NOT_FOUND) { - BT_DBG("%s, Settings %s is not found", __func__, key); + BT_DBG("Settings %s not found", key); *exist = false; return 0; } - BT_ERR("%s, Failed to get %s data (err %d)", __func__, key, err); + BT_ERR("Failed to get %s data (err %d)", key, err); return -EIO; } @@ -199,15 +215,25 @@ static int settings_load(nvs_handle handle, const char *key, return 0; } +int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, + u8_t *buf, size_t buf_len, bool *exist) +{ + int err = 0; + bt_mesh_settings_lock(); + err = settings_load(handle, key, buf, buf_len, exist); + bt_mesh_settings_unlock(); + return err; +} + int bt_mesh_load_core_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist) { - nvs_handle handle = settings_get_nvs_handle(SETTINGS_CORE); - return settings_load(handle, key, buf, buf_len, exist); + bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); + return bt_mesh_load_settings(handle, key, buf, buf_len, exist); } /* API used to get length of BLE Mesh related settings */ -static size_t settings_get_length(nvs_handle handle, const char *key) +static size_t settings_get_length(bt_mesh_nvs_handle_t handle, const char *key) { size_t len = 0U; int err = 0; @@ -220,7 +246,7 @@ static size_t settings_get_length(nvs_handle handle, const char *key) err = nvs_get_blob(handle, key, NULL, &len); if (err != ESP_OK) { if (err != ESP_ERR_NVS_NOT_FOUND) { - BT_ERR("%s, Failed to get %s length (err %d)", __func__, key, err); + BT_ERR("Failed to get %s length (err %d)", key, err); } return 0; } @@ -233,7 +259,7 @@ static size_t settings_get_length(nvs_handle handle, const char *key) * Mesh settings. */ -static struct net_buf_simple *settings_get_item(nvs_handle handle, const char *key) +static struct net_buf_simple *settings_get_item(bt_mesh_nvs_handle_t handle, const char *key) { struct net_buf_simple *buf = NULL; size_t length = 0U; @@ -242,20 +268,20 @@ static struct net_buf_simple *settings_get_item(nvs_handle handle, const char *k length = settings_get_length(handle, key); if (!length) { - BT_DBG("%s, Empty %s", __func__, key); + BT_DBG("Empty %s", key); return NULL; } buf = bt_mesh_alloc_buf(length); if (!buf) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); /* TODO: in this case, erase all related settings? */ return NULL; } err = settings_load(handle, key, buf->data, length, &exist); if (err) { - BT_ERR("%s, Failed to load %s", __func__, key); + BT_ERR("Failed to load %s", key); /* TODO: in this case, erase all related settings? */ bt_mesh_free_buf(buf); return NULL; @@ -270,10 +296,19 @@ static struct net_buf_simple *settings_get_item(nvs_handle handle, const char *k return buf; } +struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key) +{ + struct net_buf_simple *buf = NULL; + bt_mesh_settings_lock(); + buf = settings_get_item(handle, key); + bt_mesh_settings_unlock(); + return buf; +} + struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key) { - nvs_handle handle = settings_get_nvs_handle(SETTINGS_CORE); - return settings_get_item(handle, key); + bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); + return bt_mesh_get_settings_item(handle, key); } /* API used to check if the settings item exists */ @@ -305,7 +340,7 @@ static bool is_settings_item_exist(struct net_buf_simple *buf, const u16_t val) /* API used to add the settings item */ -static int settings_add_item(nvs_handle handle, const char *key, const u16_t val) +static int settings_add_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) { struct net_buf_simple *store = NULL; struct net_buf_simple *buf = NULL; @@ -316,7 +351,7 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val /* Check if val already exists */ if (is_settings_item_exist(buf, val) == true) { - BT_DBG("%s, 0x%04x already exists", __func__, val); + BT_DBG("0x%04x already exists", val); bt_mesh_free_buf(buf); return 0; } @@ -325,7 +360,7 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val store = bt_mesh_alloc_buf(length); if (!store) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free_buf(buf); return -ENOMEM; } @@ -342,15 +377,24 @@ static int settings_add_item(nvs_handle handle, const char *key, const u16_t val return err; } +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +{ + int err = 0; + bt_mesh_settings_lock(); + err = settings_add_item(handle, key, val); + bt_mesh_settings_unlock(); + return err; +} + int bt_mesh_add_core_settings_item(const char *key, const u16_t val) { - nvs_handle handle = settings_get_nvs_handle(SETTINGS_CORE); - return settings_add_item(handle, key, val); + bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); + return bt_mesh_add_settings_item(handle, key, val); } /* API used to remove the settings item */ -static int settings_remove_item(nvs_handle handle, const char *key, const u16_t val) +static int settings_remove_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) { struct net_buf_simple *store = NULL; struct net_buf_simple *buf = NULL; @@ -363,7 +407,7 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t /* Check if val does exist */ if (is_settings_item_exist(buf, val) == false) { - BT_DBG("%s, 0x%04x does not exist", __func__, val); + BT_DBG("0x%04x not exists", val); bt_mesh_free_buf(buf); return 0; } @@ -377,7 +421,7 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t store = bt_mesh_alloc_buf(length); if (!store) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free_buf(buf); return -ENOMEM; } @@ -397,10 +441,19 @@ static int settings_remove_item(nvs_handle handle, const char *key, const u16_t return err; } +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +{ + int err = 0; + bt_mesh_settings_lock(); + err = settings_remove_item(handle, key, val); + bt_mesh_settings_unlock(); + return err; +} + int bt_mesh_remove_core_settings_item(const char *key, const u16_t val) { - nvs_handle handle = settings_get_nvs_handle(SETTINGS_CORE); - return settings_remove_item(handle, key, val); + bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); + return bt_mesh_remove_settings_item(handle, key, val); } #endif /* CONFIG_BLE_MESH_SETTINGS */ diff --git a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h index 099efa54d..3bd7b4ee3 100644 --- a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h @@ -15,29 +15,42 @@ #ifndef _BLE_MESH_SETTINGS_NVS_H_ #define _BLE_MESH_SETTINGS_NVS_H_ +#include "nvs_flash.h" #include "mesh_buf.h" #ifdef __cplusplus extern "C" { #endif +typedef nvs_handle bt_mesh_nvs_handle_t; + #define SETTINGS_ITEM_SIZE sizeof(u16_t) #define BLE_MESH_GET_ELEM_IDX(x) ((u8_t)((x) >> 8)) #define BLE_MESH_GET_MODEL_IDX(x) ((u8_t)(x)) -#define BLE_MESH_GET_MODEL_KEY(a, b) ((u16_t)(((u16_t)((a) << 8)) | b)) +#define BLE_MESH_GET_MODEL_KEY(a, b) ((u16_t)(((u16_t)((a) << 8)) | (b))) -void bt_mesh_settings_foreach(void); -void bt_mesh_settings_deforeach(void); +void bt_mesh_settings_init_foreach(void); +void bt_mesh_settings_deinit_foreach(bool erase); +int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, + const u8_t *val, size_t len); int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len); +int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key); +int bt_mesh_erase_core_settings(const char *key); + +int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, + u8_t *buf, size_t buf_len, bool *exist); int bt_mesh_load_core_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist); +struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key); struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key); +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val); int bt_mesh_add_core_settings_item(const char *key, const u16_t val); +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val); int bt_mesh_remove_core_settings_item(const char *key, const u16_t val); #ifdef __cplusplus diff --git a/components/bt/esp_ble_mesh/mesh_core/test.c b/components/bt/esp_ble_mesh/mesh_core/test.c index 616c20708..8f2323302 100644 --- a/components/bt/esp_ble_mesh/mesh_core/test.c +++ b/components/bt/esp_ble_mesh/mesh_core/test.c @@ -46,14 +46,14 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info) err = bt_mesh_provision(info->net_key, info->net_idx, info->flags, info->iv_index, info->unicast_addr, info->dev_key); if (err) { - BT_ERR("%s, bt_mesh_provision() failed (err %d)", __func__, err); + BT_ERR("bt_mesh_provision() failed (err %d)", err); return err; } /* Adds application key to device */ sub = bt_mesh_subnet_get(info->net_idx); if (!sub) { - BT_ERR("%s, Failed to find subnet 0x%04x", __func__, info->net_idx); + BT_ERR("Invalid NetKeyIndex 0x%04x", info->net_idx); return -ENODEV; } @@ -64,14 +64,14 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info) } } if (i == ARRAY_SIZE(bt_mesh.app_keys)) { - BT_ERR("%s, Failed to allocate memory, AppKeyIndex 0x%04x", __func__, info->app_idx); + BT_ERR("Failed to allocate AppKey, 0x%04x", info->app_idx); return -ENOMEM; } keys = sub->kr_flag ? &key->keys[1] : &key->keys[0]; if (bt_mesh_app_id(info->app_key, &keys->id)) { - BT_ERR("%s, Failed to calculate AID, AppKeyIndex 0x%04x", __func__, info->app_idx); + BT_ERR("Failed to calculate AID, 0x%04x", info->app_idx); return -EIO; } @@ -82,7 +82,7 @@ int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info) /* Binds AppKey with all non-config models, adds group address to all these models */ comp = bt_mesh_comp_get(); if (!comp) { - BT_ERR("%s, Composition data is NULL", __func__); + BT_ERR("Invalid composition data"); return -ENODEV; } diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 1ffbf9839..40ca3eb9d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -194,7 +194,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu, buf = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, BUF_TIMEOUT); if (!buf) { - BT_ERR("%s, Out of network buffers", __func__); + BT_ERR("Out of network buffers"); return -ENOBUFS; } @@ -398,7 +398,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx) err = bt_mesh_net_resend(tx->sub, seg, tx->new_key, &seg_sent_cb, tx); if (err) { - BT_ERR("%s, Sending segment failed", __func__); + BT_ERR("Sending segment failed"); bt_mesh_tx_seg_unlock(); seg_tx_complete(tx, -EIO); return; @@ -428,12 +428,12 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, net_tx->aszmic, sdu->len); if (sdu->len < 1) { - BT_ERR("%s, Zero-length SDU not allowed", __func__); + BT_ERR("Zero-length SDU not allowed"); return -EINVAL; } if (sdu->len > BLE_MESH_TX_SDU_MAX) { - BT_ERR("%s, Not enough segment buffers for length %u", __func__, sdu->len); + BT_ERR("Not enough segment buffers for length %u", sdu->len); return -EMSGSIZE; } @@ -445,7 +445,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, } if (!tx) { - BT_ERR("%s, No multi-segment message contexts available", __func__); + BT_ERR("No multi-segment message contexts available"); return -EBUSY; } @@ -496,7 +496,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, net_tx->xmit, BUF_TIMEOUT); if (!seg) { - BT_ERR("%s, Out of segment buffers", __func__); + BT_ERR("Out of segment buffers"); seg_tx_reset(tx); return -ENOBUFS; } @@ -544,7 +544,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, seg_o ? &seg_sent_cb : &first_sent_cb, tx); if (err) { - BT_ERR("%s, Sending segment failed", __func__); + BT_ERR("Sending segment failed"); seg_tx_reset(tx); return err; } @@ -593,7 +593,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, int err = 0; if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) { - BT_ERR("%s, Insufficient tailroom for Transport MIC", __func__); + BT_ERR("Insufficient tailroom for Transport MIC"); return -EINVAL; } @@ -607,7 +607,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, role = bt_mesh_get_device_role(tx->ctx->model, tx->ctx->srv_send); if (role == ROLE_NVAL) { - BT_ERR("%s, Failed to get model role", __func__); + BT_ERR("Failed to get model role"); return -EINVAL; } @@ -636,7 +636,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, tx->ctx->addr, bt_mesh.seq, BLE_MESH_NET_IVI_TX); if (err) { - BT_ERR("%s, Encrypt failed", __func__); + BT_ERR("Encrypt failed (err %d)", err); return err; } @@ -665,7 +665,7 @@ static void update_rpl(struct bt_mesh_rpl *rpl, struct bt_mesh_net_rx *rx) * updated (needed for segmented messages), whereas if a NULL match is given * the RPL is immediately updated (used for unsegmented messages). */ -static bool is_replay(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) +bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) { int i; @@ -714,7 +714,7 @@ static bool is_replay(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) } } - BT_ERR("%s, RPL is full!", __func__); + BT_ERR("RPL is full!"); return true; } @@ -731,7 +731,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len)); if (buf->len < 1 + APP_MIC_LEN(aszmic)) { - BT_ERR("%s, Too short SDU + MIC", __func__); + BT_ERR("Too short SDU + MIC (len %u)", buf->len); return -EINVAL; } @@ -755,7 +755,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, */ sdu = bt_mesh_alloc_buf(CONFIG_BLE_MESH_RX_SDU_MAX - BLE_MESH_MIC_SHORT); if (!sdu) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -767,7 +767,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, dev_key = bt_mesh_rx_devkey_get(i, rx->ctx.addr); if (!dev_key) { - BT_DBG("%s, NULL Device Key", __func__); + BT_DBG("DevKey not found"); continue; } @@ -787,7 +787,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, return 0; } - BT_WARN("%s, Unable to decrypt with DevKey", __func__); + BT_WARN("Unable to decrypt with DevKey"); bt_mesh_free_buf(sdu); return -ENODEV; } @@ -800,7 +800,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, key = bt_mesh_rx_appkey_get(i); if (!key) { - BT_DBG("%s, NULL AppKey", __func__); + BT_DBG("AppKey not found"); continue; } @@ -839,7 +839,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, } if (rx->local_match) { - BT_WARN("%s, No matching AppKey", __func__); + BT_WARN("No matching AppKey"); } bt_mesh_free_buf(sdu); return 0; @@ -885,7 +885,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr, u8_t obo = 0U; if (buf->len < 6) { - BT_ERR("%s, Too short ack message", __func__); + BT_ERR("Too short ack message (len %u)", buf->len); return -EINVAL; } @@ -911,7 +911,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr, } if (!BLE_MESH_ADDR_IS_UNICAST(tx->dst)) { - BT_WARN("%s, Received ack for segments to group", __func__); + BT_WARN("Received ack for segments to group"); return -EINVAL; } @@ -924,7 +924,7 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr, } if (find_msb_set(ack) - 1 > tx->seg_n) { - BT_ERR("%s, Too large segment number in ack", __func__); + BT_ERR("Too large segment number in ack"); return -EINVAL; } @@ -958,7 +958,7 @@ static int trans_heartbeat(struct bt_mesh_net_rx *rx, u16_t feat = 0U; if (buf->len < 3) { - BT_ERR("%s, Too short heartbeat message", __func__); + BT_ERR("Too short heartbeat message (len %u)", buf->len); return -EINVAL; } @@ -1054,11 +1054,11 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx, BT_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data)); if (buf->len < 1) { - BT_ERR("%s, Too small unsegmented PDU", __func__); + BT_ERR("Too small unsegmented PDU"); return -EINVAL; } - if (is_replay(rx, NULL)) { + if (bt_mesh_rpl_check(rx, NULL)) { BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", rx->ctx.addr, rx->ctx.recv_dst, rx->seq); return -EINVAL; @@ -1111,7 +1111,7 @@ static int ctl_send_unseg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, buf = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, BUF_TIMEOUT); if (!buf) { - BT_ERR("%s, Out of transport buffers", __func__); + BT_ERR("Out of transport buffers"); return -ENOBUFS; } @@ -1154,7 +1154,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, } if (!tx_seg) { - BT_ERR("%s, No multi-segment message contexts available", __func__); + BT_ERR("No multi-segment message contexts available"); return -EBUSY; } @@ -1187,7 +1187,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, BUF_TIMEOUT); if (!seg) { - BT_ERR("%s, Out of segment buffers", __func__); + BT_ERR("Out of segment buffers"); seg_tx_reset(tx_seg); return -ENOBUFS; } @@ -1212,7 +1212,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, seg_o ? &seg_sent_cb : &first_sent_cb, tx_seg); if (err) { - BT_ERR("%s, Sending segment failed", __func__); + BT_ERR("Sending segment failed (err %d)", err); seg_tx_reset(tx_seg); return err; } @@ -1418,17 +1418,17 @@ static bool seg_rx_is_valid(struct seg_rx *rx, struct bt_mesh_net_rx *net_rx, const u8_t *hdr, u8_t seg_n) { if (rx->hdr != *hdr || rx->seg_n != seg_n) { - BT_ERR("%s, Invalid segment for ongoing session", __func__); + BT_ERR("Invalid segment for ongoing session"); return false; } if (rx->src != net_rx->ctx.addr || rx->dst != net_rx->ctx.recv_dst) { - BT_ERR("%s, Invalid source or destination for segment", __func__); + BT_ERR("Invalid source or destination for segment"); return false; } if (rx->ctl != net_rx->ctl) { - BT_ERR("%s, Inconsistent CTL in segment", __func__); + BT_ERR("Inconsistent CTL in segment"); return false; } @@ -1482,11 +1482,11 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, int err = 0; if (buf->len < 5) { - BT_ERR("%s, Too short segmented message (len %u)", __func__, buf->len); + BT_ERR("Too short segmented message (len %u)", buf->len); return -EINVAL; } - if (is_replay(net_rx, &rpl)) { + if (bt_mesh_rpl_check(net_rx, &rpl)) { BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq); return -EINVAL; @@ -1506,7 +1506,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, BT_DBG("SeqZero 0x%04x SegO %u SegN %u", seq_zero, seg_o, seg_n); if (seg_o > seg_n) { - BT_ERR("%s, SegO greater than SegN (%u > %u)", __func__, seg_o, seg_n); + BT_ERR("SegO greater than SegN (%u > %u)", seg_o, seg_n); return -EINVAL; } @@ -1571,7 +1571,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, /* Bail out early if we're not ready to receive such a large SDU */ if (!sdu_len_is_ok(net_rx->ctl, seg_n)) { - BT_ERR("%s, Too big incoming SDU length", __func__); + BT_ERR("Too big incoming SDU length"); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, seq_auth, 0, net_rx->friend_match); @@ -1633,7 +1633,7 @@ found_rx: } } else { if (buf->len != seg_len(rx->ctl)) { - BT_ERR("%s, Incorrect segment size for message type", __func__); + BT_ERR("Incorrect segment size for message type"); return -EINVAL; } } @@ -1768,7 +1768,7 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) return err; } -void bt_mesh_rx_reset(void) +void bt_mesh_rx_reset(bool erase) { int i; @@ -1778,10 +1778,10 @@ void bt_mesh_rx_reset(void) seg_rx_reset(&seg_rx[i], true); } - if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + (void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl)); + + if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && erase) { bt_mesh_clear_rpl(); - } else { - (void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl)); } } @@ -1863,16 +1863,7 @@ void bt_mesh_trans_deinit(bool erase) { int i; - for (i = 0; i < ARRAY_SIZE(seg_rx); i++) { - seg_rx_reset(&seg_rx[i], true); - } - - if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { - bt_mesh_clear_rpl(); - } else { - bt_mesh_rpl_clear(); - } - + bt_mesh_rx_reset(erase); bt_mesh_tx_reset(); for (i = 0; i < ARRAY_SIZE(seg_tx); i++) { @@ -1887,12 +1878,6 @@ void bt_mesh_trans_deinit(bool erase) bt_mesh_rx_seg_mutex_free(); } -void bt_mesh_rpl_clear(void) -{ - BT_DBG("%s", __func__); - (void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl)); -} - void bt_mesh_heartbeat_send(void) { struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get(); @@ -1953,7 +1938,7 @@ int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, if (app_idx == BLE_MESH_KEY_DEV) { *key = bt_mesh_tx_devkey_get(role, dst); if (!*key) { - BT_ERR("%s, Failed to get Device Key", __func__); + BT_ERR("DevKey not found"); return -EINVAL; } @@ -1962,13 +1947,13 @@ int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, } if (!subnet) { - BT_ERR("%s, Invalid subnet", __func__); + BT_ERR("Invalid subnet"); return -EINVAL; } app_key = bt_mesh_tx_appkey_get(role, app_idx); if (!app_key) { - BT_ERR("%s, AppKey 0x%04x not exists", __func__, app_idx); + BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx); return -ENOENT; } diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.h b/components/bt/esp_ble_mesh/mesh_core/transport.h index ac80273b0..31c5f0e1a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.h +++ b/components/bt/esp_ble_mesh/mesh_core/transport.h @@ -97,7 +97,7 @@ struct bt_mesh_app_key *bt_mesh_app_key_find(u16_t app_idx); bool bt_mesh_tx_in_progress(void); -void bt_mesh_rx_reset(void); +void bt_mesh_rx_reset(bool erase); void bt_mesh_tx_reset(void); void bt_mesh_rx_reset_single(u16_t src); void bt_mesh_tx_reset_single(u16_t dst); @@ -114,7 +114,7 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx); void bt_mesh_trans_init(void); void bt_mesh_trans_deinit(bool erase); -void bt_mesh_rpl_clear(void); +bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match); void bt_mesh_heartbeat_send(void); diff --git a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c index c976c2737..b61c5579c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c @@ -48,10 +48,9 @@ static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t return NULL; } -bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool need_pub) +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub) { bt_mesh_client_internal_data_t *data = NULL; bt_mesh_client_user_data_t *cli = NULL; @@ -64,7 +63,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( cli = (bt_mesh_client_user_data_t *)model->user_data; if (!cli) { - BT_ERR("%s, Clinet user_data is NULL", __func__); + BT_ERR("Invalid client user data"); return NULL; } @@ -73,7 +72,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( * this message to the application layer. */ if (!BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) { - BT_DBG("Unexpected status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected status message 0x%08x", ctx->recv_op); if (cli->publish_status && need_pub) { cli->publish_status(ctx->recv_op, model, ctx, buf); } @@ -87,12 +86,12 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( */ data = (bt_mesh_client_internal_data_t *)cli->internal_data; if (!data) { - BT_ERR("%s, Client internal_data is NULL", __func__); + BT_ERR("Invalid client internal data"); return NULL; } if ((node = bt_mesh_client_pick_node(&data->queue, ctx->addr)) == NULL) { - BT_DBG("Unexpected status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected status message 0x%08x", ctx->recv_op); if (cli->publish_status && need_pub) { cli->publish_status(ctx->recv_op, model, ctx, buf); } @@ -100,7 +99,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( } if (node->op_pending != ctx->recv_op) { - BT_DBG("Unexpected status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected status message 0x%08x", ctx->recv_op); if (cli->publish_status && need_pub) { cli->publish_status(ctx->recv_op, model, ctx, buf); } @@ -108,7 +107,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( } if (k_delayed_work_remaining_get(&node->timer) == 0) { - BT_DBG("Unexpected status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected status message 0x%08x", ctx->recv_op); if (cli->publish_status && need_pub) { cli->publish_status(ctx->recv_op, model, ctx, buf); } @@ -143,7 +142,7 @@ static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) } static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair, - int size, u32_t opcode) + int size, u32_t opcode) { if (!op_pair || size == 0) { return 0; @@ -252,86 +251,87 @@ static const struct bt_mesh_send_cb send_cb = { .end = NULL, }; -int bt_mesh_client_send_msg(struct bt_mesh_model *model, - u32_t opcode, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *msg, - k_work_handler_t timer_handler, - s32_t timeout, bool need_ack, - const struct bt_mesh_send_cb *cb, - void *cb_data) +int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param, + struct net_buf_simple *msg, bool need_ack, + k_work_handler_t timer_handler) { bt_mesh_client_internal_data_t *internal = NULL; bt_mesh_client_user_data_t *client = NULL; bt_mesh_client_node_t *node = NULL; int err = 0; - if (!model || !ctx || !msg) { + if (!param || !param->model || !msg) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } - client = (bt_mesh_client_user_data_t *)model->user_data; + client = (bt_mesh_client_user_data_t *)param->model->user_data; if (!client) { - BT_ERR("%s, Invalid client user data", __func__); + BT_ERR("Invalid client user data"); return -EINVAL; } internal = (bt_mesh_client_internal_data_t *)client->internal_data; if (!internal) { - BT_ERR("%s, Invalid client internal data", __func__); + BT_ERR("Invalid client internal data"); return -EINVAL; } - if (ctx->addr == BLE_MESH_ADDR_UNASSIGNED) { - BT_ERR("%s, Invalid DST 0x%04x", __func__, ctx->addr); + if (param->ctx.addr == BLE_MESH_ADDR_UNASSIGNED) { + BT_ERR("Invalid DST 0x%04x", param->ctx.addr); return -EINVAL; } - if (!need_ack) { - /* If this is an unack message, send it directly. */ - return bt_mesh_model_send(model, ctx, msg, cb, cb_data); + if (bt_mesh_set_client_model_role(param->model, param->msg_role)) { + BT_ERR("Failed to set client role"); + return -EIO; } - if (!BLE_MESH_ADDR_IS_UNICAST(ctx->addr)) { - /* If an acknowledged message is not sent to a unicast address, - * for example to a group/virtual address, then all the - * corresponding responses will be treated as publish messages. - * And no timeout will be used for the message. + if (need_ack == false || !BLE_MESH_ADDR_IS_UNICAST(param->ctx.addr)) { + /* 1. If this is an unacknowledged message, send it directly. + * 2. If this is an acknowledged message, but the destination + * is not a unicast address, e.g. a group/virtual address, + * then all the corresponding responses will be treated as + * publish messages, and no timeout will be used. */ - return bt_mesh_model_send(model, ctx, msg, cb, cb_data); + err = bt_mesh_model_send(param->model, ¶m->ctx, msg, param->cb, param->cb_data); + if (err) { + BT_ERR("Failed to send client message 0x%08x", param->opcode); + } + return err; } if (!timer_handler) { - BT_ERR("%s, Invalid timeout handler", __func__); + BT_ERR("Invalid timeout handler"); return -EINVAL; } - if (bt_mesh_client_check_node_in_list(&internal->queue, ctx->addr)) { - BT_ERR("%s, Busy sending message to DST 0x%04x", __func__, ctx->addr); + if (bt_mesh_client_check_node_in_list(&internal->queue, param->ctx.addr)) { + BT_ERR("Busy sending message to DST 0x%04x", param->ctx.addr); return -EBUSY; } /* Don't forget to free the node in the timeout (timer_handler) function. */ node = (bt_mesh_client_node_t *)bt_mesh_calloc(sizeof(bt_mesh_client_node_t)); if (!node) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } - memcpy(&node->ctx, ctx, sizeof(struct bt_mesh_msg_ctx)); - node->ctx.model = model; - node->opcode = opcode; - node->op_pending = bt_mesh_client_get_status_op(client->op_pair, client->op_pair_size, opcode); + memcpy(&node->ctx, ¶m->ctx, sizeof(struct bt_mesh_msg_ctx)); + node->ctx.model = param->model; + node->opcode = param->opcode; + node->op_pending = bt_mesh_client_get_status_op(client->op_pair, client->op_pair_size, param->opcode); if (node->op_pending == 0U) { BT_ERR("Not found the status opcode in op_pair list"); bt_mesh_free(node); return -EINVAL; } - node->timeout = bt_mesh_client_calc_timeout(ctx, msg, opcode, timeout ? timeout : CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT); + node->timeout = bt_mesh_client_calc_timeout(¶m->ctx, msg, param->opcode, + param->msg_timeout ? param->msg_timeout : CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT); if (k_delayed_work_init(&node->timer, timer_handler)) { - BT_ERR("%s, Failed to create a timer", __func__); + BT_ERR("Failed to create a timer"); bt_mesh_free(node); return -EIO; } @@ -344,7 +344,7 @@ int bt_mesh_client_send_msg(struct bt_mesh_model *model, * Due to the higher priority of adv_thread (than btc task), we need to * send the packet after the list item "node" is initialized properly. */ - err = bt_mesh_model_send(model, ctx, msg, &send_cb, node); + err = bt_mesh_model_send(param->model, ¶m->ctx, msg, &send_cb, node); if (err) { BT_ERR("Failed to send client message 0x%08x", node->opcode); k_delayed_work_free(&node->timer); @@ -381,38 +381,33 @@ void bt_mesh_client_model_unlock(void) int bt_mesh_client_init(struct bt_mesh_model *model) { bt_mesh_client_internal_data_t *data = NULL; - bt_mesh_client_user_data_t *cli = NULL; + bt_mesh_client_user_data_t *client = NULL; - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + if (!model || !model->op) { + BT_ERR("Invalid vendor client model"); return -EINVAL; } - if (!model->op) { - BT_ERR("%s, Client model op is NULL", __func__); + client = (bt_mesh_client_user_data_t *)model->user_data; + if (!client) { + BT_ERR("No vendor client context provided"); return -EINVAL; } - cli = model->user_data; - if (!cli) { - BT_ERR("%s, Client user_data is NULL", __func__); - return -EINVAL; - } - - if (!cli->internal_data) { + if (!client->internal_data) { data = bt_mesh_calloc(sizeof(bt_mesh_client_internal_data_t)); if (!data) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } /* Init the client data queue */ sys_slist_init(&data->queue); - cli->model = model; - cli->internal_data = data; + client->model = model; + client->internal_data = data; } else { - bt_mesh_client_clear_list(cli->internal_data); + bt_mesh_client_clear_list(client->internal_data); } bt_mesh_client_model_mutex_new(); @@ -425,13 +420,13 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model) bt_mesh_client_user_data_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid vendor client model"); return -EINVAL; } client = (bt_mesh_client_user_data_t *)model->user_data; if (!client) { - BT_ERR("%s, Client user_data is NULL", __func__); + BT_ERR("No vendor client context provided"); return -EINVAL; } @@ -455,19 +450,19 @@ int bt_mesh_client_free_node(bt_mesh_client_node_t *node) bt_mesh_client_user_data_t *client = NULL; if (!node || !node->ctx.model) { - BT_ERR("%s, Client model list item is NULL", __func__); + BT_ERR("Invalid client list item"); return -EINVAL; } client = (bt_mesh_client_user_data_t *)node->ctx.model->user_data; if (!client) { - BT_ERR("%s, Client model user data is NULL", __func__); + BT_ERR("Invalid client user data"); return -EINVAL; } internal = (bt_mesh_client_internal_data_t *)client->internal_data; if (!internal) { - BT_ERR("%s, Client model internal data is NULL", __func__); + BT_ERR("Invalid client internal data"); return -EINVAL; } @@ -504,43 +499,26 @@ int bt_mesh_client_clear_list(void *data) return 0; } -int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common) +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role) { bt_mesh_client_user_data_t *client = NULL; - if (!common || !common->model || !common->model->user_data) { - BT_ERR("%s, Invalid parameter", __func__); + if (!model) { + BT_ERR("Invalid client model"); return -EINVAL; } - client = (bt_mesh_client_user_data_t *)common->model->user_data; - - switch (common->role) { -#if CONFIG_BLE_MESH_NODE - case NODE: - /* no matter if provisioner is enabled/disabled , node role can be used to send messages */ - client->msg_role = NODE; - break; -#endif -#if CONFIG_BLE_MESH_PROVISIONER - case PROVISIONER: - /* if provisioner is not enabled, provisioner role can't be used to send messages */ - if (!bt_mesh_is_provisioner_en()) { - BT_ERR("%s, Provisioner is disabled", __func__); - return -EINVAL; - } - client->msg_role = PROVISIONER; - break; -#endif -#if CONFIG_BLE_MESH_FAST_PROV - case FAST_PROV: - client->msg_role = FAST_PROV; - break; -#endif - default: - BT_WARN("%s, Unknown model role %x", __func__, common->role); + client = (bt_mesh_client_user_data_t *)model->user_data; + if (!client) { + BT_ERR("Invalid client user data"); return -EINVAL; } + if (role >= ROLE_NVAL) { + BT_ERR("Invalid client role 0x%02x", role); + return -EINVAL; + } + + client->msg_role = role; return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index 0aff82eb6..91542536c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -20,9 +20,9 @@ #include "model_opcode.h" #include "generic_client.h" -/** The following are the macro definitions of generic client - * model messages length, and a message is composed of three - * parts: Opcode + msg_value + MIC +/* The followings are the macro definitions of Generic client + * model message length, and a message is composed of 3 parts: + * Opcode + Payload + MIC */ /* Generic onoff client messages length */ #define BLE_MESH_GEN_ONOFF_GET_MSG_LEN (2 + 0 + 4) @@ -171,7 +171,7 @@ static void generic_status(struct bt_mesh_model *model, u8_t evt = 0xFF; size_t len = 0U; - BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS: { @@ -182,7 +182,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_onoff_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_onoff = net_buf_simple_pull_u8(buf); @@ -203,7 +203,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_level_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_level = net_buf_simple_pull_le16(buf); @@ -224,7 +224,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_def_trans_time_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->trans_time = net_buf_simple_pull_u8(buf); @@ -240,7 +240,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_onpowerup_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->onpowerup = net_buf_simple_pull_u8(buf); @@ -256,7 +256,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_level_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_power = net_buf_simple_pull_le16(buf); @@ -277,7 +277,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_last_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->power = net_buf_simple_pull_le16(buf); @@ -293,7 +293,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_default_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->power = net_buf_simple_pull_le16(buf); @@ -309,7 +309,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_power_range_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -327,7 +327,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_battery_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } u32_t value = 0; @@ -349,7 +349,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_loc_global_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->global_latitude = net_buf_simple_pull_le32(buf); @@ -367,7 +367,7 @@ static void generic_status(struct bt_mesh_model *model, } status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_loc_local_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->local_north = net_buf_simple_pull_le16(buf); @@ -383,12 +383,12 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_user_properties_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_user_properties_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->user_property_ids = bt_mesh_alloc_buf(buf->len); if (!status->user_property_ids) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -401,7 +401,7 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_user_property_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_user_property_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->user_property_id = net_buf_simple_pull_le16(buf); @@ -410,7 +410,7 @@ static void generic_status(struct bt_mesh_model *model, status->user_access = net_buf_simple_pull_u8(buf); status->user_property_value = bt_mesh_alloc_buf(buf->len); if (!status->user_property_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -424,12 +424,12 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_admin_properties_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_admin_properties_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->admin_property_ids = bt_mesh_alloc_buf(buf->len); if (!status->admin_property_ids) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -442,7 +442,7 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_admin_property_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_admin_property_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->admin_property_id = net_buf_simple_pull_le16(buf); @@ -451,7 +451,7 @@ static void generic_status(struct bt_mesh_model *model, status->admin_user_access = net_buf_simple_pull_u8(buf); status->admin_property_value = bt_mesh_alloc_buf(buf->len); if (!status->admin_property_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -465,12 +465,12 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_manu_properties_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_manu_properties_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->manu_property_ids = bt_mesh_alloc_buf(buf->len); if (!status->manu_property_ids) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -483,7 +483,7 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_manu_property_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_manu_property_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->manu_property_id = net_buf_simple_pull_le16(buf); @@ -492,7 +492,7 @@ static void generic_status(struct bt_mesh_model *model, status->manu_user_access = net_buf_simple_pull_u8(buf); status->manu_property_value = bt_mesh_alloc_buf(buf->len); if (!status->manu_property_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -506,12 +506,12 @@ static void generic_status(struct bt_mesh_model *model, struct bt_mesh_gen_client_properties_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_gen_client_properties_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->client_property_ids = bt_mesh_alloc_buf(buf->len); if (!status->client_property_ids) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -521,7 +521,7 @@ static void generic_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Not a Generic Status message opcode", __func__); + BT_ERR("Invalid Generic Status opcode 0x%04x", ctx->recv_op); return; } @@ -532,7 +532,7 @@ static void generic_status(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { - BT_DBG("Unexpected generic status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Generic Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case BLE_MESH_MODEL_OP_GEN_ONOFF_GET: @@ -636,27 +636,27 @@ static void generic_status(struct bt_mesh_model *model, return; } -const struct bt_mesh_model_op gen_onoff_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS, 1, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_level_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS, 2, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_def_trans_time_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS, 1, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_power_onoff_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS, 1, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_power_level_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS, 2, generic_status }, { BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS, 2, generic_status }, { BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS, 2, generic_status }, @@ -664,18 +664,18 @@ const struct bt_mesh_model_op gen_power_level_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_battery_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS, 8, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_location_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS, 10, generic_status }, { BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS, 9, generic_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op gen_property_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[] = { { BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS, 2, generic_status }, { BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS, 2, generic_status }, { BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS, 2, generic_status }, @@ -689,7 +689,6 @@ const struct bt_mesh_model_op gen_property_cli_op[] = { static int gen_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_GEN_GET_STATE_MSG_LEN); - int err = 0; bt_mesh_model_msg_init(&msg, common->opcode); @@ -720,19 +719,12 @@ static int gen_get_state(bt_mesh_client_common_param_t *common, void *value) break; } default: - BT_DBG("This generic message should be sent with NULL get pointer"); + BT_DBG("No parameters for Generic Get 0x%04x", common->opcode); break; } } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg, - timeout_handler, common->msg_timeout, true, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Generic Get message (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(common, &msg, true, timeout_handler); } static int gen_set_state(bt_mesh_client_common_param_t *common, @@ -743,7 +735,7 @@ static int gen_set_state(bt_mesh_client_common_param_t *common, msg = bt_mesh_alloc_buf(value_len); if (!msg) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -899,25 +891,19 @@ static int gen_set_state(bt_mesh_client_common_param_t *common, } default: - BT_ERR("%s, Not a Generic Client Set message opcode", __func__); + BT_ERR("Invalid Generic Set opcode 0x%04x", common->opcode); err = -EINVAL; goto end; } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg, - timeout_handler, common->msg_timeout, need_ack, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Generic Set message (err %d)", __func__, err); - } + err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler); end: bt_mesh_free_buf(msg); - return err; } -int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get) { bt_mesh_generic_client_t *client = NULL; @@ -928,7 +914,7 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void client = (bt_mesh_generic_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Generic Client user data is NULL", __func__); + BT_ERR("Invalid Generic client data"); return -EINVAL; } @@ -950,37 +936,37 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void break; case BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET: if (!get) { - BT_ERR("%s, Generic user_property_get is NULL", __func__); + BT_ERR("Invalid Generic User Property Get"); return -EINVAL; } break; case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET: if (!get) { - BT_ERR("%s, Generic admin_property_get is NULL", __func__); + BT_ERR("Invalid Generic Admin Property Get"); return -EINVAL; } break; case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET: if (!get) { - BT_ERR("%s, Generic manu_property_get is NULL", __func__); + BT_ERR("Invalid Generic Manu Property Get"); return -EINVAL; } break; case BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET: if (!get) { - BT_ERR("%s, Generic client_properties_get is NULL", __func__); + BT_ERR("Invalid Generic Client Properties Get"); return -EINVAL; } break; default: - BT_ERR("%s, Not a Generic Client Get message opcode", __func__); + BT_ERR("Invalid Generic Get opcode 0x%04x", common->opcode); return -EINVAL; } return gen_get_state(common, get); } -int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_generic_client_t *client = NULL; u16_t length = 0U; @@ -993,7 +979,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void client = (bt_mesh_generic_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Generic Client user data is NULL", __func__); + BT_ERR("Invalid Generic client data"); return -EINVAL; } @@ -1005,7 +991,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_gen_onoff_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic OnOff Set transition time", __func__); + BT_ERR("Invalid Generic OnOff Set transition time"); return -EINVAL; } } @@ -1019,7 +1005,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_gen_level_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic Level Set transition time", __func__); + BT_ERR("Invalid Generic Level Set transition time"); return -EINVAL; } } @@ -1033,7 +1019,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_gen_delta_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic Delta Set transition time", __func__); + BT_ERR("Invalid Generic Delta Set transition time"); return -EINVAL; } } @@ -1047,7 +1033,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_gen_move_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic Move Set transition time", __func__); + BT_ERR("Invalid Generic Move Set transition time"); return -EINVAL; } } @@ -1059,7 +1045,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void case BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK: { u8_t value = *(u8_t *)set; if ((value & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic Default Trans Time Set transition time", __func__); + BT_ERR("Invalid Generic Default Trans Time Set transition time"); return -EINVAL; } length = BLE_MESH_GEN_DEF_TRANS_TIME_SET_MSG_LEN; @@ -1077,7 +1063,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_gen_power_level_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Generic Power Level Set transition time", __func__); + BT_ERR("Invalid Generic Power Level Set transition time"); return -EINVAL; } } @@ -1095,7 +1081,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void struct bt_mesh_gen_power_range_set *value; value = (struct bt_mesh_gen_power_range_set *)set; if (value->range_min > value->range_max) { - BT_ERR("%s, Generic Power Level Set range min is greater than range max", __func__); + BT_ERR("Generic Power Level Set range min is greater than range max"); return -EINVAL; } length = BLE_MESH_GEN_POWER_RANGE_SET_MSG_LEN; @@ -1117,7 +1103,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void struct bt_mesh_gen_user_property_set *value; value = (struct bt_mesh_gen_user_property_set *)set; if (!value->user_property_value) { - BT_ERR("%s, Generic user_property_value is NULL", __func__); + BT_ERR("Invalid Generic User Property value"); return -EINVAL; } length = (1 + 2 + value->user_property_value->len + 4); @@ -1129,7 +1115,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void struct bt_mesh_gen_admin_property_set *value; value = (struct bt_mesh_gen_admin_property_set *)set; if (!value->admin_property_value) { - BT_ERR("%s, Generic admin_property_value is NULL", __func__); + BT_ERR("Invalid Generic Admin Property value"); return -EINVAL; } length = (1 + 2 + 1 + value->admin_property_value->len + 4); @@ -1141,35 +1127,33 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void length = BLE_MESH_GEN_MANU_PROPERTY_SET_MSG_LEN; break; default: - BT_ERR("%s, Not a Generic Client Set message opcode", __func__); + BT_ERR("Invalid Generic Set opcode 0x%04x", common->opcode); return -EINVAL; } return gen_set_state(common, set, length, need_ack); } -static int generic_client_init(struct bt_mesh_model *model, bool primary) +static int generic_client_init(struct bt_mesh_model *model) { generic_internal_data_t *internal = NULL; bt_mesh_generic_client_t *client = NULL; - BT_DBG("primary %u", primary); - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Generic client model"); return -EINVAL; } client = (bt_mesh_generic_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Generic Client user_data is NULL", __func__); + BT_ERR("No Generic client context provided"); return -EINVAL; } if (!client->internal_data) { internal = bt_mesh_calloc(sizeof(generic_internal_data_t)); if (!internal) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -1188,58 +1172,18 @@ static int generic_client_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_gen_onoff_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_level_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_def_trans_time_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_pwr_onoff_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_pwr_level_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_battery_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_location_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -int bt_mesh_gen_property_cli_init(struct bt_mesh_model *model, bool primary) -{ - return generic_client_init(model, primary); -} - -static int generic_client_deinit(struct bt_mesh_model *model, bool primary) +static int generic_client_deinit(struct bt_mesh_model *model) { bt_mesh_generic_client_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Generic client model"); return -EINVAL; } client = (bt_mesh_generic_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Generic Client user_data is NULL", __func__); + BT_ERR("No Generic client context provided"); return -EINVAL; } @@ -1257,42 +1201,7 @@ static int generic_client_deinit(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_gen_onoff_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_level_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_def_trans_time_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_pwr_onoff_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_pwr_level_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_battery_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_location_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} - -int bt_mesh_gen_property_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return generic_client_deinit(model, primary); -} +const struct bt_mesh_model_cb bt_mesh_generic_client_cb = { + .init = generic_client_init, + .deinit = generic_client_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h index a39bcb542..9883efe20 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -79,6 +79,7 @@ typedef struct { struct bt_mesh_model *model; /* Pointer to the client model */ struct bt_mesh_msg_ctx ctx; /* Message context */ s32_t msg_timeout; /* Time to get corresponding response */ + u8_t msg_role; /* Role (Node/Provisioner) of the device */ const struct bt_mesh_send_cb *cb; /* User defined callback function */ void *cb_data; /* User defined callback value */ } bt_mesh_client_common_param_t; @@ -100,36 +101,27 @@ int bt_mesh_client_deinit(struct bt_mesh_model *model); * @param need_pub Indicate if the msg sent to app layer as a publish msg * @return 0 on success, or (negative) error code on failure. */ -bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool need_pub); +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub); -int bt_mesh_client_send_msg(struct bt_mesh_model *model, - u32_t opcode, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *msg, - k_work_handler_t timer_handler, - s32_t timeout, bool need_ack, - const struct bt_mesh_send_cb *cb, void *cb_data); +int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param, + struct net_buf_simple *msg, bool need_ack, + k_work_handler_t timer_handler); int bt_mesh_client_free_node(bt_mesh_client_node_t *node); int bt_mesh_client_clear_list(void *data); -typedef struct { - struct bt_mesh_model *model; /* The client model structure */ - u8_t role; /* Role of the device - Node/Provisioner */ -} bt_mesh_role_param_t; - /** - * @brief This function copies node_index for stack internal use. + * @brief Set role of the client model for internal use. * - * @param[in] common: Pointer to the bt_mesh_role_param_t structure + * @param[in] model: Pointer to the client model + * @param[in] role: Role of the device * * @return Zero - success, otherwise - fail */ -int bt_mesh_set_client_model_role(bt_mesh_role_param_t *common); +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h index eeda99fc3..b9619ac1c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h @@ -29,8 +29,11 @@ extern "C" { typedef bt_mesh_client_user_data_t bt_mesh_generic_client_t; typedef bt_mesh_client_internal_data_t generic_internal_data_t; +/* Generic Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb; + /* Generic OnOff Client Model Context */ -extern const struct bt_mesh_model_op gen_onoff_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[]; /** @def BLE_MESH_MODEL_GEN_ONOFF_CLI * @@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op gen_onoff_cli_op[]; * @return New generic onoff client model instance. */ #define BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ - gen_onoff_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ + bt_mesh_gen_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t; @@ -64,7 +67,7 @@ struct bt_mesh_gen_onoff_set { }; /* Generic Level Client Model Context */ -extern const struct bt_mesh_model_op gen_level_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[]; /** @def BLE_MESH_MODEL_GEN_LEVEL_CLI * @@ -77,8 +80,8 @@ extern const struct bt_mesh_model_op gen_level_cli_op[]; * @return New generic level client model instance. */ #define BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ - gen_level_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ + bt_mesh_gen_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t; @@ -114,7 +117,7 @@ struct bt_mesh_gen_move_set { }; /* Generic Default Transition Time Client Model Context */ -extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[]; /** @def BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI * @@ -128,8 +131,8 @@ extern const struct bt_mesh_model_op gen_def_trans_time_cli_op[]; * @return New generic default transition time client model instance. */ #define BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ - gen_def_trans_time_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ + bt_mesh_gen_def_trans_time_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t; @@ -142,7 +145,7 @@ struct bt_mesh_gen_def_trans_time_status { }; /* Generic Power OnOff Client Model Context */ -extern const struct bt_mesh_model_op gen_power_onoff_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[]; /** @def BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI * @@ -155,8 +158,8 @@ extern const struct bt_mesh_model_op gen_power_onoff_cli_op[]; * @return New generic power onoff client model instance. */ #define BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ - gen_power_onoff_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ + bt_mesh_gen_power_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t; @@ -169,7 +172,7 @@ struct bt_mesh_gen_onpowerup_status { }; /* Generic Power Level Client Model Context */ -extern const struct bt_mesh_model_op gen_power_level_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[]; /** @def BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI * @@ -182,8 +185,8 @@ extern const struct bt_mesh_model_op gen_power_level_cli_op[]; * @return New generic power level client model instance. */ #define BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ - gen_power_level_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ + bt_mesh_gen_power_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t; @@ -226,7 +229,7 @@ struct bt_mesh_gen_power_range_set { }; /* Generic Battery Client Model Context */ -extern const struct bt_mesh_model_op gen_battery_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[]; /** @def BLE_MESH_MODEL_GEN_BATTERY_CLI * @@ -239,8 +242,8 @@ extern const struct bt_mesh_model_op gen_battery_cli_op[]; * @return New generic battery client model instance. */ #define BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ - gen_battery_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ + bt_mesh_gen_battery_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t; @@ -252,7 +255,7 @@ struct bt_mesh_gen_battery_status { }; /* Generic Location Client Model Context */ -extern const struct bt_mesh_model_op gen_location_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[]; /** @def BLE_MESH_MODEL_GEN_LOCATION_CLI * @@ -265,8 +268,8 @@ extern const struct bt_mesh_model_op gen_location_cli_op[]; * @return New generic location client model instance. */ #define BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ - gen_location_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ + bt_mesh_gen_location_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t; @@ -299,7 +302,7 @@ struct bt_mesh_gen_loc_local_set { }; /* Generic Property Client Model Context */ -extern const struct bt_mesh_model_op gen_property_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[]; /** @def BLE_MESH_MODEL_GEN_LOCATION_CLI * @@ -312,8 +315,8 @@ extern const struct bt_mesh_model_op gen_property_cli_op[]; * @return New generic location client model instance. */ #define BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ - gen_property_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ + bt_mesh_gen_property_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_gen_property_client_t; @@ -386,189 +389,25 @@ struct bt_mesh_gen_client_properties_get { u16_t client_property_id; /* A starting Client Property ID present within an element */ }; -/** - * @brief This function is called to initialize generic onoff client model user_data. - * - * @param[in] model: Pointer to generic onoff client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_onoff_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic level client model user_data. - * - * @param[in] model: Pointer to generic level client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_level_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic default transition time - * client model user_data. - * - * @param[in] model: Pointer to generic default transition time client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_def_trans_time_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic power onoff client model user_data. - * - * @param[in] model: Pointer to generic power onoff client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_pwr_onoff_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic power level client model user_data. - * - * @param[in] model: Pointer to generic power level client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_pwr_level_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic battery client model user_data. - * - * @param[in] model: Pointer to generic battery client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_battery_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic location client model user_data. - * - * @param[in] model: Pointer to generic location client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_location_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize generic property client model user_data. - * - * @param[in] model: Pointer to generic property client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_property_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic onoff client model user_data. - * - * @param[in] model: Pointer to generic onoff client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_onoff_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic level client model user_data. - * - * @param[in] model: Pointer to generic level client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_level_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic default transition time - * client model user_data. - * - * @param[in] model: Pointer to generic default transition time client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_def_trans_time_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic power onoff client model user_data. - * - * @param[in] model: Pointer to generic power onoff client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_pwr_onoff_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic power level client model user_data. - * - * @param[in] model: Pointer to generic power level client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_pwr_level_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic battery client model user_data. - * - * @param[in] model: Pointer to generic battery client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_battery_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic location client model user_data. - * - * @param[in] model: Pointer to generic location client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_location_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize generic property client model user_data. - * - * @param[in] model: Pointer to generic property client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_gen_property_cli_deinit(struct bt_mesh_model *model, bool primary); - /** * @brief This function is called to get generic states. * * @param[in] common: Message common information structure * @param[in] get: Pointer of generic get message value - * @param[out] status: Pointer of generic status message value * * @return Zero-success, other-fail */ -int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get); /** * @brief This function is called to set generic states. * * @param[in] common: Message common information structure * @param[in] set: Pointer of generic set message value - * @param[out] status: Pointer of generic status message value * * @return Zero-success, other-fail */ -int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h index 7867f10ad..5f1f8a86c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h @@ -29,8 +29,11 @@ extern "C" { typedef bt_mesh_client_user_data_t bt_mesh_light_client_t; typedef bt_mesh_client_internal_data_t light_internal_data_t; +/* Lighting Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb; + /* Light Lightness Client Model Context */ -extern const struct bt_mesh_model_op light_lightness_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[]; /** @def BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI * @@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op light_lightness_cli_op[]; * @return New light lightness client model instance. */ #define BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ - light_lightness_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ + bt_mesh_light_lightness_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t; @@ -102,7 +105,7 @@ struct bt_mesh_light_lightness_range_set { }; /* Light CTL Client Model Context */ -extern const struct bt_mesh_model_op light_ctl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[]; /** @def BLE_MESH_MODEL_LIGHT_CTL_CLI * @@ -115,8 +118,8 @@ extern const struct bt_mesh_model_op light_ctl_cli_op[]; * @return New light CTL client model instance. */ #define BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ - light_ctl_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ + bt_mesh_light_ctl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t; @@ -181,7 +184,7 @@ struct bt_mesh_light_ctl_default_set { }; /* Light HSL Client Model Context */ -extern const struct bt_mesh_model_op light_hsl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[]; /** @def BLE_MESH_MODEL_LIGHT_HSL_CLI * @@ -194,8 +197,8 @@ extern const struct bt_mesh_model_op light_hsl_cli_op[]; * @return New light HSL client model instance. */ #define BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ - light_hsl_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ + bt_mesh_light_hsl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t; @@ -283,7 +286,7 @@ struct bt_mesh_light_hsl_range_set { }; /* Light xyL Client Model Context */ -extern const struct bt_mesh_model_op light_xyl_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[]; /** @def BLE_MESH_MODEL_LIGHT_XYL_CLI * @@ -296,8 +299,8 @@ extern const struct bt_mesh_model_op light_xyl_cli_op[]; * @return New light xyL client model instance. */ #define BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ - light_xyl_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ + bt_mesh_light_xyl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t; @@ -355,7 +358,7 @@ struct bt_mesh_light_xyl_range_set { }; /* Light LC Client Model Context */ -extern const struct bt_mesh_model_op light_lc_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[]; /** @def BLE_MESH_MODEL_LIGHT_LC_CLI * @@ -368,8 +371,8 @@ extern const struct bt_mesh_model_op light_lc_cli_op[]; * @return New light lc client model instance. */ #define BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ - light_lc_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ + bt_mesh_light_lc_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t; @@ -418,127 +421,25 @@ struct bt_mesh_light_lc_property_set { struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ }; -/** - * @brief This function is called to initialize light lightness client model user_data. - * - * @param[in] model: Pointer to light lightness client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_lightness_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize light ctl client model user_data. - * - * @param[in] model: Pointer to light ctl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_ctl_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize light hsl client model user_data. - * - * @param[in] model: Pointer to light hsl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_hsl_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize light xyl client model user_data. - * - * @param[in] model: Pointer to light xyl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_xyl_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize light lc client model user_data. - * - * @param[in] model: Pointer to light lc client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_lc_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize light lightness client model user_data. - * - * @param[in] model: Pointer to light lightness client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_lightness_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize light ctl client model user_data. - * - * @param[in] model: Pointer to light ctl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_ctl_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize light hsl client model user_data. - * - * @param[in] model: Pointer to light hsl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_hsl_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize light xyl client model user_data. - * - * @param[in] model: Pointer to light xyl client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_xyl_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize light lc client model user_data. - * - * @param[in] model: Pointer to light lc client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_light_lc_cli_deinit(struct bt_mesh_model *model, bool primary); - /** * @brief This function is called to get light states. * * @param[in] common: Message common information structure * @param[in] get: Pointer of light get message value - * @param[out] status: Pointer of light status message value * * @return Zero-success, other-fail */ -int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get); /** * @brief This function is called to set light states. * * @param[in] common: Message common information structure * @param[in] set: Pointer of light set message value - * @param[out] status: Pointer of light status message value * * @return Zero-success, other-fail */ -int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h index 135eaf799..70fb3989d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h @@ -25,8 +25,11 @@ extern "C" { #endif +/* Sensor Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb; + /* Sensor Client Model Context */ -extern const struct bt_mesh_model_op sensor_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[]; /** @def BLE_MESH_MODEL_SENSOR_CLI * @@ -39,8 +42,8 @@ extern const struct bt_mesh_model_op sensor_cli_op[]; * @return New sensor client model instance. */ #define BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SENSOR_CLI, \ - sensor_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SENSOR_CLI, \ + bt_mesh_sensor_cli_op, cli_pub, cli_data, &bt_mesh_sensor_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_sensor_client_t; typedef bt_mesh_client_internal_data_t sensor_internal_data_t; @@ -133,47 +136,25 @@ struct bt_mesh_sensor_series_get { struct net_buf_simple *raw_value_x2; /* Raw value identifying a ending column (C.1) */ }; -/** - * @brief This function is called to initialize sensor client model user_data. - * - * @param[in] model: Pointer to sensor client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize sensor client model user_data. - * - * @param[in] model: Pointer to sensor client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary); - /** * @brief This function is called to get sensor states. * * @param[in] common: Message common information structure * @param[in] get: Pointer of sensor get message value - * @param[out] status: Pointer of sensor status message value * * @return Zero-success, other-fail */ -int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get); /** * @brief This function is called to set sensor states. * * @param[in] common: Message common information structure * @param[in] set: Pointer of sensor set message value - * @param[out] status: Pointer of sensor status message value * * @return Zero-success, other-fail */ -int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h index 11a917f41..78cce2cbb 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h @@ -29,8 +29,11 @@ extern "C" { typedef bt_mesh_client_user_data_t bt_mesh_time_scene_client_t; typedef bt_mesh_client_internal_data_t time_scene_internal_data_t; +/* Time Scene Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb; + /* Time Client Model Context */ -extern const struct bt_mesh_model_op time_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_time_cli_op[]; /** @def BLE_MESH_MODEL_TIME_CLI * @@ -43,8 +46,8 @@ extern const struct bt_mesh_model_op time_cli_op[]; * @return New time client model instance. */ #define BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_TIME_CLI, \ - time_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_TIME_CLI, \ + bt_mesh_time_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_time_client_t; @@ -100,7 +103,7 @@ struct bt_mesh_time_role_set { }; /* Scene Client Model Context */ -extern const struct bt_mesh_model_op scene_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[]; /** @def BLE_MESH_MODEL_SCENE_CLI * @@ -113,8 +116,8 @@ extern const struct bt_mesh_model_op scene_cli_op[]; * @return New scene client model instance. */ #define BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCENE_CLI, \ - scene_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCENE_CLI, \ + bt_mesh_scene_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t; @@ -149,7 +152,7 @@ struct bt_mesh_scene_delete { }; /* Scheduler Client Model Context */ -extern const struct bt_mesh_model_op scheduler_cli_op[]; +extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[]; /** @def BLE_MESH_MODEL_SCHEDULER_CLI * @@ -162,8 +165,8 @@ extern const struct bt_mesh_model_op scheduler_cli_op[]; * @return New scheduler client model instance. */ #define BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ - BLE_MESH_MODEL(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ - scheduler_cli_op, cli_pub, cli_data) + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ + bt_mesh_scheduler_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t; @@ -203,87 +206,25 @@ struct bt_mesh_scheduler_act_set { u16_t scene_number; /* Transition time for this action */ }; -/** - * @brief This function is called to initialize time client model user_data. - * - * @param[in] model: Pointer to time client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_time_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize scene client model user_data. - * - * @param[in] model: Pointer to scene client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_scene_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to initialize scheduler client model user_data. - * - * @param[in] model: Pointer to scheduler client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_scheduler_cli_init(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize time client model user_data. - * - * @param[in] model: Pointer to time client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_time_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize scene client model user_data. - * - * @param[in] model: Pointer to scene client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_scene_cli_deinit(struct bt_mesh_model *model, bool primary); - -/** - * @brief This function is called to de-initialize scheduler client model user_data. - * - * @param[in] model: Pointer to scheduler client model - * @param[in] primary: Whether belongs to primary element - * - * @return Zero-success, other-fail - */ -int bt_mesh_scheduler_cli_deinit(struct bt_mesh_model *model, bool primary); - /** * @brief This function is called to get scene states. * * @param[in] common: Message common information structure * @param[in] get: Pointer of time scene get message value - * @param[out] status: Pointer of time scene status message value * * @return Zero-success, other-fail */ -int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status); +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get); /** * @brief This function is called to set scene states. * * @param[in] common: Message common information structure * @param[in] set: Pointer of time scene set message value - * @param[out] status: Pointer of time scene status message value * * @return Zero-success, other-fail */ -int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status); +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index 5ab225ab5..eaf96b01a 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -20,9 +20,9 @@ #include "model_opcode.h" #include "lighting_client.h" -/** The following are the macro definitions of lighting client - * model messages length, and a message is composed of three - * parts: Opcode + msg_value + MIC +/* The followings are the macro definitions of Lighting client + * model message length, and a message is composed of 3 parts: + * Opcode + Payload + MIC */ /* Light lightness client messages length */ #define BLE_MESH_LIGHT_LIGHTNESS_GET_MSG_LEN (2 + 0 + 4) @@ -180,18 +180,18 @@ static void light_status(struct bt_mesh_model *model, u8_t evt = 0xFF; size_t len = 0U; - BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS: { struct bt_mesh_light_lightness_status *status = NULL; if (buf->len != 2 && buf->len != 5) { - BT_ERR("%s, Invalid Light Lightness Status length %d", __func__, buf->len); + BT_ERR("Invalid Light Lightness Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_lightness = net_buf_simple_pull_le16(buf); @@ -207,12 +207,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS: { struct bt_mesh_light_lightness_linear_status *status = NULL; if (buf->len != 2 && buf->len != 5) { - BT_ERR("%s, Invalid Light Lightness Linear Status length %d", __func__, buf->len); + BT_ERR("Invalid Light Lightness Linear Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_linear_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_lightness = net_buf_simple_pull_le16(buf); @@ -228,12 +228,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS: { struct bt_mesh_light_lightness_last_status *status = NULL; if (buf->len != 2) { - BT_ERR("%s, Invalid Light Lightness Last Status length %d", __func__, buf->len); + BT_ERR("Invalid Light Lightness Last Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_last_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->lightness = net_buf_simple_pull_le16(buf); @@ -244,12 +244,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS: { struct bt_mesh_light_lightness_default_status *status = NULL; if (buf->len != 2) { - BT_ERR("%s, Invalid Light Lightness Default Status length %d", __func__, buf->len); + BT_ERR("Invalid Light Lightness Default Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_default_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->lightness = net_buf_simple_pull_le16(buf); @@ -260,12 +260,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS: { struct bt_mesh_light_lightness_range_status *status = NULL; if (buf->len != 5) { - BT_ERR("%s, Invalid Light Lightness Range Status length %d", __func__, buf->len); + BT_ERR("Invalid Light Lightness Range Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lightness_range_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -278,12 +278,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS: { struct bt_mesh_light_ctl_status *status = NULL; if (buf->len != 4 && buf->len != 9) { - BT_ERR("%s, Invalid Light CTL Status length %d", __func__, buf->len); + BT_ERR("Invalid Light CTL Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_ctl_lightness = net_buf_simple_pull_le16(buf); @@ -301,12 +301,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS: { struct bt_mesh_light_ctl_temperature_status *status = NULL; if (buf->len != 4 && buf->len != 9) { - BT_ERR("%s, Invalid Light CTL Temperature Status length %d", __func__, buf->len); + BT_ERR("Invalid Light CTL Temperature Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_temperature_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_ctl_temperature = net_buf_simple_pull_le16(buf); @@ -324,12 +324,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS: { struct bt_mesh_light_ctl_temperature_range_status *status = NULL; if (buf->len != 5) { - BT_ERR("%s, Invalid Light CTL Temperature Range Status length %d", __func__, buf->len); + BT_ERR("Invalid Light CTL Temperature Range Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_temperature_range_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -342,12 +342,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS: { struct bt_mesh_light_ctl_default_status *status = NULL; if (buf->len != 6) { - BT_ERR("%s, Invalid Light CTL Default Status length %d", __func__, buf->len); + BT_ERR("Invalid Light CTL Default Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_ctl_default_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->lightness = net_buf_simple_pull_le16(buf); @@ -360,12 +360,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS: { struct bt_mesh_light_hsl_status *status = NULL; if (buf->len != 6 && buf->len != 7) { - BT_ERR("%s, Invalid Light HSL Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->hsl_lightness = net_buf_simple_pull_le16(buf); @@ -382,12 +382,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS: { struct bt_mesh_light_hsl_target_status *status = NULL; if (buf->len != 6 && buf->len != 7) { - BT_ERR("%s, Invalid Light HSL Target Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Target Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_target_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->hsl_lightness_target = net_buf_simple_pull_le16(buf); @@ -404,12 +404,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS: { struct bt_mesh_light_hsl_hue_status *status = NULL; if (buf->len != 2 && buf->len != 5) { - BT_ERR("%s, Invalid Light HSL Hue Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Hue Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_hue_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_hue = net_buf_simple_pull_le16(buf); @@ -425,12 +425,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS: { struct bt_mesh_light_hsl_saturation_status *status = NULL; if (buf->len != 2 && buf->len != 5) { - BT_ERR("%s, Invalid Light HSL Saturation Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Saturation Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_saturation_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_saturation = net_buf_simple_pull_le16(buf); @@ -446,12 +446,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS: { struct bt_mesh_light_hsl_default_status *status = NULL; if (buf->len != 6) { - BT_ERR("%s, Invalid Light HSL Default Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Default Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_default_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->lightness = net_buf_simple_pull_le16(buf); @@ -464,12 +464,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS: { struct bt_mesh_light_hsl_range_status *status = NULL; if (buf->len != 9) { - BT_ERR("%s, Invalid Light HSL Range Status length %d", __func__, buf->len); + BT_ERR("Invalid Light HSL Range Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_hsl_range_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -484,12 +484,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS: { struct bt_mesh_light_xyl_status *status = NULL; if (buf->len != 6 && buf->len != 7) { - BT_ERR("%s, Invalid Light xyL Status length %d", __func__, buf->len); + BT_ERR("Invalid Light xyL Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->xyl_lightness = net_buf_simple_pull_le16(buf); @@ -506,12 +506,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS: { struct bt_mesh_light_xyl_target_status *status = NULL; if (buf->len != 6 && buf->len != 7) { - BT_ERR("%s, Invalid Light xyL Target Status length %d", __func__, buf->len); + BT_ERR("Invalid Light xyL Target Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_target_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->target_xyl_lightness = net_buf_simple_pull_le16(buf); @@ -528,12 +528,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS: { struct bt_mesh_light_xyl_default_status *status = NULL; if (buf->len != 6) { - BT_ERR("%s, Invalid Light xyL Default Status length %d", __func__, buf->len); + BT_ERR("Invalid Light xyL Default Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_default_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->lightness = net_buf_simple_pull_le16(buf); @@ -546,12 +546,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS: { struct bt_mesh_light_xyl_range_status *status = NULL; if (buf->len != 9) { - BT_ERR("%s, Invalid Light xyL Range Status length %d", __func__, buf->len); + BT_ERR("Invalid Light xyL Range Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_xyl_range_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -566,12 +566,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS: { struct bt_mesh_light_lc_mode_status *status = NULL; if (buf->len != 1) { - BT_ERR("%s, Invalid Light LC Mode Status length %d", __func__, buf->len); + BT_ERR("Invalid Light LC Mode Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_mode_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->mode = net_buf_simple_pull_u8(buf); @@ -582,12 +582,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS: { struct bt_mesh_light_lc_om_status *status = NULL; if (buf->len != 1) { - BT_ERR("%s, Invalid Light LC OM Status length %d", __func__, buf->len); + BT_ERR("Invalid Light LC OM Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_om_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->mode = net_buf_simple_pull_u8(buf); @@ -598,12 +598,12 @@ static void light_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS: { struct bt_mesh_light_lc_light_onoff_status *status = NULL; if (buf->len != 1 && buf->len != 3) { - BT_ERR("%s, Invalid Light LC Light OnOff Status length %d", __func__, buf->len); + BT_ERR("Invalid Light LC Light OnOff Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_light_onoff_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->present_light_onoff = net_buf_simple_pull_u8(buf); @@ -620,13 +620,13 @@ static void light_status(struct bt_mesh_model *model, struct bt_mesh_light_lc_property_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_light_lc_property_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->light_lc_property_id = net_buf_simple_pull_le16(buf); status->light_lc_property_value = bt_mesh_alloc_buf(buf->len); if (!status->light_lc_property_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -636,7 +636,7 @@ static void light_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Not a Lighting Status message opcode", __func__); + BT_ERR("Invalid Lighting Status opcode 0x%04x", ctx->recv_op); return; } @@ -647,7 +647,7 @@ static void light_status(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { - BT_DBG("Unexpected light status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Lighting Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET: @@ -726,7 +726,7 @@ static void light_status(struct bt_mesh_model *model, return; } -const struct bt_mesh_model_op light_lightness_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS, 2, light_status }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS, 2, light_status }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS, 2, light_status }, @@ -735,7 +735,7 @@ const struct bt_mesh_model_op light_lightness_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op light_ctl_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[] = { { BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS, 4, light_status }, { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS, 4, light_status }, { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS, 5, light_status }, @@ -743,7 +743,7 @@ const struct bt_mesh_model_op light_ctl_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op light_hsl_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[] = { { BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS, 6, light_status }, { BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS, 6, light_status }, { BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS, 2, light_status }, @@ -753,7 +753,7 @@ const struct bt_mesh_model_op light_hsl_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op light_xyl_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[] = { { BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS, 6, light_status }, { BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS, 6, light_status }, { BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS, 6, light_status }, @@ -761,7 +761,7 @@ const struct bt_mesh_model_op light_xyl_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op light_lc_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS, 1, light_status }, { BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS, 1, light_status }, { BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS, 1, light_status }, @@ -772,7 +772,6 @@ const struct bt_mesh_model_op light_lc_cli_op[] = { static int light_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_LIGHT_GET_STATE_MSG_LEN); - int err = 0; bt_mesh_model_msg_init(&msg, common->opcode); @@ -785,19 +784,12 @@ static int light_get_state(bt_mesh_client_common_param_t *common, void *value) break; } default: - BT_DBG("This lighting message should be sent with NULL get pointer"); + BT_DBG("No parameters for Lighting Get 0x%04x", common->opcode); break; } } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg, - timeout_handler, common->msg_timeout, true, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Lighting Client Get message (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(common, &msg, true, timeout_handler); } static int light_set_state(bt_mesh_client_common_param_t *common, @@ -808,7 +800,7 @@ static int light_set_state(bt_mesh_client_common_param_t *common, msg = bt_mesh_alloc_buf(value_len); if (!msg) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -1023,25 +1015,19 @@ static int light_set_state(bt_mesh_client_common_param_t *common, break; } default: - BT_ERR("%s, Not a Lighting Client Set message opcode", __func__); + BT_ERR("Invalid Lighting Set opcode 0x%04x", common->opcode); err = -EINVAL; goto end; } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg, - timeout_handler, common->msg_timeout, need_ack, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Lighting Client Set message (err %d)", __func__, err); - } + err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler); end: bt_mesh_free_buf(msg); - return err; } -int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get) { bt_mesh_light_client_t *client = NULL; @@ -1052,7 +1038,7 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void * client = (bt_mesh_light_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Lighting Client user data is NULL", __func__); + BT_ERR("Invalid Lighting client data"); return -EINVAL; } @@ -1082,19 +1068,19 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void * break; case BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET: if (!get) { - BT_ERR("%s, Lighting lc_property_get is NULL", __func__); + BT_ERR("Invalid Lighting LC Property Get"); return -EINVAL; } break; default: - BT_ERR("%s, Not a Lighting Client Get message opcode", __func__); + BT_ERR("Invalid Lighting Get opcode 0x%04x", common->opcode); return -EINVAL; } return light_get_state(common, get); } -int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_light_client_t *client = NULL; u16_t length = 0U; @@ -1107,7 +1093,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * client = (bt_mesh_light_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Lighting Client user data is NULL", __func__); + BT_ERR("Invalid Lighting client data"); return -EINVAL; } @@ -1119,7 +1105,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_lightness_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light Lightness Set transition time", __func__); + BT_ERR("Invalid Light Lightness Set transition time"); return -EINVAL; } } @@ -1133,7 +1119,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_lightness_linear_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light Lightness Linear Set transition time", __func__); + BT_ERR("Invalid Light Lightness Linear Set transition time"); return -EINVAL; } } @@ -1151,7 +1137,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * struct bt_mesh_light_lightness_range_set *value; value = (struct bt_mesh_light_lightness_range_set *)set; if (value->range_min > value->range_max) { - BT_ERR("%s, Light Lightness Range Set range min is greater than range max", __func__); + BT_ERR("Light Lightness Range Set range min is greater than range max"); return -EINVAL; } length = BLE_MESH_LIGHT_LIGHTNESS_RANGE_SET_MSG_LEN; @@ -1164,7 +1150,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_ctl_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light CTL Set transition time", __func__); + BT_ERR("Invalid Light CTL Set transition time"); return -EINVAL; } } @@ -1178,7 +1164,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_ctl_temperature_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light CTL Temperature Set transition time", __func__); + BT_ERR("Invalid Light CTL Temperature Set transition time"); return -EINVAL; } } @@ -1191,7 +1177,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * struct bt_mesh_light_ctl_temperature_range_set *value; value = (struct bt_mesh_light_ctl_temperature_range_set *)set; if (value->range_min > value->range_max) { - BT_ERR("%s, Light CTL Temperature Range Set range min is greater than range max", __func__); + BT_ERR("Light CTL Temperature Range Set range min is greater than range max"); return -EINVAL; } length = BLE_MESH_LIGHT_CTL_TEMPERATURE_RANGE_SET_MSG_LEN; @@ -1209,7 +1195,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_hsl_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light HSL Set transition time", __func__); + BT_ERR("Invalid Light HSL Set transition time"); return -EINVAL; } } @@ -1223,7 +1209,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_hsl_hue_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light HSL Hue Set transition time", __func__); + BT_ERR("Invalid Light HSL Hue Set transition time"); return -EINVAL; } } @@ -1237,7 +1223,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_hsl_saturation_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light HSL Saturation Set transition time", __func__); + BT_ERR("Invalid Light HSL Saturation Set transition time"); return -EINVAL; } } @@ -1256,7 +1242,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_hsl_range_set *)set; if (value->hue_range_min > value->hue_range_max || value->saturation_range_min > value->saturation_range_max) { - BT_ERR("%s, Light HSL Range Set range min is greater than range max", __func__); + BT_ERR("Light HSL Range Set range min is greater than range max"); return -EINVAL; } length = BLE_MESH_LIGHT_HSL_RANGE_SET_MSG_LEN; @@ -1269,7 +1255,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_xyl_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light xyL Set transition time", __func__); + BT_ERR("Invalid Light xyL Set transition time"); return -EINVAL; } } @@ -1288,7 +1274,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_xyl_range_set *)set; if (value->xyl_x_range_min > value->xyl_x_range_max || value->xyl_y_range_min > value->xyl_y_range_max) { - BT_ERR("%s, Light xyL Range Set range min is greater than range max", __func__); + BT_ERR("Light xyL Range Set range min is greater than range max"); return -EINVAL; } length = BLE_MESH_LIGHT_XYL_RANGE_SET_MSG_LEN; @@ -1311,7 +1297,7 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * value = (struct bt_mesh_light_lc_light_onoff_set *)set; if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Light LC Light OnOff Set transition time", __func__); + BT_ERR("Invalid Light LC Light OnOff Set transition time"); return -EINVAL; } } @@ -1324,42 +1310,40 @@ int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void * struct bt_mesh_light_lc_property_set *value; value = (struct bt_mesh_light_lc_property_set *)set; if (!value->light_lc_property_value) { - BT_ERR("%s, Lighting light_lc_property_value is NULL", __func__); + BT_ERR("Invalid Lighting Light LC Property value"); return -EINVAL; } length = (1 + 2 + value->light_lc_property_value->len + 4); break; } default: - BT_ERR("%s, Not a Lighting Client Set message opcode", __func__); + BT_ERR("Invalid Lighting Set opcode 0x%04x", common->opcode); return -EINVAL; } return light_set_state(common, set, length, need_ack); } -static int light_client_init(struct bt_mesh_model *model, bool primary) +static int lighting_client_init(struct bt_mesh_model *model) { light_internal_data_t *internal = NULL; bt_mesh_light_client_t *client = NULL; - BT_DBG("primary %u", primary); - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Lighting client model"); return -EINVAL; } client = (bt_mesh_light_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Lighting Client user_data is NULL", __func__); + BT_ERR("No Lighting client context provided"); return -EINVAL; } if (!client->internal_data) { internal = bt_mesh_calloc(sizeof(light_internal_data_t)); if (!internal) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -1378,43 +1362,18 @@ static int light_client_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_light_lightness_cli_init(struct bt_mesh_model *model, bool primary) -{ - return light_client_init(model, primary); -} - -int bt_mesh_light_ctl_cli_init(struct bt_mesh_model *model, bool primary) -{ - return light_client_init(model, primary); -} - -int bt_mesh_light_hsl_cli_init(struct bt_mesh_model *model, bool primary) -{ - return light_client_init(model, primary); -} - -int bt_mesh_light_xyl_cli_init(struct bt_mesh_model *model, bool primary) -{ - return light_client_init(model, primary); -} - -int bt_mesh_light_lc_cli_init(struct bt_mesh_model *model, bool primary) -{ - return light_client_init(model, primary); -} - -static int light_client_deinit(struct bt_mesh_model *model, bool primary) +static int lighting_client_deinit(struct bt_mesh_model *model) { bt_mesh_light_client_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Lighting client model"); return -EINVAL; } client = (bt_mesh_light_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Lighting Client user_data is NULL", __func__); + BT_ERR("No Lighting client context provided"); return -EINVAL; } @@ -1432,27 +1391,7 @@ static int light_client_deinit(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_light_lightness_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return light_client_deinit(model, primary); -} - -int bt_mesh_light_ctl_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return light_client_deinit(model, primary); -} - -int bt_mesh_light_hsl_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return light_client_deinit(model, primary); -} - -int bt_mesh_light_xyl_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return light_client_deinit(model, primary); -} - -int bt_mesh_light_lc_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return light_client_deinit(model, primary); -} \ No newline at end of file +const struct bt_mesh_model_cb bt_mesh_lighting_client_cb = { + .init = lighting_client_init, + .deinit = lighting_client_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index 18e1e389e..47ee42e2c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -20,9 +20,9 @@ #include "model_opcode.h" #include "sensor_client.h" -/** The following are the macro definitions of sensor client - * model messages length, and a message is composed of three - * parts: Opcode + msg_value + MIC +/* The followings are the macro definitions of Sensor client + * model message length, and a message is composed of 3 parts: + * Opcode + Payload + MIC */ /* Sensor client messages length */ #define BLE_MESH_SENSOR_DESCRIPTOR_GET_MSG_LEN (2 + 2 + 4) @@ -109,19 +109,19 @@ static void sensor_status(struct bt_mesh_model *model, u8_t evt = 0xFF; size_t len = 0U; - BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS: { struct bt_mesh_sensor_descriptor_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_descriptor_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->descriptor = bt_mesh_alloc_buf(buf->len); if (!status->descriptor) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -134,13 +134,13 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_cadence_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_cadence_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->property_id = net_buf_simple_pull_le16(buf); status->sensor_cadence_value = bt_mesh_alloc_buf(buf->len); if (!status->sensor_cadence_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -153,13 +153,13 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_settings_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_settings_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->sensor_property_id = net_buf_simple_pull_le16(buf); status->sensor_setting_property_ids = bt_mesh_alloc_buf(buf->len); if (!status->sensor_setting_property_ids) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -172,7 +172,7 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_setting_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_setting_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->sensor_property_id = net_buf_simple_pull_le16(buf); @@ -182,7 +182,7 @@ static void sensor_status(struct bt_mesh_model *model, status->sensor_setting_access = net_buf_simple_pull_u8(buf); status->sensor_setting_raw = bt_mesh_alloc_buf(buf->len); if (!status->sensor_setting_raw) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -196,12 +196,12 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->marshalled_sensor_data = bt_mesh_alloc_buf(buf->len); if (!status->marshalled_sensor_data) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -214,13 +214,13 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_column_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_column_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->property_id = net_buf_simple_pull_le16(buf); status->sensor_column_value = bt_mesh_alloc_buf(buf->len); if (!status->sensor_column_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -233,13 +233,13 @@ static void sensor_status(struct bt_mesh_model *model, struct bt_mesh_sensor_series_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_sensor_series_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->property_id = net_buf_simple_pull_le16(buf); status->sensor_series_value = bt_mesh_alloc_buf(buf->len); if (!status->sensor_series_value) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -249,7 +249,7 @@ static void sensor_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Not a Sensor Status message opcode", __func__); + BT_ERR("Invalid Sensor Status opcode 0x%04x", ctx->recv_op); return; } @@ -260,7 +260,7 @@ static void sensor_status(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { - BT_DBG("Unexpected sensor status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Sensor Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET: @@ -341,7 +341,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } -const struct bt_mesh_model_op sensor_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_sensor_cli_op[] = { { BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS, 0, sensor_status }, { BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS, 2, sensor_status }, { BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS, 2, sensor_status }, @@ -360,7 +360,7 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common, msg = bt_mesh_alloc_buf(value_len); if (!msg) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -442,25 +442,19 @@ static int sensor_act_state(bt_mesh_client_common_param_t *common, break; } default: - BT_ERR("%s, Not a Sensor Client message opcode", __func__); + BT_ERR("Invalid Sensor client opcode 0x%04x", common->opcode); err = -EINVAL; goto end; } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg, - timeout_handler, common->msg_timeout, need_ack, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Sensor Client message (err %d)", __func__, err); - } + err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler); end: bt_mesh_free_buf(msg); - return err; } -int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get) { bt_mesh_sensor_client_t *client = NULL; u16_t length = 0U; @@ -472,7 +466,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void client = (bt_mesh_sensor_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Sensor Client user data is NULL", __func__); + BT_ERR("Invalid Sensor client data"); return -EINVAL; } @@ -496,7 +490,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void struct bt_mesh_sensor_column_get *value; value = (struct bt_mesh_sensor_column_get *)get; if (!value->raw_value_x) { - BT_ERR("%s, Sensor column_get is NULL", __func__); + BT_ERR("Invalid Sensor Column Get"); return -EINVAL; } length = (2 + 2 + value->raw_value_x->len + 4); @@ -507,7 +501,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_sensor_series_get *)get; if (value->op_en) { if (!value->raw_value_x1 || !value->raw_value_x2) { - BT_ERR("%s, Sensor series_get is NULL", __func__); + BT_ERR("Invalid Sensor Series Get"); return -EINVAL; } } @@ -518,14 +512,14 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void break; } default: - BT_ERR("%s, Not a Sensor Client Get message opcode", __func__); + BT_ERR("Invalid Sensor Get opcode 0x%04x", common->opcode); return -EINVAL; } return sensor_act_state(common, get, length, true); } -int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_sensor_client_t *client = NULL; u16_t length = 0U; @@ -538,7 +532,7 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void client = (bt_mesh_sensor_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Sensor Client user data is NULL", __func__); + BT_ERR("Invalid Sensor client data"); return -EINVAL; } @@ -550,7 +544,7 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void value = (struct bt_mesh_sensor_cadence_set *)set; if (!value->status_trigger_delta_down || !value->status_trigger_delta_up || !value->fast_cadence_low || !value->fast_cadence_high) { - BT_ERR("%s, Sensor cadence_set is NULL", __func__); + BT_ERR("Invalid Sensor Cadence Set"); return -EINVAL; } length = value->status_trigger_delta_down->len + \ @@ -566,42 +560,40 @@ int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void struct bt_mesh_sensor_setting_set *value; value = (struct bt_mesh_sensor_setting_set *)set; if (!value->sensor_setting_raw) { - BT_ERR("%s, Sensor setting_raw is NULL", __func__); + BT_ERR("Invalid Sensor Setting Raw value"); return -EINVAL; } length = (1 + 2 + 2 + value->sensor_setting_raw->len + 4); break; } default: - BT_ERR("%s, Not a Sensor Client Set message opcode", __func__); + BT_ERR("Invalid Sensor Set opcode 0x%04x", common->opcode); return -EINVAL; } return sensor_act_state(common, set, length, need_ack); } -int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary) +static int sensor_client_init(struct bt_mesh_model *model) { sensor_internal_data_t *internal = NULL; bt_mesh_sensor_client_t *client = NULL; - BT_DBG("primary %u", primary); - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Sensor client model"); return -EINVAL; } client = (bt_mesh_sensor_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Sensor Client user_data is NULL", __func__); + BT_ERR("No Sensor client context provided"); return -EINVAL; } if (!client->internal_data) { internal = bt_mesh_calloc(sizeof(sensor_internal_data_t)); if (!internal) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -620,18 +612,18 @@ int bt_mesh_sensor_cli_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary) +static int sensor_client_deinit(struct bt_mesh_model *model) { bt_mesh_sensor_client_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Sensor client model"); return -EINVAL; } client = (bt_mesh_sensor_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Sensor Client user_data is NULL", __func__); + BT_ERR("No Sensor client context provided"); return -EINVAL; } @@ -647,4 +639,9 @@ int bt_mesh_sensor_cli_deinit(struct bt_mesh_model *model, bool primary) bt_mesh_sensor_client_mutex_free(); return 0; -} \ No newline at end of file +} + +const struct bt_mesh_model_cb bt_mesh_sensor_client_cb = { + .init = sensor_client_init, + .deinit = sensor_client_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index 11162ae4f..d99a685fc 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -20,9 +20,9 @@ #include "model_opcode.h" #include "time_scene_client.h" -/** The following are the macro definitions of time and client - * scene model messages length, and a message is composed of - * three parts: Opcode + msg_value + MIC +/* The followings are the macro definitions of Time Scene client + * model message length, and a message is composed of 3 parts: + * Opcode + Payload + MIC */ /* Time client messages length */ #define BLE_MESH_TIME_SET_MSG_LEN (1 + 10 + 4) @@ -125,18 +125,18 @@ static void time_scene_status(struct bt_mesh_model *model, u8_t evt = 0xFF; size_t len = 0U; - BT_DBG("%s, len %d, bytes %s", __func__, buf->len, bt_hex(buf->data, buf->len)); + BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_TIME_STATUS: { struct bt_mesh_time_status *status = NULL; if (buf->len != 5 && buf->len != 10) { - BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len); + BT_ERR("Invalid Time Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_time_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } memcpy(status->tai_seconds, buf->data, 5); @@ -154,12 +154,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TIME_ZONE_STATUS: { struct bt_mesh_time_zone_status *status = NULL; if (buf->len != 7) { - BT_ERR("%s, Invalid Time Zone Status length %d", __func__, buf->len); + BT_ERR("Invalid Time Zone Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_time_zone_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->time_zone_offset_curr = net_buf_simple_pull_u8(buf); @@ -173,12 +173,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS: { struct bt_mesh_tai_utc_delta_status *status = NULL; if (buf->len != 9) { - BT_ERR("%s, Invalid TAI UTC Delta Status length %d", __func__, buf->len); + BT_ERR("Invalid TAI UTC Delta Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_tai_utc_delta_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } u16_t temp = net_buf_simple_pull_le16(buf); @@ -196,12 +196,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TIME_ROLE_STATUS: { struct bt_mesh_time_role_status *status = NULL; if (buf->len != 1) { - BT_ERR("%s, Invalid Time Role Status length %d", __func__, buf->len); + BT_ERR("Invalid Time Role Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_time_role_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->time_role = net_buf_simple_pull_u8(buf); @@ -212,12 +212,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SCENE_STATUS: { struct bt_mesh_scene_status *status = NULL; if (buf->len != 3 && buf->len != 6) { - BT_ERR("%s, Invalid Scene Status length %d", __func__, buf->len); + BT_ERR("Invalid Scene Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_scene_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); @@ -235,14 +235,14 @@ static void time_scene_status(struct bt_mesh_model *model, struct bt_mesh_scene_register_status *status = NULL; status = bt_mesh_calloc(sizeof(struct bt_mesh_scene_register_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->status_code = net_buf_simple_pull_u8(buf); status->current_scene = net_buf_simple_pull_le16(buf); status->scenes = bt_mesh_alloc_buf(buf->len); if (!status->scenes) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); bt_mesh_free(status); return; } @@ -254,12 +254,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SCHEDULER_STATUS: { struct bt_mesh_scheduler_status *status = NULL; if (buf->len != 2) { - BT_ERR("%s, Invalid Scheduler Status length %d", __func__, buf->len); + BT_ERR("Invalid Scheduler Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_scheduler_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } status->schedules = net_buf_simple_pull_le16(buf); @@ -270,12 +270,12 @@ static void time_scene_status(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS: { struct bt_mesh_scheduler_act_status *status = NULL; if (buf->len != 10) { - BT_ERR("%s, Invalid Scheduler Action Status length %d", __func__, buf->len); + BT_ERR("Invalid Scheduler Action Status length %d", buf->len); return; } status = bt_mesh_calloc(sizeof(struct bt_mesh_scheduler_act_status)); if (!status) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } memcpy(status, buf->data, offsetof(struct bt_mesh_scheduler_act_status, scene_number)); @@ -286,7 +286,7 @@ static void time_scene_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Not a Time Scene Status message opcode", __func__); + BT_ERR("Invalid Time Scene Status opcode 0x%04x", ctx->recv_op); return; } @@ -297,7 +297,7 @@ static void time_scene_status(struct bt_mesh_model *model, node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true); if (!node) { - BT_DBG("Unexpected time scene status message 0x%x", ctx->recv_op); + BT_DBG("Unexpected Time Scene Status 0x%04x", ctx->recv_op); } else { switch (node->opcode) { case BLE_MESH_MODEL_OP_TIME_GET: @@ -349,7 +349,7 @@ static void time_scene_status(struct bt_mesh_model *model, return; } -const struct bt_mesh_model_op time_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_time_cli_op[] = { { BLE_MESH_MODEL_OP_TIME_STATUS, 5, time_scene_status }, { BLE_MESH_MODEL_OP_TIME_ZONE_STATUS, 7, time_scene_status }, { BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS, 9, time_scene_status }, @@ -357,13 +357,13 @@ const struct bt_mesh_model_op time_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op scene_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_scene_cli_op[] = { { BLE_MESH_MODEL_OP_SCENE_STATUS, 3, time_scene_status }, { BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS, 3, time_scene_status }, BLE_MESH_MODEL_OP_END, }; -const struct bt_mesh_model_op scheduler_cli_op[] = { +const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[] = { { BLE_MESH_MODEL_OP_SCHEDULER_STATUS, 2, time_scene_status }, { BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS, 10, time_scene_status }, BLE_MESH_MODEL_OP_END, @@ -372,7 +372,6 @@ const struct bt_mesh_model_op scheduler_cli_op[] = { static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *value) { NET_BUF_SIMPLE_DEFINE(msg, BLE_MESH_SCENE_GET_STATE_MSG_LEN); - int err = 0; bt_mesh_model_msg_init(&msg, common->opcode); @@ -385,19 +384,12 @@ static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *val break; } default: - BT_DBG("This time scene message should be sent with NULL get pointer"); + BT_DBG("No parameters for Time Scene Get 0x%04x", common->opcode); break; } } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, &msg, - timeout_handler, common->msg_timeout, true, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Time Scene Get message (err %d)", __func__, err); - } - - return err; + return bt_mesh_client_send_msg(common, &msg, true, timeout_handler); } static int time_scene_set_state(bt_mesh_client_common_param_t *common, @@ -408,7 +400,7 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common, msg = bt_mesh_alloc_buf(value_len); if (!msg) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -480,24 +472,19 @@ static int time_scene_set_state(bt_mesh_client_common_param_t *common, break; } default: - BT_ERR("%s, Not a Time Scene Client set message opcode", __func__); + BT_ERR("Invalid Time Scene Set opcode 0x%04x", common->opcode); err = -EINVAL; goto end; } - err = bt_mesh_client_send_msg(common->model, common->opcode, &common->ctx, msg, - timeout_handler, common->msg_timeout, need_ack, - common->cb, common->cb_data); - if (err) { - BT_ERR("%s, Failed to send Time Scene Set message (err %d)", __func__, err); - } + err = bt_mesh_client_send_msg(common, msg, need_ack, timeout_handler); end: bt_mesh_free_buf(msg); return err; } -int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get, void *status) +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get) { bt_mesh_time_scene_client_t *client = NULL; @@ -508,7 +495,7 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v client = (bt_mesh_time_scene_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Time Scene Client user data is NULL", __func__); + BT_ERR("Invalid Time Scene client data"); return -EINVAL; } @@ -523,19 +510,19 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v break; case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET: if (!get) { - BT_ERR("%s, Scheduler action index is NULL", __func__); + BT_ERR("Invalid Scheduler Action Get"); return -EINVAL; } break; default: - BT_ERR("%s, Not a Time Scene Client Get message opcode", __func__); + BT_ERR("Invalid Time Scene Get opcode 0x%04x", common->opcode); return -EINVAL; } return time_scene_get_state(common, get); } -int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set, void *status) +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_time_scene_client_t *client = NULL; u16_t length = 0U; @@ -548,7 +535,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v client = (bt_mesh_time_scene_client_t *)common->model->user_data; if (!client || !client->internal_data) { - BT_ERR("%s, Time Scene Client user data is NULL", __func__); + BT_ERR("Invalid Time Scene client data"); return -EINVAL; } @@ -565,7 +552,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v struct bt_mesh_tai_utc_delta_set *value; value = (struct bt_mesh_tai_utc_delta_set *)set; if (value->padding) { - BT_ERR("%s, Non-zero padding value is prohibited", __func__); + BT_ERR("Non-zero padding value is prohibited"); return -EINVAL; } need_ack = true; @@ -576,7 +563,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v struct bt_mesh_time_role_set *value; value = (struct bt_mesh_time_role_set *)set; if (value->time_role > 0x03) { - BT_ERR("%s, Time role value is prohibited", __func__); + BT_ERR("Time role 0x%02x is prohibited", value->time_role); return -EINVAL; } need_ack = true; @@ -589,7 +576,7 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v struct bt_mesh_scene_store *value; value = (struct bt_mesh_scene_store *)set; if (!value->scene_number) { - BT_ERR("%s, Scene store scene_number 0x0000 is prohibited", __func__); + BT_ERR("Scene Store scene number 0x0000 is prohibited"); return -EINVAL; } length = BLE_MESH_SCENE_STORE_MSG_LEN; @@ -601,12 +588,12 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v struct bt_mesh_scene_recall *value; value = (struct bt_mesh_scene_recall *)set; if (!value->scene_number) { - BT_ERR("%s, Scene recall scene_number 0x0000 is prohibited", __func__); + BT_ERR("Scene Recall scene number 0x0000 is prohibited"); return -EINVAL; } if (value->op_en) { if ((value->trans_time & 0x3F) > 0x3E) { - BT_ERR("%s, Invalid Scene Recall transition time", __func__); + BT_ERR("Invalid Scene Recall transition time"); return -EINVAL; } } @@ -625,46 +612,44 @@ int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, v struct bt_mesh_scheduler_act_set *value; value = (struct bt_mesh_scheduler_act_set *)set; if (value->year > 0x64) { - BT_ERR("%s, Scheduler register year value is prohibited", __func__); + BT_ERR("Scheduler Register year 0x%02x is prohibited", value->year); return -EINVAL; } if (value->hour > 0x19) { - BT_ERR("%s, Scheduler register hour value is prohibited", __func__); + BT_ERR("Scheduler Register hour 0x%02x is prohibited", value->hour); return -EINVAL; } length = BLE_MESH_SCHEDULER_ACT_SET_MSG_LEN; break; } default: - BT_ERR("%s, Not a Time Scene Set message opcode", __func__); + BT_ERR("Invalid Time Scene Set opcode 0x%04x", common->opcode); return -EINVAL; } return time_scene_set_state(common, set, length, need_ack); } -static int time_scene_client_init(struct bt_mesh_model *model, bool primary) +static int time_scene_client_init(struct bt_mesh_model *model) { time_scene_internal_data_t *internal = NULL; bt_mesh_time_scene_client_t *client = NULL; - BT_DBG("primary %u", primary); - if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Time Scene client model"); return -EINVAL; } client = (bt_mesh_time_scene_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Time Scene Client user_data is NULL", __func__); + BT_ERR("No Time Scene client context provided"); return -EINVAL; } if (!client->internal_data) { internal = bt_mesh_calloc(sizeof(time_scene_internal_data_t)); if (!internal) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return -ENOMEM; } @@ -683,33 +668,18 @@ static int time_scene_client_init(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_time_cli_init(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_init(model, primary); -} - -int bt_mesh_scene_cli_init(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_init(model, primary); -} - -int bt_mesh_scheduler_cli_init(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_init(model, primary); -} - -static int time_scene_client_deinit(struct bt_mesh_model *model, bool primary) +static int time_scene_client_deinit(struct bt_mesh_model *model) { bt_mesh_time_scene_client_t *client = NULL; if (!model) { - BT_ERR("%s, Invalid parameter", __func__); + BT_ERR("Invalid Time Scene client model"); return -EINVAL; } client = (bt_mesh_time_scene_client_t *)model->user_data; if (!client) { - BT_ERR("%s, Time Scene Client user_data is NULL", __func__); + BT_ERR("No Time Scene client context provided"); return -EINVAL; } @@ -727,17 +697,7 @@ static int time_scene_client_deinit(struct bt_mesh_model *model, bool primary) return 0; } -int bt_mesh_time_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_deinit(model, primary); -} - -int bt_mesh_scene_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_deinit(model, primary); -} - -int bt_mesh_scheduler_cli_deinit(struct bt_mesh_model *model, bool primary) -{ - return time_scene_client_deinit(model, primary); -} \ No newline at end of file +const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb = { + .init = time_scene_client_init, + .deinit = time_scene_client_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/device_property.c b/components/bt/esp_ble_mesh/mesh_models/common/device_property.c similarity index 60% rename from components/bt/esp_ble_mesh/mesh_models/server/device_property.c rename to components/bt/esp_ble_mesh/mesh_models/common/device_property.c index 5ef9d3968..9031c00df 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/device_property.c +++ b/components/bt/esp_ble_mesh/mesh_models/common/device_property.c @@ -19,8 +19,8 @@ static struct bt_mesh_dev_prop { u16_t prop_id; u8_t len; -} device_properties [] = { - { BLE_MESH_INVALID_DEVICE_PROPERTY_ID, 0xFF }, +} device_properties[] = { + { BLE_MESH_INVALID_DEVICE_PROPERTY_ID, 0xFF }, /* Prohibited */ { BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY, 0x03 }, { BLE_MESH_AVERAGE_INPUT_CURRENT, 0x03 }, { BLE_MESH_AVERAGE_INPUT_VOLTAGE, 0x03 }, @@ -32,20 +32,20 @@ static struct bt_mesh_dev_prop { { BLE_MESH_COLOR_RENDERING_INDEX_RA, 0x01 }, { BLE_MESH_DEVICE_APPEARANCE, 0x02 }, { BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN, 0x02 }, - { BLE_MESH_DEVICE_DATE_OF_MANUFACTURE, 0x04 }, - { BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON, 0x04 }, + { BLE_MESH_DEVICE_DATE_OF_MANUFACTURE, 0x03 }, + { BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON, 0x03 }, { BLE_MESH_DEVICE_FIRMWARE_REVISION, 0x08 }, - { BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER, 0x08 }, - { BLE_MESH_DEVICE_HARDWARE_REVISION, 0x16 }, - { BLE_MESH_DEVICE_MANUFACTURER_NAME, 0x36 }, - { BLE_MESH_DEVICE_MODEL_NUMBER, 0x24 }, + { BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER, 0x06 }, + { BLE_MESH_DEVICE_HARDWARE_REVISION, 0x10 }, + { BLE_MESH_DEVICE_MANUFACTURER_NAME, 0x24 }, + { BLE_MESH_DEVICE_MODEL_NUMBER, 0x18 }, { BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION, 0x04 }, { BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES, 0x09 }, { BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS, 0x06 }, - { BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION, 0x12 }, - { BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON, 0x04 }, - { BLE_MESH_DEVICE_RUNTIME_WARRANTY, 0x04 }, - { BLE_MESH_DEVICE_SERIAL_NUMBER, 0x16 }, + { BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION, 0x09 }, + { BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON, 0x03 }, + { BLE_MESH_DEVICE_RUNTIME_WARRANTY, 0x03 }, + { BLE_MESH_DEVICE_SERIAL_NUMBER, 0x10 }, { BLE_MESH_DEVICE_SOFTWARE_REVISION, 0x08 }, { BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS, 0x06 }, { BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES, 0x05 }, @@ -63,9 +63,9 @@ static struct bt_mesh_dev_prop { { BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION, 0x06 }, { BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION, 0x01 }, { BLE_MESH_INPUT_VOLTAGE_STATISTICS, 0x09 }, - { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON, 0x04 }, - { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG, 0x04 }, - { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY, 0x04 }, + { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON, 0x03 }, + { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG, 0x03 }, + { BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY, 0x03 }, { BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON, 0x02 }, { BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG, 0x02 }, { BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY, 0x02 }, @@ -83,8 +83,8 @@ static struct bt_mesh_dev_prop { { BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON, 0x03 }, { BLE_MESH_LUMEN_MAINTENANCE_FACTOR, 0x01 }, { BLE_MESH_LUMINOUS_EFFICACY, 0x02 }, - { BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON, 0x04 }, - { BLE_MESH_LUMINOUS_EXPOSURE, 0x04 }, + { BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON, 0x03 }, + { BLE_MESH_LUMINOUS_EXPOSURE, 0x03 }, { BLE_MESH_LUMINOUS_FLUX_RANGE, 0x04 }, { BLE_MESH_MOTION_SENSED, 0x01 }, { BLE_MESH_MOTION_THRESHOLD, 0x01 }, @@ -98,14 +98,14 @@ static struct bt_mesh_dev_prop { { BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS, 0x06 }, { BLE_MESH_PEOPLE_COUNT, 0x02 }, { BLE_MESH_PRESENCE_DETECTED, 0x01 }, - { BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL, 0x04 }, + { BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL, 0x03 }, { BLE_MESH_PRESENT_AMBIENT_TEMPERATURE, 0x01 }, { BLE_MESH_PRESENT_CIE_1931_CHROMATICITY, 0x04 }, { BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE, 0x02 }, - { BLE_MESH_PRESENT_DEVICE_INPUT_POWER, 0x04 }, + { BLE_MESH_PRESENT_DEVICE_INPUT_POWER, 0x03 }, { BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY, 0x01 }, { BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE, 0x02 }, - { BLE_MESH_PRESENT_ILLUMINANCE, 0x04 }, + { BLE_MESH_PRESENT_ILLUMINANCE, 0x03 }, { BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE, 0x01 }, { BLE_MESH_PRESENT_INPUT_CURRENT, 0x02 }, { BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE, 0x01 }, @@ -116,29 +116,100 @@ static struct bt_mesh_dev_prop { { BLE_MESH_PRESENT_OUTPUT_VOLTAGE, 0x02 }, { BLE_MESH_PRESENT_PLANCKIAN_DISTANCE, 0x02 }, { BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE, 0x01 }, - { BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY, 0x06 }, + { BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY, 0x05 }, { BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE, 0x05 }, - { BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE, 0x09 }, - { BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE, 0x04 }, - { BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE, 0x05 }, + { BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE, 0x05 }, + { BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE, 0x03 }, + { BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE, 0x03 }, { BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE, 0x05 }, { BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE, 0x05 }, { BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS, 0x06 }, { BLE_MESH_TIME_SINCE_MOTION_SENSED, 0x02 }, { BLE_MESH_TIME_SINCE_PRESENCE_DETECTED, 0x02 }, - { BLE_MESH_TOTAL_DEVICE_ENERGY_USE, 0x04 }, - { BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES, 0x04 }, - { BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES, 0x04 }, - { BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME, 0x04 }, - { BLE_MESH_TOTAL_DEVICE_RUNTIME, 0x04 }, - { BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME, 0x04 }, - { BLE_MESH_TOTAL_LUMINOUS_ENERGY, 0x04 }, + { BLE_MESH_TOTAL_DEVICE_ENERGY_USE, 0x03 }, + { BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES, 0x03 }, + { BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES, 0x03 }, + { BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME, 0x03 }, + { BLE_MESH_TOTAL_DEVICE_RUNTIME, 0x03 }, + { BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME, 0x03 }, + { BLE_MESH_TOTAL_LUMINOUS_ENERGY, 0x03 }, + { BLE_MESH_DESIRED_AMBIENT_TEMPERATURE, 0x01 }, + { BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE, 0x04 }, + { BLE_MESH_POWER_FACTOR, 0x01 }, + { BLE_MESH_SENSOR_GAIN, 0x04 }, + { BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE, 0x02 }, + { BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY, 0x02 }, + { BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION, 0x02 }, + { BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION, 0x02 }, + { BLE_MESH_PRESENT_AMBIENT_NOISE, 0x01 }, + { 0x007A, 0xFF }, /* Not defined */ + { 0x007B, 0xFF }, /* Not defined */ + { 0x007C, 0xFF }, /* Not defined */ + { 0x007D, 0xFF }, /* Not defined */ + { 0x007E, 0xFF }, /* Not defined */ + { 0x007F, 0xFF }, /* Not defined */ + { BLE_MESH_ACTIVE_ENERGY_LOADSIDE, 0x04 }, + { BLE_MESH_ACTIVE_POWER_LOADSIDE, 0x03 }, + { BLE_MESH_AIR_PRESSURE, 0x04 }, + { BLE_MESH_APPARENT_ENERGY, 0x04 }, + { BLE_MESH_APPARENT_POWER, 0x03 }, + { BLE_MESH_APPARENT_WIND_DIRECTION, 0x02 }, + { BLE_MESH_APPARENT_WIND_SPEED, 0x02 }, + { BLE_MESH_DEW_POINT, 0x01 }, + { BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE, 0x03 }, + { BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY, 0x02 }, + { BLE_MESH_GUST_FACTOR, 0x01 }, + { BLE_MESH_HEAT_INDEX, 0x01 }, + { BLE_MESH_LIGHT_DISTRIBUTION, 0x01 }, + { BLE_MESH_LIGHT_SOURCE_CURRENT, 0x03 }, + { BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE, 0x04 }, + { BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE, 0x04 }, + { BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS, 0x06 }, + { BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS, 0x06 }, + { BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS, 0x06 }, + { BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE, 0x03 }, + { BLE_MESH_LIGHT_SOURCE_TEMPERATURE, 0x02 }, + { BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS, 0x06 }, + { BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS, 0x06 }, + { BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES, 0x03 }, + { BLE_MESH_LIGHT_SOURCE_VOLTAGE, 0x03 }, + { BLE_MESH_LUMINAIRE_COLOR, 0x18 }, + { BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER, 0x18 }, + { BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN, 0x06 }, + { BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER, 0x03 }, + { BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE, 0x02 }, + { BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE, 0x02 }, + { BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL, 0x03 }, + { BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE, 0x03 }, + { BLE_MESH_MAGNETIC_DECLINATION, 0x02 }, + { BLE_MESH_MAGNETIC_FLUX_DENSITY_2D, 0x04 }, + { BLE_MESH_MAGNETIC_FLUX_DENSITY_3D, 0x06 }, + { BLE_MESH_NOMINAL_LIGHT_OUTPUT, 0x03 }, + { BLE_MESH_OVERALL_FAILURE_CONDITION, 0x06 }, + { BLE_MESH_POLLEN_CONCENTRATION, 0x03 }, + { BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY, 0x02 }, + { BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY, 0x02 }, + { BLE_MESH_PRESSURE, 0x04 }, + { BLE_MESH_RAINFALL, 0x02 }, + { BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE, 0x03 }, + { BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS, 0x03 }, + { BLE_MESH_REFERENCE_TEMPERATURE, 0x02 }, + { BLE_MESH_TOTAL_DEVICE_STARTS, 0x03 }, + { BLE_MESH_TRUE_WIND_DIRECTION, 0x02 }, + { BLE_MESH_TRUE_WIND_SPEED, 0x02 }, + { BLE_MESH_UV_INDEX, 0x01 }, + { BLE_MESH_WIND_CHILL, 0x01 }, + { BLE_MESH_LIGHT_SOURCE_TYPE, 0x01 }, + { BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING, 0x40 }, + { BLE_MESH_OUTPUT_POWER_LIMITATION, 0x06 }, + { BLE_MESH_THERMAL_DERATING, 0x06 }, + { BLE_MESH_OUTPUT_CURRENT_PERCENT, 0x01 }, }; u8_t bt_mesh_get_dev_prop_len(u16_t prop_id) { - if (prop_id > BLE_MESH_TOTAL_LUMINOUS_ENERGY) { - BT_ERR("%s, Unknown Device Property ID 0x%04x", __func__, prop_id); + if (prop_id > BLE_MESH_OUTPUT_CURRENT_PERCENT) { + BT_ERR("Unknown Device Property ID 0x%04x", prop_id); return UINT8_MAX; } diff --git a/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h b/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h new file mode 100644 index 000000000..9236032f5 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h @@ -0,0 +1,1358 @@ +// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _DEVICE_PROPERTY_H_ +#define _DEVICE_PROPERTY_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Details of BLE Mesh Device Properties. + * Note: For the size of the corresponding characteristic, please refer to the GATT_Specification_Supplement_v2. + * + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Property Name | ID | Characteristic | Size | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Ambient Temperature In A Period Of Day | 0x0001 | Temperature 8 In A Period Of Day | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Current | 0x0002 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Voltage | 0x0003 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Current | 0x0004 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Voltage | 0x0005 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Center Beam Intensity At Full Power | 0x0006 | Luminous Intensity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Chromaticity Tolerance | 0x0007 | Chromaticity Tolerance | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index R9 | 0x0008 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index Ra | 0x0009 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Appearance | 0x000A | Gap.Appearance | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Country Of Origin | 0x000B | Country Code | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Date Of Manufacture | 0x000C | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Energy Use Since Turn On | 0x000D | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Firmware Revision | 0x000E | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Global Trade Item Number | 0x000F | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Hardware Revision | 0x0010 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Manufacturer Name | 0x0011 | Fixed String 36 | 36 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Model Number | 0x0012 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Range Specification | 0x0013 | Temperature Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Statistical Values | 0x0014 | Temperature Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Over Temperature Event Statistics | 0x0015 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Power Range Specification | 0x0016 | Power Specification | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Since Turn On | 0x0017 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Warranty | 0x0018 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Serial Number | 0x0019 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Software Revision | 0x001A | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Under Temperature Event Statistics | 0x001B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Indoor Ambient Temperature Statistical Values | 0x001C | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial CIE 1931 Chromaticity Coordinates | 0x001D | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Correlated Color Temperature | 0x001E | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Luminous Flux | 0x001F | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Planckian Distance | 0x0020 | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Range Specification | 0x0021 | Electric Current Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Statistics | 0x0022 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Current Event Statistics | 0x0023 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Ripple Voltage Event Statistics | 0x0024 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Voltage Event Statistics | 0x0025 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Current Event Statistics | 0x0026 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Voltage Event Statistics | 0x0027 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Range Specification | 0x0028 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Ripple Specification | 0x0029 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Statistics | 0x002A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel On | 0x002B | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Prolong | 0x002C | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Standby | 0x002D | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness On | 0x002E | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Prolong | 0x002F | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Standby | 0x0030 | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Accuracy | 0x0031 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kid | 0x0032 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kiu | 0x0033 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpd | 0x0034 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpu | 0x0035 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade | 0x0036 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade On | 0x0037 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Auto | 0x0038 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Manual | 0x0039 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Occupancy Delay | 0x003A | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Prolong | 0x003B | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Run On | 0x003C | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Lumen Maintenance Factor | 0x003D | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Efficacy | 0x003E | Luminous Efficacy | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Energy Since Turn On | 0x003F | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Exposure | 0x0040 | Luminous Exposure | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Flux Range | 0x0041 | Luminous Flux Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Sensed | 0x0042 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Threshold | 0x0043 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Open Circuit Event Statistics | 0x0044 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Outdoor Statistical Values | 0x0045 | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Range | 0x0046 | Electric Current Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Statistics | 0x0047 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Ripple Voltage Specification | 0x0048 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Range | 0x0049 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Statistics | 0x004A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Over Output Ripple Voltage Event Statistics | 0x004B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | People Count | 0x004C | Count 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Presence Detected | 0x004D | Boolean | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Light Level | 0x004E | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Temperature | 0x004F | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present CIE 1931 Chromaticity Coordinates | 0x0050 | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Correlated Color Temperature | 0x0051 | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Input Power | 0x0052 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Efficiency | 0x0053 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Temperature | 0x0054 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Illuminance | 0x0055 | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Ambient Temperature | 0x0056 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Current | 0x0057 | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Ripple Voltage | 0x0058 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Voltage | 0x0059 | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Luminous Flux | 0x005A | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Ambient Temperature | 0x005B | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Current | 0x005C | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Voltage | 0x005D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Planckian Distance | 0x005E | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Relative Output Ripple Voltage | 0x005F | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Energy Use In A Period Of Day | 0x0060 | Energy In A Period Of Day | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Runtime In A Generic Level Range | 0x0061 | Relative Runtime In A Generic Level Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Exposure Time In An Illuminance Range | 0x0062 | Relative Value In An Illuminance Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Correlated Color Temperature Range | 0x0063 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Device Operating Temperature Range | 0x0064 | Relative Value In A Temperature Range | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Current Range | 0x0065 | Relative Runtime In A Current Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Voltage Range | 0x0066 | Relative Value In A Voltage Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Short Circuit Event Statistics | 0x0067 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Motion Sensed | 0x0068 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Presence Detected | 0x0069 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Energy Use | 0x006A | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Off On Cycles | 0x006B | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Cycles | 0x006C | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Time | 0x006D | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Runtime | 0x006E | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Light Exposure Time | 0x006F | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Luminous Energy | 0x0070 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Desired Ambient Temperature | 0x0071 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Total Device Energy Use | 0x0072 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Power Factor | 0x0073 | Cosine Of The Angle | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Sensor Gain | 0x0074 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Present Ambient Temperature | 0x0075 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Relative Humidity | 0x0076 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Carbon Dioxide Concentration | 0x0077 | CO2 Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Volatile Organic Compounds Concentration | 0x0078 | VOC Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Noise | 0x0079 | Noise | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Energy Loadside | 0x0080 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Power Loadside | 0x0081 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Air Pressure | 0x0082 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Energy | 0x0083 | Apparent Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Power | 0x0084 | Apparent Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Direction | 0x0085 | Apparent Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Speed | 0x0086 | Apparent Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Dew Point | 0x0087 | Dew Point | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage | 0x0088 | High Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage Frequency | 0x0089 | Voltage Frequency | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Gust Factor | 0x008A | Gust Factor | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Heat Index | 0x008B | Heat Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Distribution | 0x008C | Light Distribution | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Current | 0x008D | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Not Resettable | 0x008E | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Resettable | 0x008F | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Open Circuit Statistics | 0x0090 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Overall Failures Statistics | 0x0091 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Short Circuit Statistics | 0x0092 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Start Counter Resettable | 0x0093 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Temperature | 0x0094 | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Derating Statistics | 0x0095 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Shutdown Statistics | 0x0096 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Total Power On Cycles | 0x0097 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Voltage | 0x0098 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Color | 0x0099 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification Number | 0x009A | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Manufacturer GTIN | 0x009B | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Input Power | 0x009C | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Maximum AC Mains Voltage | 0x009D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Minimum AC Mains Voltage | 0x009E | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Power At Minimum Dim Level | 0x009F | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Time Of Manufacture | 0x00A0 | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Declination | 0x00A1 | Magnetic Declination | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 2D | 0x00A2 | Magnetic Flux Density - 2D | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 3D | 0x00A3 | Magnetic Flux Density - 3D | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Nominal Light Output | 0x00A4 | Light Output | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Overall Failure Condition | 0x00A5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pollen Concentration | 0x00A6 | Pollen Concentration | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Relative Humidity | 0x00A7 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Relative Humidity | 0x00A8 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pressure | 0x00A9 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rainfall | 0x00AA | Rainfall | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Life Of Luminaire | 0x00AB | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Light Source Starts | 0x00AC | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Reference Temperature | 0x00AD | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Starts | 0x00AE | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Direction | 0x00AF | True Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Speed | 0x00B0 | True Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | UV Index | 0x00B1 | UV Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Wind Chill | 0x00B2 | Wind Chill | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Type | 0x00B3 | Light Source Type | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification String | 0x00B4 | Fixed String 64 | 64 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Power Limitation | 0x00B5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Thermal Derating | 0x00B6 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Percent | 0x00B7 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + */ + +/** + * @brief BLE Mesh Device Property IDs + */ +#define BLE_MESH_INVALID_DEVICE_PROPERTY_ID 0x0000 +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY 0x0001 +#define BLE_MESH_AVERAGE_INPUT_CURRENT 0x0002 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE 0x0003 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT 0x0004 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE 0x0005 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER 0x0006 +#define BLE_MESH_CHROMATICITY_TOLERANCE 0x0007 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9 0x0008 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA 0x0009 +#define BLE_MESH_DEVICE_APPEARANCE 0x000A +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN 0x000B +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE 0x000C +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON 0x000D +#define BLE_MESH_DEVICE_FIRMWARE_REVISION 0x000E +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER 0x000F +#define BLE_MESH_DEVICE_HARDWARE_REVISION 0x0010 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME 0x0011 +#define BLE_MESH_DEVICE_MODEL_NUMBER 0x0012 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION 0x0013 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES 0x0014 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS 0x0015 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION 0x0016 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON 0x0017 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY 0x0018 +#define BLE_MESH_DEVICE_SERIAL_NUMBER 0x0019 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION 0x001A +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS 0x001B +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES 0x001C +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES 0x001D +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE 0x001E +#define BLE_MESH_INITIAL_LUMINOUS_FLUX 0x001F +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE 0x0020 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION 0x0021 +#define BLE_MESH_INPUT_CURRENT_STATISTICS 0x0022 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS 0x0023 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x0024 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS 0x0025 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS 0x0026 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS 0x0027 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION 0x0028 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION 0x0029 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS 0x002A +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON 0x002B +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG 0x002C +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY 0x002D +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON 0x002E +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG 0x002F +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY 0x0030 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY 0x0031 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID 0x0032 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU 0x0033 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD 0x0034 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU 0x0035 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE 0x0036 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON 0x0037 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO 0x0038 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL 0x0039 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY 0x003A +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG 0x003B +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON 0x003C +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR 0x003D +#define BLE_MESH_LUMINOUS_EFFICACY 0x003E +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON 0x003F +#define BLE_MESH_LUMINOUS_EXPOSURE 0x0040 +#define BLE_MESH_LUMINOUS_FLUX_RANGE 0x0041 +#define BLE_MESH_MOTION_SENSED 0x0042 +#define BLE_MESH_MOTION_THRESHOLD 0x0043 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS 0x0044 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES 0x0045 +#define BLE_MESH_OUTPUT_CURRENT_RANGE 0x0046 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS 0x0047 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION 0x0048 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE 0x0049 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS 0x004A +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x004B +#define BLE_MESH_PEOPLE_COUNT 0x004C +#define BLE_MESH_PRESENCE_DETECTED 0x004D +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL 0x004E +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE 0x004F +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY 0x0050 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE 0x0051 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER 0x0052 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY 0x0053 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE 0x0054 +#define BLE_MESH_PRESENT_ILLUMINANCE 0x0055 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE 0x0056 +#define BLE_MESH_PRESENT_INPUT_CURRENT 0x0057 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE 0x0058 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE 0x0059 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX 0x005A +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE 0x005B +#define BLE_MESH_PRESENT_OUTPUT_CURRENT 0x005C +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE 0x005D +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE 0x005E +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE 0x005F +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY 0x0060 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE 0x0061 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE 0x0062 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE 0x0063 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE 0x0064 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE 0x0065 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE 0x0066 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS 0x0067 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED 0x0068 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED 0x0069 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE 0x006A +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES 0x006B +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES 0x006C +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME 0x006D +#define BLE_MESH_TOTAL_DEVICE_RUNTIME 0x006E +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME 0x006F +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY 0x0070 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE 0x0071 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE 0x0072 +#define BLE_MESH_POWER_FACTOR 0x0073 +#define BLE_MESH_SENSOR_GAIN 0x0074 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE 0x0075 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY 0x0076 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION 0x0077 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION 0x0078 +#define BLE_MESH_PRESENT_AMBIENT_NOISE 0x0079 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE 0x0080 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE 0x0081 +#define BLE_MESH_AIR_PRESSURE 0x0082 +#define BLE_MESH_APPARENT_ENERGY 0x0083 +#define BLE_MESH_APPARENT_POWER 0x0084 +#define BLE_MESH_APPARENT_WIND_DIRECTION 0x0085 +#define BLE_MESH_APPARENT_WIND_SPEED 0x0086 +#define BLE_MESH_DEW_POINT 0x0087 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE 0x0088 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY 0x0089 +#define BLE_MESH_GUST_FACTOR 0x008A +#define BLE_MESH_HEAT_INDEX 0x008B +#define BLE_MESH_LIGHT_DISTRIBUTION 0x008C +#define BLE_MESH_LIGHT_SOURCE_CURRENT 0x008D +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE 0x008E +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE 0x008F +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS 0x0090 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS 0x0091 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS 0x0092 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE 0x0093 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE 0x0094 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS 0x0095 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS 0x0096 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES 0x0097 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE 0x0098 +#define BLE_MESH_LUMINAIRE_COLOR 0x0099 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER 0x009A +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN 0x009B +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER 0x009C +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE 0x009D +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE 0x009E +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL 0x009F +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE 0x00A0 +#define BLE_MESH_MAGNETIC_DECLINATION 0x00A1 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D 0x00A2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D 0x00A3 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT 0x00A4 +#define BLE_MESH_OVERALL_FAILURE_CONDITION 0x00A5 +#define BLE_MESH_POLLEN_CONCENTRATION 0x00A6 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY 0x00A7 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY 0x00A8 +#define BLE_MESH_PRESSURE 0x00A9 +#define BLE_MESH_RAINFALL 0x00AA +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE 0x00AB +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS 0x00AC +#define BLE_MESH_REFERENCE_TEMPERATURE 0x00AD +#define BLE_MESH_TOTAL_DEVICE_STARTS 0x00AE +#define BLE_MESH_TRUE_WIND_DIRECTION 0x00AF +#define BLE_MESH_TRUE_WIND_SPEED 0x00B0 +#define BLE_MESH_UV_INDEX 0x00B1 +#define BLE_MESH_WIND_CHILL 0x00B2 +#define BLE_MESH_LIGHT_SOURCE_TYPE 0x00B3 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING 0x00B4 +#define BLE_MESH_OUTPUT_POWER_LIMITATION 0x00B5 +#define BLE_MESH_THERMAL_DERATING 0x00B6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT 0x00B7 + +/** + * @brief BLE Mesh Device Property value length + */ +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE_LEN 3 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER_LEN 2 +#define BLE_MESH_CHROMATICITY_TOLERANCE_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA_LEN 1 +#define BLE_MESH_DEVICE_APPEARANCE_LEN 2 +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN_LEN 2 +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_FIRMWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER_LEN 6 +#define BLE_MESH_DEVICE_HARDWARE_REVISION_LEN 16 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME_LEN 36 +#define BLE_MESH_DEVICE_MODEL_NUMBER_LEN 24 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION_LEN 4 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES_LEN 9 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION_LEN 9 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY_LEN 3 +#define BLE_MESH_DEVICE_SERIAL_NUMBER_LEN 16 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES_LEN 4 +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_INITIAL_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION_LEN 1 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY_LEN 1 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON_LEN 3 +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR_LEN 1 +#define BLE_MESH_LUMINOUS_EFFICACY_LEN 2 +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_LUMINOUS_EXPOSURE_LEN 3 +#define BLE_MESH_LUMINOUS_FLUX_RANGE_LEN 4 +#define BLE_MESH_MOTION_SENSED_LEN 1 +#define BLE_MESH_MOTION_THRESHOLD_LEN 1 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_OUTPUT_CURRENT_RANGE_LEN 4 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION_LEN 1 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE_LEN 6 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_PEOPLE_COUNT_LEN 2 +#define BLE_MESH_PRESENCE_DETECTED_LEN 1 +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL_LEN 3 +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY_LEN 4 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER_LEN 3 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY_LEN 1 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_ILLUMINANCE_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_OUTPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY_LEN 5 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE_LEN 5 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED_LEN 2 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_RUNTIME_LEN 3 +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME_LEN 3 +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY_LEN 3 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE_LEN 4 +#define BLE_MESH_POWER_FACTOR_LEN 1 +#define BLE_MESH_SENSOR_GAIN_LEN 4 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_NOISE_LEN 1 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE_LEN 4 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE_LEN 3 +#define BLE_MESH_AIR_PRESSURE_LEN 4 +#define BLE_MESH_APPARENT_ENERGY_LEN 4 +#define BLE_MESH_APPARENT_POWER_LEN 3 +#define BLE_MESH_APPARENT_WIND_DIRECTION_LEN 2 +#define BLE_MESH_APPARENT_WIND_SPEED_LEN 2 +#define BLE_MESH_DEW_POINT_LEN 1 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_LEN 3 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY_LEN 2 +#define BLE_MESH_GUST_FACTOR_LEN 1 +#define BLE_MESH_HEAT_INDEX_LEN 1 +#define BLE_MESH_LIGHT_DISTRIBUTION_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_CURRENT_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE_LEN 2 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE_LEN 3 +#define BLE_MESH_LUMINAIRE_COLOR_LEN 24 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER_LEN 24 +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN_LEN 6 +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER_LEN 3 +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL_LEN 3 +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_MAGNETIC_DECLINATION_LEN 2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D_LEN 4 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D_LEN 6 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT_LEN 3 +#define BLE_MESH_OVERALL_FAILURE_CONDITION_LEN 6 +#define BLE_MESH_POLLEN_CONCENTRATION_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESSURE_LEN 4 +#define BLE_MESH_RAINFALL_LEN 2 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE_LEN 3 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS_LEN 3 +#define BLE_MESH_REFERENCE_TEMPERATURE_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_STARTS_LEN 3 +#define BLE_MESH_TRUE_WIND_DIRECTION_LEN 2 +#define BLE_MESH_TRUE_WIND_SPEED_LEN 2 +#define BLE_MESH_UV_INDEX_LEN 1 +#define BLE_MESH_WIND_CHILL_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_TYPE_LEN 1 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING_LEN 64 +#define BLE_MESH_OUTPUT_POWER_LIMITATION_LEN 6 +#define BLE_MESH_THERMAL_DERATING_LEN 6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT_LEN 1 + +/** + * @brief BLE Mesh Device Property referenced Characteristic UUIDs + */ +#define BLE_MESH_UUID_AVERAGE_CURRENT_VAL 0x2AE0 +#define BLE_MESH_UUID_AVERAGE_VOLTAGE_VAL 0x2AE1 +#define BLE_MESH_UUID_BOOLEAN_VAL 0x2AE2 +#define BLE_MESH_UUID_CHROMATIC_DISTANCE_FROM_PLANCKIAN_VAL 0x2AE3 +#define BLE_MESH_UUID_CHROMATICITY_COORDINATE_VAL 0x2B1C +#define BLE_MESH_UUID_CHROMATICITY_COORDINATES_VAL 0x2AE4 +#define BLE_MESH_UUID_CHROMATICITY_IN_CCT_AND_DUV_VALUES_VAL 0x2AE5 +#define BLE_MESH_UUID_CHROMATICITY_TOLERANCE_VAL 0x2AE6 +#define BLE_MESH_UUID_CIE_13_3_1995_COLOR_RENDERING_INDEX_VAL 0x2AE7 +#define BLE_MESH_UUID_COEFFICIENT_VAL 0x2AE8 +#define BLE_MESH_UUID_CORRELATED_COLOR_TEMPERATURE_VAL 0x2AE9 +#define BLE_MESH_UUID_COUNT_16_VAL 0x2AEA +#define BLE_MESH_UUID_COUNT_24_VAL 0x2AEB +#define BLE_MESH_UUID_COUNTRY_CODE_VAL 0x2AEC +#define BLE_MESH_UUID_DATE_UTC_VAL 0x2AED +#define BLE_MESH_UUID_ELECTRIC_CURRENT_VAL 0x2AEE +#define BLE_MESH_UUID_ELECTRIC_CURRENT_RANGE_VAL 0x2AEF +#define BLE_MESH_UUID_ELECTRIC_CURRENT_SPECIFICATION_VAL 0x2AF0 +#define BLE_MESH_UUID_ELECTRIC_CURRENT_STATISTICS_VAL 0x2AF1 +#define BLE_MESH_UUID_ENERGY_VAL 0x2AF2 +#define BLE_MESH_UUID_ENERGY_IN_A_PERIOD_OF_DAY_VAL 0x2AF3 +#define BLE_MESH_UUID_EVENT_STATISTICS_VAL 0x2AF4 +#define BLE_MESH_UUID_FIXED_STRING_16_VAL 0x2AF5 +#define BLE_MESH_UUID_FIXED_STRING_24_VAL 0x2AF6 +#define BLE_MESH_UUID_FIXED_STRING_36_VAL 0x2AF7 +#define BLE_MESH_UUID_FIXED_STRING_8_VAL 0x2AF8 +#define BLE_MESH_UUID_GENERIC_LEVEL_VAL 0x2AF9 +#define BLE_MESH_UUID_GLOBAL_TRADE_ITEM_NUMBER_VAL 0x2AFA +#define BLE_MESH_UUID_ILLUMINANCE_VAL 0x2AFB +#define BLE_MESH_UUID_LUMINOUS_EFFICACY_VAL 0x2AFC +#define BLE_MESH_UUID_LUMINOUS_ENERGY_VAL 0x2AFD +#define BLE_MESH_UUID_LUMINOUS_EXPOSURE_VAL 0x2AFE +#define BLE_MESH_UUID_LUMINOUS_FLUX_VAL 0x2AFF +#define BLE_MESH_UUID_LUMINOUS_FLUX_RANGE_VAL 0x2B00 +#define BLE_MESH_UUID_LUMINOUS_INTENSITY_VAL 0x2B01 +#define BLE_MESH_UUID_MASS_FLOW_VAL 0x2B02 +/** + * The following four have been defined in mesh_uuid.h + * #define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2ADB + * #define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2ADC + * #define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2ADD + * #define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ADE + */ +#define BLE_MESH_UUID_PERCEIVED_LIGHTNESS_VAL 0x2B03 +#define BLE_MESH_UUID_PERCENTAGE_8_VAL 0x2B04 +#define BLE_MESH_UUID_POWER_VAL 0x2B05 +#define BLE_MESH_UUID_POWER_SPECIFICATION_VAL 0x2B06 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_CURRENT_RANGE_VAL 0x2B07 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_VAL 0x2B08 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_PERIOD_OF_DAY_VAL 0x2B0B +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_TEMPERATURE_RANGE_VAL 0x2B0C +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_VOLTAGE_RANGE_VAL 0x2B09 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_AN_ILLUMINANCE_RANGE_VAL 0x2B0A +#define BLE_MESH_UUID_TEMPERATURE_8_VAL 0x2B0D +#define BLE_MESH_UUID_TEMPERATURE_8_IN_A_PERIOD_OF_DAY_VAL 0x2B0E +#define BLE_MESH_UUID_TEMPERATURE_8_STATISTICS_VAL 0x2B0F +#define BLE_MESH_UUID_TEMPERATURE_RANGE_VAL 0x2B10 +#define BLE_MESH_UUID_TEMPERATURE_STATISTICS_VAL 0x2B11 +#define BLE_MESH_UUID_TIME_DECIHOUR_8_VAL 0x2B12 +#define BLE_MESH_UUID_TIME_EXPONENTIAL_8_VAL 0x2B13 +#define BLE_MESH_UUID_TIME_HOUR_24_VAL 0x2B14 +#define BLE_MESH_UUID_TIME_MILLISECOND_24_VAL 0x2B15 +#define BLE_MESH_UUID_TIME_SECOND_16_VAL 0x2B16 +#define BLE_MESH_UUID_TIME_SECOND_8_VAL 0x2B17 +#define BLE_MESH_UUID_VOLTAGE_VAL 0x2B18 +#define BLE_MESH_UUID_VOLTAGE_SPECIFICATION_VAL 0x2B19 +#define BLE_MESH_UUID_VOLTAGE_STATISTICS_VAL 0x2B1A +#define BLE_MESH_UUID_VOLUME_FLOW_VAL 0x2B1B + +/** + * @brief BLE Mesh Device Property referenced Characteristic Type Definitions + */ + +/* Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius. */ +typedef s16_t bt_mesh_temperature_t; + +typedef u16_t bt_mesh_gap_appearance_t; + +/* Mesh Characteristics Type Definitions */ + +/* This characteristic represents an electric current. + * Note: Unit is ampere with a resolution of 0.01. + * Minimum value: 0, maximum value: 655.34; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_electric_current_t; + +/* The Time Exponential 8 characteristic is used to represent a measure of period of + * time in seconds. + * Note: The time duration is given by the value 1.1^(N-64) in seconds, with N being + * the raw 8-bit value; + * Minimum value: 0.0, maximum value: 73216705; + * A raw value of 0x00 represents 0 seconds, and a raw value of 0xFF represents + * the total life of the device. + */ +typedef u8_t bt_mesh_time_exponential_8_t; + +/* The Voltage characteristic is used to represent a measure of positive electric + * potential difference in units of volts. + * Note: Unit is volt with a resolution of 1/64V; + * Minimum value: 0.0, maximum value: 1022.0; + * A value of 0xFFFF represents 'value is not known'. The minimum representable + * value represents the minimum value or lower, the maximum representable value + * represents the maximum value or higher. + */ +typedef u16_t bt_mesh_voltage_t; + +/* This characteristic aggregates the Electric Current characteristic and instance of + * the Time Exponential 8 characteristic. + */ +typedef struct __packed average_current { + bt_mesh_electric_current_t electric_current; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_current_t; + +/* This characteristic aggregates the Voltage characteristic and instance of the Time + * Exponential 8 characteristic. + */ +typedef struct __packed average_voltage { + bt_mesh_voltage_t voltage; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_voltage_t; + +/* The Boolean characteristic defines the predefined Boolean values as an enumeration. + * Key | Value + * 0 | False + * 1 | True + * 2 to 255 | Prohibited + */ +typedef u8_t bt_mesh_boolean_t; + +/* The Chromatic Distance From Planckian characteristic represents a distance of a + * chromaticity coordinate from the Planckian locus in the (u',2/3 v') diagram as + * defined by ANSI standard C78.377-2008. The distance is positive if the chromaticity + * coordinate is located above the Planckian locus (i.e. has as higher y value than the + * Planckian), and negative if it is located below. The distance is only valid within + * the range from -0.05 to 0.05. + * Note: Unit is unitless with a resolution of 0.00001; + * Minimum value: -0.05, maximum value: 0.05; + * A value of 0xFFFF represents 'value is not known'; + * A value of 0xFFFE represents 'value is not valid'. + */ +typedef s16_t bt_mesh_chromatic_distance_from_planckian_t; + +/* This characteristic represents a chromaticity coordinate in a color diagram such as + * the CIE1931 diagram. It can represent an x or y coordinate. + * Note: Unit is unitless with a resolution of 1/65535; + * Minimum value: 0, maximum value: 1.0. + */ +typedef u16_t bt_mesh_chromaticity_coordinate_t; + +/* This characteristic represents a chromaticity coordinate as a tuple with an x and + * y coordinate. + */ +typedef struct __packed chromaticity_coordinates { + bt_mesh_chromaticity_coordinate_t chromaticity_x_coordinate; + bt_mesh_chromaticity_coordinate_t chromaticity_y_coordinate; +} bt_mesh_chromaticity_coordinates_t; + +/* The Correlated Color Temperature characteristic is used to represent correlated color + * temperature in a range from 800 to 65534 Kelvin with a resolution of 1 Kelvin. + * Note: Unit is Kelvin with a resolution of 1; + * Minimum value: 800, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_correlated_color_temperature_t; + +/* The Chromaticity In CCT And Duv Values characteristic is a composite characteristic + * consisting of the Correlated Color Temperature characteristic and the Chromatic + * Distance From Planckian characteristic. + */ +typedef struct __packed chromaticity_in_cct_and_duv_values { + bt_mesh_correlated_color_temperature_t correlated_color_temperature; + bt_mesh_chromatic_distance_from_planckian_t chromaticity_distance_from_planckian; +} bt_mesh_chromaticity_in_cct_and_duv_values_t; + +/* The Chromaticity Tolerance characteristic is a tolerance of a tuple of chromaticity + * values represented as a value of a radius of a circle in the CIE 1976 (u',v') diagram; + * value corresponding to the 3-sigma values of the expected chromaticity deviations. + * Note: Unit is unitless with a resolution of 0.0001; + * Minimum value: 0, maximum value: 0.0255. + */ +typedef u8_t bt_mesh_chromaticity_tolerance_t; + +/* The CIE 13.3-1995 Color Rendering Index characteristic is a color rendition index value + * for a color patch as calculated in accordance with the CIE 13.3-1995 standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: -128, maximum value: 100. + */ +typedef s8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; + +/* The Coefficient characteristic is used to represent a general coefficient value. */ +typedef float bt_mesh_coefficient_t; + +/* The Count 16 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_count_16_t; + +/* The Count 24 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_count_24_t[3]; + +/* This characteristic represents a country or dependent areas in accordance with + * the ISO 3166-1 Numeric standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 4095; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_country_code_t; + +/* Date as days elapsed since the Epoch (Jan 1, 1970) in the Coordinated Universal + * Time (UTC) time zone. + * Note: Unit is a day with a resolution of 1; + * Minimum value: 1, maximum value: 16777214; + * A value of 0x000000 represents 'value is not known'. + */ +typedef u8_t bt_mesh_date_utc_t[3]; + +/* This characteristic aggregates two instances of the Electric Current characteristic + * to represent a range of Electric Current values. + */ +typedef struct __packed electric_current_range { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_range_t; + +/* This characteristic aggregates three instances of the Electric Current characteristic + * to represent a specification of electric current values. + */ +typedef struct __packed electric_current_specification { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t typical_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_specification_t; + +/* This characteristic aggregates four instances of the Electric Current characteristic + * with a Sensing Duration to represent a set of statistical electric current values. + */ +typedef struct __packed electric_current_statistics { + bt_mesh_electric_current_t average_electric_current_value; + bt_mesh_electric_current_t standard_electric_current_value; + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_electric_current_statistics_t; + +/* The Energy characteristic is used to represent a measure of energy in units of + * kilowatt hours. + * Note: Unit is kilowatt-hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents ‘value is not known’. + */ +typedef u8_t bt_mesh_energy_t[3]; + +/* The Time Decihour 8 characteristic is used to represent a period of time in + * tenths of an hour. + * Note: Unit is hour with a resolution of 0.1; + * Minimum value: 0.0, maximum value: 24.0; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef u8_t bt_mesh_time_decihour_8_t; + +/* This characteristic aggregates the Energy characteristic, and two instances of + * the Time Decihour 8 characteristic, to represent energy use in a period of day. + */ +typedef struct __packed energy_in_a_period_of_day { + bt_mesh_energy_t energy_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_energy_in_a_period_of_day_t; + +/* The Time Second 16 characteristic is used to represent a period of time with a + * unit of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_time_second_16_t; + +/* This characteristic aggregates the Count 16 characteristic, two instances of the + * Time Decihour 8 characteristic and an instance of the Sensing Duration characteristic, + * to represent statistical values of events. + */ +typedef struct __packed event_statistics { + bt_mesh_count_16_t number_of_events; + bt_mesh_time_second_16_t average_event_duration; + bt_mesh_time_exponential_8_t time_elapsed_since_last_event; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_event_statistics_t; + +/* The Fixed String 16 characteristic represents a 16-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_16_t[16]; + +/* The Fixed String 24 characteristic represents a 24-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_24_t[24]; + +/* The Fixed String 36 characteristic represents a 36-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_36_t[36]; + +/* The Fixed String 8 characteristic represents an 8-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_8_t[8]; + +/* The Generic Level characteristic represents a general level value of a + * setting of a device. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef u16_t bt_mesh_generic_level_t; + +/* The Global Trade Item Number characteristic represents an identifier as + * issued by GS1 General Specifications, which may consist up to 14 digits, + * and is here represented as a 48-bit unsigned integer. + */ +typedef u8_t bt_mesh_global_trade_item_number_t[6]; + +/* The Illuminance characteristic is used to represent a measure of illuminance + * in units of lux. + * Note: Unit is lux with a resolution of 0.01; + * Minimum value: 0, maximum value: 167772.14; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_illuminance_t[3]; + +/* The Luminous Efficacy characteristic is used to represent a measure of luminous + * efficacy in units of lumen per watt. + * Note: Unit is lumen per watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1800; + * A value of 0xFFFF represents 'value is not known'. All other values are Prohibited. + */ +typedef u16_t bt_mesh_luminous_efficacy_t; + +/* The Luminous Energy characteristic is used to represent a measure of luminous + * energy in units of lumen hour. + * Note: Unit is lumen hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_luminous_energy_t[3]; + +/* The Luminous Exposure characteristic is used to represent a measure of luminous + * exposure in units of lux-hour. + * Note: Unit is lux hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_luminous_exposure_t[3]; + +/* The Luminous Flux characteristic is used to represent a measure of luminous flux + * in units of lumen. + * Note: Unit is lumen with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_luminous_flux_t; + +/* This characteristic aggregates two instances of the Luminous Flux characteristic + * to represent a luminous flux range. + */ +typedef struct __packed luminous_flux_range { + bt_mesh_luminous_flux_t minimum_luminous_flux; + bt_mesh_luminous_flux_t maximum_luminous_flux; +} bt_mesh_luminous_flux_range_t; + +/* The Luminous Intensity characteristic is used to represent a luminous intensity of + * a beam of light in units of candela. + * Note: Unit is candela with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_luminous_intensity_t; + +/* The Mass Flow characteristic is used to represent a flow of mass. + * Note: Unit is gram/second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_mass_flow_t; + +/* The Mesh Provisioning Data In characteristic can be written to send a Proxy PDU + * message containing Provisioning PDU to the Provisioning Server. + */ +struct mesh_provisioning_data_in { + +}; + +/* The Mesh Provisioning Data Out characteristic can be notified to send a Proxy PDU + * message containing Provisioning PDU from a Provisioning Server to a Provisioning Client. + */ +struct mesh_provisioning_data_out { + +}; + +/* The Mesh Proxy Data In characteristic is used by the client to send Proxy PDUs to + * the server. + */ +struct mesh_proxy_data_in { + +}; + +/* The Mesh Proxy Data Out characteristic is used by the server to send Proxy PDUs to + * the client. + */ +struct mesh_proxy_data_out { + +}; + +/* The Perceived Lightness characteristic is used to represent the perceived lightness + * of a light. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef u16_t bt_mesh_perceived_lightness_t; + +/* The Percentage 8 characteristic is used to represent a measure of percentage. + * Note: Unit is a percentage with a resolution of 0.5; + * Minimum value: 0, maximum value: 100; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef u8_t bt_mesh_percentage_8_t; + +/* The Power characteristic is used to represent a measure of power in units of watts. + * Note: Unit is watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1677721.4; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_power_t[3]; + +/* This characteristic aggregates three instances of the Power characteristic to + * represent a specification of Power values. + */ +typedef struct __packed power_specification { + bt_mesh_power_t minimum_power_value; + bt_mesh_power_t typical_power_value; + bt_mesh_power_t maximum_power_value; +} bt_mesh_power_specification_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Electric Current characteristic to represent a relative value in an electric + * current range. + */ +typedef struct __packed relative_runtime_in_a_current_range { + bt_mesh_percentage_8_t relative_runtime_value; + bt_mesh_electric_current_t minimum_current; + bt_mesh_electric_current_t maximum_current; +} bt_mesh_relative_runtime_in_a_current_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Generic Level characteristic to represent a runtime in a generic level range. + */ +typedef struct __packed relative_runtime_in_a_generic_level_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_generic_level_t minimum_generic_level; + bt_mesh_generic_level_t maximum_generic_level; +} bt_mesh_relative_runtime_in_a_generic_level_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Time Decihour 8 characteristic. + */ +typedef struct __packed relative_value_in_a_period_of_day { + bt_mesh_percentage_8_t relative_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_relative_value_in_a_period_of_day_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Temperature characteristic. + */ +typedef struct __packed relative_value_in_a_temperature_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_temperature_t minimum_temperature_value; + bt_mesh_temperature_t maximum_temperature_value; +} bt_mesh_relative_value_in_a_temperature_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Voltage characteristic to represent a relative value in a voltage range. + */ +typedef struct __packed relative_value_in_a_voltage_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_voltage_t minimum_voltage; + bt_mesh_voltage_t maximum_voltage; +} bt_mesh_relative_value_in_a_voltage_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Illuminance characteristic to represent a relative value in a illuminance range. + */ +typedef struct __packed relative_value_in_an_illuminance_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_illuminance_t minimum_illuminance; + bt_mesh_illuminance_t maximum_illuminance; +} bt_mesh_relative_value_in_an_illuminance_range_t; + +/* The Temperature 8 characteristic is used to represent a measure of temperature with + * a unit of 0.5 degree Celsius. + * Note: Unit is degree Celsius with a resolution of 0.5; + * Minimum value: -64.0, maximum value: 63.5; + * A value of 0xFF represents 'value is not known'. + */ +typedef s8_t bt_mesh_temperature_8_t; + +/* This characteristic aggregates the Temperature 8 characteristic, and two instances + * of the Time Decihour 8 characteristic, to represent a temperature value in a period + * of day. + */ +typedef struct __packed temperature_8_in_a_period_of_day { + bt_mesh_temperature_8_t temperature; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_temperature_8_in_a_period_of_day_t; + +/* This characteristic aggregates four instances of the Temperature 8 characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_8_statistics { + bt_mesh_temperature_8_t average; + bt_mesh_temperature_8_t standard_deviation_value; + bt_mesh_temperature_8_t minimum_value; + bt_mesh_temperature_8_t maximum_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_8_statistics_t; + +/* This characteristic aggregates two instances of the Temperature characteristic to + * represent a temperature range. + */ +typedef struct __packed temperature_range { + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; +} bt_mesh_temperature_range_t; + +/* This characteristic aggregates four instances of the Temperature characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_statistics { + bt_mesh_temperature_t average_temperature; + bt_mesh_temperature_t standard_deviation_temperature; + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_statistics_t; + +/* The Time Hour 24 characteristic is used to represent a period of time in hours. + * Note: Unit is hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_time_hour_24_t[3]; + +/* The Time Millisecond 24 characteristic is used to represent a period of time with + * a resolution of 1 millisecond. + * Note: Unit is second with a resolution of 0.001; + * Minimum value: 0, maximum value: 16777.214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_time_millisecond_24_t[3]; + +/* The Time Second 8 characteristic is used to represent a period of time with a unit + * of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 254; + * A value of 0xFF represents 'value is not known'. + */ +typedef u8_t bt_mesh_time_second_8_t; + +/* This characteristic aggregates three instances of the Voltage characteristic to + * represent a specification of voltage values. + */ +typedef struct __packed voltage_specification { + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t typical_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; +} bt_mesh_voltage_specification_t; + +/* This characteristic aggregates four instances of the Voltage characteristic and an + * instance of the Time Exponential 8 characteristic to represent a set of statistical + * voltage values over a period of time. + */ +typedef struct __packed voltage_statistics { + bt_mesh_voltage_t average_voltage_value; + bt_mesh_voltage_t standard_deviation_voltage_value; + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_voltage_statistics_t; + +/* The Volume Flow characteristic is used to represent a flow of a general volume such + * as a volume of material or gas. + * Note: Unit is liter/second with a resolution of 0.001 (1 milliliter); + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef u16_t bt_mesh_volume_flow_t; + +/* Mesh Device Property related function */ + +u8_t bt_mesh_get_dev_prop_len(u16_t prop_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVICE_PROPERTY_H_ */ \ No newline at end of file diff --git a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c index ab74f633d..3de3a1545 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c @@ -59,7 +59,7 @@ static void send_gen_onoff_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -93,7 +93,7 @@ static void gen_onoff_get(struct bt_mesh_model *model, struct bt_mesh_gen_onoff_srv *srv = model->user_data; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -111,7 +111,7 @@ static void gen_onoff_get(struct bt_mesh_model *model, void gen_onoff_publish(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -129,13 +129,13 @@ static void gen_onoff_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } onoff = net_buf_simple_pull_u8(buf); if (onoff > BLE_MESH_STATE_ON) { - BT_ERR("%s, Invalid OnOff value 0x%02x", __func__, onoff); + BT_ERR("Invalid OnOff value 0x%02x", onoff); return; } tid = net_buf_simple_pull_u8(buf); @@ -231,7 +231,7 @@ static void send_gen_level_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -274,7 +274,7 @@ static void gen_level_get(struct bt_mesh_model *model, struct bt_mesh_gen_level_srv *srv = model->user_data; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -292,7 +292,7 @@ static void gen_level_get(struct bt_mesh_model *model, void gen_level_publish(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -311,7 +311,7 @@ static void gen_level_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -407,7 +407,7 @@ static void gen_delta_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -529,7 +529,7 @@ static void gen_move_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -660,7 +660,7 @@ static void send_gen_def_trans_time_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -689,7 +689,7 @@ static void gen_def_trans_time_get(struct bt_mesh_model *model, struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -712,13 +712,13 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model, u8_t trans_time = 0U; if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } trans_time = net_buf_simple_pull_u8(buf); if ((trans_time & 0x3F) == 0x3F) { - BT_WARN("%s, Invalid Transaction Number of Steps 0x3F", __func__); + BT_WARN("Invalid Transaction Number of Steps 0x3f"); return; } @@ -766,7 +766,7 @@ static void send_gen_onpowerup_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -789,7 +789,7 @@ static void send_gen_onpowerup_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Invalid Generic Power OnOff Server 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Power OnOff Server 0x%04x", model->id); if (publish == false) { bt_mesh_free_buf(msg); } @@ -812,7 +812,7 @@ static void gen_onpowerup_get(struct bt_mesh_model *model, struct bt_mesh_gen_power_onoff_srv *srv = model->user_data; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -831,7 +831,7 @@ static void gen_onpowerup_get(struct bt_mesh_model *model, void gen_onpowerup_publish(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -839,7 +839,7 @@ void gen_onpowerup_publish(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV: { struct bt_mesh_gen_power_onoff_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power OnOff Server state", __func__); + BT_ERR("Invalid Generic Power OnOff Server state"); return; } break; @@ -847,13 +847,13 @@ void gen_onpowerup_publish(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV: { struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power OnOff Setup Server state", __func__); + BT_ERR("Invalid Generic Power OnOff Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Generic Power OnOff Server 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Power OnOff Server 0x%04x", model->id); return; } @@ -869,13 +869,13 @@ static void gen_onpowerup_set(struct bt_mesh_model *model, u8_t onpowerup = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } onpowerup = net_buf_simple_pull_u8(buf); if (onpowerup > BLE_MESH_STATE_RESTORE) { - BT_WARN("%s, Invalid OnPowerUp value 0x%02x", __func__, onpowerup); + BT_WARN("Invalid OnPowerUp value 0x%02x", onpowerup); return; } @@ -923,7 +923,7 @@ static void send_gen_power_level_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -973,7 +973,7 @@ static void send_gen_power_level_status(struct bt_mesh_model *model, } break; default: - BT_WARN("%s, Unknown Generic Power status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Generic Power status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -997,7 +997,7 @@ static void gen_power_level_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1022,7 +1022,7 @@ static void gen_power_level_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS; break; default: - BT_WARN("%s, Unknown Generic Power Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic Power Get opcode 0x%04x", ctx->recv_op); return; } @@ -1033,7 +1033,7 @@ static void gen_power_level_get(struct bt_mesh_model *model, void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1041,7 +1041,7 @@ void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: { struct bt_mesh_gen_power_level_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power Level Server state", __func__); + BT_ERR("Invalid Generic Power Level Server state"); return; } break; @@ -1049,13 +1049,13 @@ void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode) case ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV: { struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power Level Setup Server state", __func__); + BT_ERR("Invalid Generic Power Level Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Generic Power Level Server 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Power Level Server 0x%04x", model->id); return; } @@ -1074,7 +1074,7 @@ static void gen_power_level_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1182,7 +1182,7 @@ static void gen_power_default_set(struct bt_mesh_model *model, u16_t power = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1232,7 +1232,7 @@ static void gen_power_range_set(struct bt_mesh_model *model, u16_t range_min = 0U, range_max = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1240,8 +1240,8 @@ static void gen_power_range_set(struct bt_mesh_model *model, range_max = net_buf_simple_pull_le16(buf); if (range_min > range_max) { - BT_ERR("%s, Range Min 0x%04x is greater than Range Max 0x%04x", - __func__, range_min, range_max); + BT_ERR("Range min 0x%04x is greater than range max 0x%04x", + range_min, range_max); return; } @@ -1296,7 +1296,7 @@ static void gen_battery_get(struct bt_mesh_model *model, NET_BUF_SIMPLE_DEFINE(msg, 2 + 8 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (srv == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1331,7 +1331,7 @@ static void send_gen_location_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -1374,7 +1374,7 @@ static void send_gen_location_status(struct bt_mesh_model *model, } break; default: - BT_WARN("%s, Unknown Generic Location status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Generic Location status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -1398,7 +1398,7 @@ static void gen_location_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1417,7 +1417,7 @@ static void gen_location_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS; break; default: - BT_WARN("%s, Unknown Generic Location Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic Location Get opcode 0x%04x", ctx->recv_op); return; } @@ -1434,7 +1434,7 @@ static void gen_location_set(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1526,7 +1526,7 @@ static void gen_location_set(struct bt_mesh_model *model, break; } default: - BT_WARN("%s, Unknown Generic Location Set opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic Location Set opcode 0x%04x", ctx->recv_op); return; } @@ -1540,8 +1540,8 @@ static void gen_location_set(struct bt_mesh_model *model, } /* Generic User Property Server message handlers */ -struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model, - u16_t property_id) +static struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model, + u16_t property_id) { struct bt_mesh_gen_user_prop_srv *srv = model->user_data; int i; @@ -1564,13 +1564,13 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model, u16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { - BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id); + BT_ERR("Invalid User Property ID 0x%04x", property_id); return; } property = gen_get_user_property(model, property_id); if (property == NULL) { - BT_WARN("%s, User property 0x%04x not exist", __func__, property_id); + BT_WARN("User property 0x%04x not exists", property_id); length = sizeof(property_id); } else { length = sizeof(property->id) + sizeof(property->user_access) + property->val->len; @@ -1579,7 +1579,7 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -1622,7 +1622,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, struct bt_mesh_gen_user_prop_srv *srv = model->user_data; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1651,7 +1651,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, u8_t i; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS); @@ -1671,7 +1671,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, return; } default: - BT_WARN("%s, Unknown Generic User Property Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic User Property Get opcode 0x%04x", ctx->recv_op); return; } } @@ -1686,7 +1686,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, u8_t expect_len = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1720,8 +1720,8 @@ static void gen_user_prop_set(struct bt_mesh_model *model, */ expect_len = bt_mesh_get_dev_prop_len(property_id); if (buf->len != expect_len) { - BT_ERR("%s, Invalid User Property length, ID 0x%04x, expect %d, actual %d", - __func__, property_id, expect_len, buf->len); + BT_ERR("Invalid User Property 0x%04x length, expect %d, actual %d", + property_id, expect_len, buf->len); return; } @@ -1744,8 +1744,8 @@ static void gen_user_prop_set(struct bt_mesh_model *model, } /* Generic Admin Property Server message handlers */ -struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model, - u16_t property_id) +static struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model, + u16_t property_id) { struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; int i; @@ -1768,13 +1768,13 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model, u16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { - BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id); + BT_ERR("Invalid Admin Property ID 0x%04x", property_id); return; } property = gen_get_admin_property(model, property_id); if (property == NULL) { - BT_WARN("%s, Admin property 0x%04x not exist", __func__, property_id); + BT_WARN("Admin property 0x%04x not exists", property_id); length = sizeof(property_id); } else { length = sizeof(property->id) + sizeof(property->admin_access) + property->val->len; @@ -1783,7 +1783,7 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -1821,7 +1821,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1846,7 +1846,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, u8_t i = 0U; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS); @@ -1863,7 +1863,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, return; } default: - BT_WARN("%s, Unknown Generic Admin Property Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic Admin Property Get opcode 0x%04x", ctx->recv_op); return; } } @@ -1878,14 +1878,14 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, u8_t access = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } property_id = net_buf_simple_pull_le16(buf); access = net_buf_simple_pull_u8(buf); if (access > ADMIN_ACCESS_READ_WRITE) { - BT_ERR("%s, Invalid Admin Access 0x%02x", __func__, access); + BT_ERR("Invalid Admin Access 0x%02x", access); return; } @@ -1932,8 +1932,8 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, } /* Generic Manufacturer Property Server message handlers */ -struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model, - u16_t property_id) +static struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model, + u16_t property_id) { struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; int i; @@ -1956,13 +1956,13 @@ static void send_gen_manu_prop_status(struct bt_mesh_model *model, u16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { - BT_ERR("%s, Invalid User Property ID 0x%04x", __func__, property_id); + BT_ERR("Invalid Manu Property ID 0x%04x", property_id); return; } property = gen_get_manu_property(model, property_id); if (property == NULL) { - BT_WARN("%s, Manufacturer property 0x%04x not exist", __func__, property_id); + BT_WARN("Manu property 0x%04x not exists", property_id); length = sizeof(property_id); } else { length = sizeof(property->id) + sizeof(property->manu_access) + property->val->len; @@ -1971,7 +1971,7 @@ static void send_gen_manu_prop_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -2006,7 +2006,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2031,7 +2031,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, u8_t i = 0U; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS); @@ -2048,7 +2048,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, return; } default: - BT_WARN("%s, Unknown Generic Manufacturer Property Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Generic Manu Property Get opcode 0x%04x", ctx->recv_op); return; } } @@ -2063,14 +2063,14 @@ static void gen_manu_prop_set(struct bt_mesh_model *model, u8_t access = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } property_id = net_buf_simple_pull_le16(buf); access = net_buf_simple_pull_u8(buf); if (access > MANU_ACCESS_READ) { - BT_ERR("%s, Invalid Manufacturer Access 0x%02x", __func__, access); + BT_ERR("Invalid Manu Access 0x%02x", access); return; } @@ -2153,7 +2153,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, int i, index = 0; if (srv == NULL || srv->id_count == 0U || srv->property_ids == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2184,7 +2184,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); if (sdu == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -2193,6 +2193,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, total_len += sizeof(u16_t); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ + BT_WARN("Too large generic client properties status"); break; } net_buf_simple_add_le16(sdu, srv->property_ids[i]); @@ -2206,7 +2207,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, /* message handlers (End) */ /* Mapping of message handlers for Generic OnOff Server (0x1000) */ -const struct bt_mesh_model_op gen_onoff_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_onoff_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_ONOFF_GET, 0, gen_onoff_get }, { BLE_MESH_MODEL_OP_GEN_ONOFF_SET, 2, gen_onoff_set }, { BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK, 2, gen_onoff_set }, @@ -2214,7 +2215,7 @@ const struct bt_mesh_model_op gen_onoff_srv_op[] = { }; /* Mapping of message handlers for Generic Level Server (0x1002) */ -const struct bt_mesh_model_op gen_level_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_level_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_LEVEL_GET, 0, gen_level_get }, { BLE_MESH_MODEL_OP_GEN_LEVEL_SET, 3, gen_level_set }, { BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK, 3, gen_level_set }, @@ -2226,7 +2227,7 @@ const struct bt_mesh_model_op gen_level_srv_op[] = { }; /* Mapping of message handlers for Generic Default TT Server (0x1004) */ -const struct bt_mesh_model_op gen_def_trans_time_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET, 0, gen_def_trans_time_get }, { BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET, 1, gen_def_trans_time_set }, { BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK, 1, gen_def_trans_time_set }, @@ -2234,20 +2235,20 @@ const struct bt_mesh_model_op gen_def_trans_time_srv_op[] = { }; /* Mapping of message handlers for Generic Power OnOff Server (0x1006) */ -const struct bt_mesh_model_op gen_power_onoff_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_onoff_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET, 0, gen_onpowerup_get }, BLE_MESH_MODEL_OP_END, }; /* Mapping of message handlers for Generic Power OnOff Setup Server (0x1007) */ -const struct bt_mesh_model_op gen_power_onoff_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_onoff_setup_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET, 1, gen_onpowerup_set }, { BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK, 1, gen_onpowerup_set }, BLE_MESH_MODEL_OP_END, }; /* Mapping of message handlers for Generic Power Level Server (0x1009) */ -const struct bt_mesh_model_op gen_power_level_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_level_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET, 0, gen_power_level_get }, { BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET, 3, gen_power_level_set }, { BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK, 3, gen_power_level_set }, @@ -2258,7 +2259,7 @@ const struct bt_mesh_model_op gen_power_level_srv_op[] = { }; /* Mapping of message handlers for Generic Power Level Setup Server (0x100A) */ -const struct bt_mesh_model_op gen_power_level_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_power_level_setup_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET, 2, gen_power_default_set }, { BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK, 2, gen_power_default_set }, { BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET, 4, gen_power_range_set }, @@ -2267,20 +2268,20 @@ const struct bt_mesh_model_op gen_power_level_setup_srv_op[] = { }; /* Mapping of message handlers for Generic Battery Server (0x100C) */ -const struct bt_mesh_model_op gen_battery_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_battery_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_BATTERY_GET, 0, gen_battery_get }, BLE_MESH_MODEL_OP_END, }; /* Mapping of message handlers for Generic Location Server (0x100E) */ -const struct bt_mesh_model_op gen_location_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_location_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET, 0, gen_location_get }, { BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET, 0, gen_location_get }, BLE_MESH_MODEL_OP_END, }; /* Mapping of message handlers for Generic Location Setup Server (0x100F) */ -const struct bt_mesh_model_op gen_location_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_location_setup_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET, 10, gen_location_set }, { BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK, 10, gen_location_set }, { BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET, 9, gen_location_set }, @@ -2289,7 +2290,7 @@ const struct bt_mesh_model_op gen_location_setup_srv_op[] = { }; /* Mapping of message handlers for Generic User Property Server (0x1013) */ -const struct bt_mesh_model_op gen_user_prop_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_user_prop_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET, 0, gen_user_prop_get }, { BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET, 2, gen_user_prop_get }, { BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET, 3, gen_user_prop_set }, @@ -2298,7 +2299,7 @@ const struct bt_mesh_model_op gen_user_prop_srv_op[] = { }; /* Mapping of message handlers for Generic Admin Property Server (0x1011) */ -const struct bt_mesh_model_op gen_admin_prop_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_admin_prop_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET, 0, gen_admin_prop_get }, { BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET, 2, gen_admin_prop_get }, { BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET, 4, gen_admin_prop_set }, @@ -2307,7 +2308,7 @@ const struct bt_mesh_model_op gen_admin_prop_srv_op[] = { }; /* Mapping of message handlers for Generic Manufacturer Property Server (0x1012) */ -const struct bt_mesh_model_op gen_manu_prop_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_manu_prop_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET, 0, gen_manu_prop_get }, { BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET, 2, gen_manu_prop_get }, { BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET, 3, gen_manu_prop_set }, @@ -2316,7 +2317,7 @@ const struct bt_mesh_model_op gen_manu_prop_srv_op[] = { }; /* Mapping of message handlers for Generic Client Property Server (0x1014) */ -const struct bt_mesh_model_op gen_client_prop_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_gen_client_prop_srv_op[] = { { BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET, 2, gen_client_prop_get }, BLE_MESH_MODEL_OP_END, }; @@ -2335,7 +2336,7 @@ static inline int property_id_compare(const void *p1, const void *p2) static int generic_server_init(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Generic Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -2366,7 +2367,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV: { struct bt_mesh_gen_power_onoff_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic OnPowerUp State", __func__); + BT_ERR("Invalid Generic OnPowerUp State"); return -EINVAL; } srv->model = model; @@ -2375,7 +2376,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV: { struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic OnPowerUp State", __func__); + BT_ERR("Invalid Generic OnPowerUp State"); return -EINVAL; } srv->model = model; @@ -2384,7 +2385,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: { struct bt_mesh_gen_power_level_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic Power Level State", __func__); + BT_ERR("Invalid Generic Power Level State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -2397,7 +2398,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV: { struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic Power Level State", __func__); + BT_ERR("Invalid Generic Power Level State"); return -EINVAL; } srv->model = model; @@ -2411,7 +2412,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_LOCATION_SRV: { struct bt_mesh_gen_location_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic Location State", __func__); + BT_ERR("Invalid Generic Location State"); return -EINVAL; } srv->model = model; @@ -2420,7 +2421,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV: { struct bt_mesh_gen_location_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic Location State", __func__); + BT_ERR("Invalid Generic Location State"); return -EINVAL; } srv->model = model; @@ -2429,7 +2430,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV: { struct bt_mesh_gen_user_prop_srv *srv = model->user_data; if (srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, NULL Generic User Property State", __func__); + BT_ERR("Invalid Generic User Property State"); return -EINVAL; } srv->model = model; @@ -2438,7 +2439,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV: { struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; if (srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, NULL Generic Admin Property State", __func__); + BT_ERR("Invalid Generic Admin Property State"); return -EINVAL; } srv->model = model; @@ -2447,7 +2448,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV: { struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; if (srv->property_count == 0U || srv->properties == NULL) { - BT_ERR("%s, NULL Generic Manufacturer Property State", __func__); + BT_ERR("Invalid Generic Manufacturer Property State"); return -EINVAL; } srv->model = model; @@ -2456,7 +2457,7 @@ static int generic_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV: { struct bt_mesh_gen_client_prop_srv *srv = model->user_data; if (srv->id_count == 0U || srv->property_ids == NULL) { - BT_ERR("%s, NULL Generic Client Property State", __func__); + BT_ERR("Invalid Generic Client Property State"); return -EINVAL; } /* Quick sort the Client Property IDs in ascending order */ @@ -2465,7 +2466,7 @@ static int generic_server_init(struct bt_mesh_model *model) break; } default: - BT_WARN("%s, Unknown Generic Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Generic Server, model id 0x%04x", model->id); return -EINVAL; } @@ -2474,40 +2475,40 @@ static int generic_server_init(struct bt_mesh_model *model) return 0; } -int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_onoff_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic OnOff Server has no publication support", __func__); + BT_ERR("Generic OnOff Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_level_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Level Server has no publication support", __func__); + BT_ERR("Generic Level Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_def_trans_time_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Default Trans Time Server has no publication support", __func__); + BT_ERR("Generic Default Trans Time Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_power_onoff_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Power OnOff Server has no publication support", __func__); + BT_ERR("Generic Power OnOff Server has no publication support"); return -EINVAL; } @@ -2516,21 +2517,21 @@ int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV) == NULL) { - BT_WARN("%s, Generic Power OnOff Setup Server is not present", __func__); + BT_WARN("Generic Power OnOff Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return generic_server_init(model); } -int bt_mesh_gen_power_onoff_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_power_onoff_setup_srv_init(struct bt_mesh_model *model) { return generic_server_init(model); } -int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_power_level_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Power Level Server has no publication support", __func__); + BT_ERR("Generic Power Level Server has no publication support"); return -EINVAL; } @@ -2539,84 +2540,84 @@ int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV) == NULL) { - BT_WARN("%s, Generic Power Level Setup Server is not present", __func__); + BT_WARN("Generic Power Level Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return generic_server_init(model); } -int bt_mesh_gen_power_level_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_power_level_setup_srv_init(struct bt_mesh_model *model) { return generic_server_init(model); } -int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_battery_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Battery Server has no publication support", __func__); + BT_ERR("Generic Battery Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_location_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Location Server has no publication support", __func__); + BT_ERR("Generic Location Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_location_setup_srv_init(struct bt_mesh_model *model) { /* When this model is present on an Element, the corresponding Generic * Location Setup Server model shall also be present. */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV) == NULL) { - BT_WARN("%s, Generic Location Setup Server is not present", __func__); + BT_WARN("Generic Location Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return generic_server_init(model); } -int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_user_prop_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic User Property has no publication support", __func__); + BT_ERR("Generic User Property Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_admin_prop_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Admin Property has no publication support", __func__); + BT_ERR("Generic Admin Property Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_manu_prop_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Manufacturer Property has no publication support", __func__); + BT_ERR("Generic Manufacturer Property Server has no publication support"); return -EINVAL; } return generic_server_init(model); } -int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary) +static int gen_client_prop_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Client Property has no publication support", __func__); + BT_ERR("Generic Client Property Server has no publication support"); return -EINVAL; } @@ -2626,7 +2627,7 @@ int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary) static int generic_server_deinit(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Generic Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -2650,7 +2651,7 @@ static int generic_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV: { struct bt_mesh_gen_power_level_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Generic Power Level State", __func__); + BT_ERR("Invalid Generic Power Level State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -2660,7 +2661,7 @@ static int generic_server_deinit(struct bt_mesh_model *model) break; } default: - BT_WARN("%s, Unknown Generic Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Generic Server, model id 0x%04x", model->id); return -EINVAL; } @@ -2669,127 +2670,197 @@ static int generic_server_deinit(struct bt_mesh_model *model) return 0; } -int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_onoff_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic OnOff Server has no publication support", __func__); + BT_ERR("Generic OnOff Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_level_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Level Server has no publication support", __func__); + BT_ERR("Generic Level Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_def_trans_time_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Default Trans Time Server has no publication support", __func__); + BT_ERR("Generic Default Trans Time Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_power_onoff_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Power OnOff Server has no publication support", __func__); + BT_ERR("Generic Power OnOff Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model) { return generic_server_deinit(model); } -int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_power_level_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Power Level Server has no publication support", __func__); + BT_ERR("Generic Power Level Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_power_level_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_power_level_setup_srv_deinit(struct bt_mesh_model *model) { return generic_server_deinit(model); } -int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_battery_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Battery Server has no publication support", __func__); + BT_ERR("Generic Battery Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_location_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Location Server has no publication support", __func__); + BT_ERR("Generic Location Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_location_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_location_setup_srv_deinit(struct bt_mesh_model *model) { return generic_server_deinit(model); } -int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_user_prop_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic User Property has no publication support", __func__); + BT_ERR("Generic User Property Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_admin_prop_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Admin Property has no publication support", __func__); + BT_ERR("Generic Admin Property Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_manu_prop_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Manufacturer Property has no publication support", __func__); + BT_ERR("Generic Manufacturer Property Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); } -int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary) +static int gen_client_prop_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Generic Client Property has no publication support", __func__); + BT_ERR("Generic Client Property Server has no publication support"); return -EINVAL; } return generic_server_deinit(model); -} \ No newline at end of file +} + +const struct bt_mesh_model_cb bt_mesh_gen_onoff_srv_cb = { + .init = gen_onoff_srv_init, + .deinit = gen_onoff_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_level_srv_cb = { + .init = gen_level_srv_init, + .deinit = gen_level_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_def_trans_time_srv_cb = { + .init = gen_def_trans_time_srv_init, + .deinit = gen_def_trans_time_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_srv_cb = { + .init = gen_power_onoff_srv_init, + .deinit = gen_power_onoff_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_power_onoff_setup_srv_cb = { + .init = gen_power_onoff_setup_srv_init, + .deinit = gen_power_onoff_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_power_level_srv_cb = { + .init = gen_power_level_srv_init, + .deinit = gen_power_level_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_power_level_setup_srv_cb = { + .init = gen_power_level_setup_srv_init, + .deinit = gen_power_level_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_battery_srv_cb = { + .init = gen_battery_srv_init, + .deinit = gen_battery_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_location_srv_cb = { + .init = gen_location_srv_init, + .deinit = gen_location_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_location_setup_srv_cb = { + .init = gen_location_setup_srv_init, + .deinit = gen_location_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb = { + .init = gen_user_prop_srv_init, + .deinit = gen_user_prop_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb = { + .init = gen_admin_prop_srv_init, + .deinit = gen_admin_prop_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb = { + .init = gen_manu_prop_srv_init, + .deinit = gen_manu_prop_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb = { + .init = gen_client_prop_srv_init, + .deinit = gen_client_prop_srv_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/device_property.h b/components/bt/esp_ble_mesh/mesh_models/server/include/device_property.h deleted file mode 100644 index 35bdc34ef..000000000 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/device_property.h +++ /dev/null @@ -1,1053 +0,0 @@ -// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _DEVICE_PROPERTY_H_ -#define _DEVICE_PROPERTY_H_ - -#include "mesh_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * BLE Mesh Device Properties. - * - * Name Type ID Characteristic Type Size - * Average Ambient Temperature In A Period Of Day org.bluetooth.property.average_ambient_temperature_in_a_period_of_day 0x0001 Temperature 8 In A Period Of Day 3 - * Average Input Current org.bluetooth.property.average_input_current 0x0002 Average Current 3 - * Average Input Voltage org.bluetooth.property.average_input_voltage 0x0003 Average Voltage 3 - * Average Output Current org.bluetooth.property.average_output_current 0x0004 Average Current 3 - * Average Output Voltage org.bluetooth.property.average_output_voltage 0x0005 Average Voltage 3 - * Center Beam Intensity At Full Power org.bluetooth.property.center_beam_intensity_at_full_power 0x0006 Luminous Intensity 2 - * Chromaticity Tolerance org.bluetooth.property.chromaticity_tolerance 0x0007 Chromaticity Tolerance 1 - * Color Rendering Index R9 org.bluetooth.property.color_rendering_index_r9 0x0008 Cie 13.3-1995 Color Rendering Index 1 - * Color Rendering Index Ra org.bluetooth.property.color_rendering_index_ra 0x0009 Cie 13.3-1995 Color Rendering Index 1 - * Device Appearance org.bluetooth.property.device_appearance 0x000A Gap.Appearance 2 - * Device Country Of Origin org.bluetooth.property.device_country_of_origin 0x000B Country Code 2 - * Device Date Of Manufacture org.bluetooth.property.device_date_of_manufacture 0x000C Date Utc 4 - * Device Energy Use Since Turn On org.bluetooth.property.device_energy_use_since_turn_on 0x000D Energy 4 - * Device Firmware Revision org.bluetooth.property.device_firmware_revision 0x000E Fixed String 8 8 - * Device Global Trade Item Number org.bluetooth.property.device_global_trade_item_number 0x000F Global Trade Item Number 8 - * Device Hardware Revision org.bluetooth.property.device_hardware_revision 0x0010 Fixed String 16 16 - * Device Manufacturer Name org.bluetooth.property.device_manufacturer_name 0x0011 Fixed String 36 36 - * Device Model Number org.bluetooth.property.device_model_number 0x0012 Fixed String 24 24 - * Device Operating Temperature Range Specification org.bluetooth.property.device_operating_temperature_range_specification 0x0013 Temperature Range 4 - * Device Operating Temperature Statistical Values org.bluetooth.property.device_operating_temperature_statistical_values 0x0014 Temperature Statistics 9 - * Device Over Temperature Event Statistics org.bluetooth.property.device_over_temperature_event_statistics 0x0015 Event Statistics 6 - * Device Power Range Specification org.bluetooth.property.device_power_range_specification 0x0016 Power Specification 12 - * Device Runtime Since Turn On org.bluetooth.property.device_runtime_since_turn_on 0x0017 Time Hour 24 4 - * Device Runtime Warranty org.bluetooth.property.device_runtime_warranty 0x0018 Time Hour 24 4 - * Device Serial Number org.bluetooth.property.device_serial_number 0x0019 Fixed String 16 16 - * Device Software Revision org.bluetooth.property.device_software_revision 0x001A Fixed String 8 8 - * Device Under Temperature Event Statistics org.bluetooth.property.device_under_temperature_event_statistics 0x001B Event Statistics 6 - * Indoor Ambient Temperature Statistical Values org.bluetooth.property.indoor_ambient_temperature_statistical_values 0x001C Temperature 8 Statistics 5 - * Initial CIE 1931 Chromaticity Coordinates org.bluetooth.property.initial_cie_1931_chromaticity_coordinates 0x001D Chromaticity Coordinates 4 - * Initial Correlated Color Temperature org.bluetooth.property.initial_correlated_color_temperature 0x001E Correlated Color Temperature 2 - * Initial Luminous Flux org.bluetooth.property.initial_luminous_flux 0x001F Luminous Flux 2 - * Initial Planckian Distance org.bluetooth.property.initial_planckian_distance 0x0020 Chromatic Distance From Planckian 2 - * Input Current Range Specification org.bluetooth.property.input_current_range_specification 0x0021 Electric Current Specification 6 - * Input Current Statistics org.bluetooth.property.input_current_statistics 0x0022 Electric Current Statistics 9 - * Input Over Current Event Statistics org.bluetooth.property.input_over_current_event_statistics 0x0023 Event Statistics 6 - * Input Over Ripple Voltage Event Statistics org.bluetooth.property.input_over_ripple_voltage_event_statistics 0x0024 Event Statistics 6 - * Input Over Voltage Event Statistics org.bluetooth.property.input_over_voltage_event_statistics 0x0025 Event Statistics 6 - * Input Under Current Event Statistics org.bluetooth.property.input_under_current_event_statistics 0x0026 Event Statistics 6 - * Input Under Voltage Event Statistics org.bluetooth.property.input_under_voltage_event_statistics 0x0027 Event Statistics 6 - * Input Voltage Range Specification org.bluetooth.property.input_voltage_range_specification 0x0028 Voltage Specification 6 - * Input Voltage Ripple Specification org.bluetooth.property.input_voltage_ripple_specification 0x0029 Percentage 8 1 - * Input Voltage Statistics org.bluetooth.property.input_voltage_statistics 0x002A Voltage Statistics 9 - * Light Control Ambient LuxLevel On org.bluetooth.property.light_control_ambient_luxlevel_on 0x002B Illuminance 4 - * Light Control Ambient LuxLevel Prolong org.bluetooth.property.light_control_ambient_luxlevel_prolong 0x002C Illuminance 4 - * Light Control Ambient LuxLevel Standby org.bluetooth.property.light_control_ambient_luxlevel_standby 0x002D Illuminance 4 - * Light Control Lightness On org.bluetooth.property.light_control_lightness_on 0x002E Perceived Lightness 2 - * Light Control Lightness Prolong org.bluetooth.property.light_control_lightness_prolong 0x002F Perceived Lightness 2 - * Light Control Lightness Standby org.bluetooth.property.light_control_lightness_standby 0x0030 Perceived Lightness 2 - * Light Control Regulator Accuracy org.bluetooth.property.light_control_regulator_accuracy 0x0031 Percentage 8 1 - * Light Control Regulator Kid org.bluetooth.property.light_control_regulator_kid 0x0032 Coefficient 4 - * Light Control Regulator Kiu org.bluetooth.property.light_control_regulator_kiu 0x0033 Coefficient 4 - * Light Control Regulator Kpd org.bluetooth.property.light_control_regulator_kpd 0x0034 Coefficient 4 - * Light Control Regulator Kpu org.bluetooth.property.light_control_regulator_kpu 0x0035 Coefficient 4 - * Light Control Time Fade org.bluetooth.property.light_control_time_fade 0x0036 Time Millisecond 24 4 - * Light Control Time Fade On org.bluetooth.property.light_control_time_fade_on 0x0037 Time Millisecond 24 4 - * Light Control Time Fade Standby Auto org.bluetooth.property.light_control_time_fade_standby_auto 0x0038 Time Millisecond 24 4 - * Light Control Time Fade Standby Manual org.bluetooth.property.light_control_time_fade_standby_manual 0x0039 Time Millisecond 24 4 - * Light Control Time Occupancy Delay org.bluetooth.property.light_control_time_occupancy_delay 0x003A Time Millisecond 24 4 - * Light Control Time Prolong org.bluetooth.property.light_control_time_prolong 0x003B Time Millisecond 24 4 - * Light Control Time Run On org.bluetooth.property.light_control_time_run_on 0x003C Time Millisecond 24 4 - * Lumen Maintenance Factor org.bluetooth.property.lumen_maintenance_factor 0x003D Percentage 8 1 - * Luminous Efficacy org.bluetooth.property.luminous_efficacy 0x003E Luminous Efficacy 2 - * Luminous Energy Since Turn On org.bluetooth.property.luminous_energy_since_turn_on 0x003F Luminous Energy 4 - * Luminous Exposure org.bluetooth.property.luminous_exposure 0x0040 Luminous Exposure 4 - * Luminous Flux Range org.bluetooth.property.luminous_flux_range 0x0041 Luminous Flux Range 4 - * Motion Sensed org.bluetooth.property.motion_sensed 0x0042 Percentage 8 1 - * Motion Threshold org.bluetooth.property.motion_threshold 0x0043 Percentage 8 1 - * Open Circuit Event Statistics org.bluetooth.property.open_circuit_event_statistics 0x0044 Event Statistics 6 - * Outdoor Statistical Values org.bluetooth.property.outdoor_statistical_values 0x0045 Temperature 8 Statistics 5 - * Output Current Range org.bluetooth.property.output_current_range 0x0046 Electric Current Range 4 - * Output Current Statistics org.bluetooth.property.output_current_statistics 0x0047 Electric Current Statistics 9 - * Output Ripple Voltage Specification org.bluetooth.property.output_ripple_voltage_specification 0x0048 Percentage 8 1 - * Output Voltage Range org.bluetooth.property.output_voltage_range 0x0049 Voltage Specification 6 - * Output Voltage Statistics org.bluetooth.property.output_voltage_statistics 0x004A Voltage Statistics 9 - * Over Output Ripple Voltage Event Statistics org.bluetooth.property.over_output_ripple_voltage_event_statistics 0x004B Event Statistics 6 - * People Count org.bluetooth.property.people_count 0x004C Count 16 2 - * Presence Detected org.bluetooth.property.presence_detected 0x004D Boolean 1 - * Present Ambient Light Level org.bluetooth.property.present_ambient_light_level 0x004E Illuminance 4 - * Present Ambient Temperature org.bluetooth.property.present_ambient_temperature 0x004F Temperature 8 1 - * Present CIE 1931 Chromaticity Coordinates org.bluetooth.property.present_cie_1931_chromaticity 0x0050 Chromaticity Coordinates 4 - * Present Correlated Color Temperature org.bluetooth.property.present_correlated_color_temperature 0x0051 Correlated Color Temperature 2 - * Present Device Input Power org.bluetooth.property.present_device_input_power 0x0052 Power 4 - * Present Device Operating Efficiency org.bluetooth.property.present_device_operating_efficiency 0x0053 Percentage 8 1 - * Present Device Operating Temperature org.bluetooth.property.present_device_operating_temperature 0x0054 Temperature 2 - * Present Illuminance org.bluetooth.property.present_illuminance 0x0055 Illuminance 4 - * Present Indoor Ambient Temperature org.bluetooth.property.present_indoor_ambient_temperature 0x0056 Temperature 8 1 - * Present Input Current org.bluetooth.property.present_input_current 0x0057 Electric Current 2 - * Present Input Ripple Voltage org.bluetooth.property.present_input_ripple_voltage 0x0058 Percentage 8 1 - * Present Input Voltage org.bluetooth.property.present_input_voltage 0x0059 Voltage 2 - * Present Luminous Flux org.bluetooth.property.present_luminous_flux 0x005A Luminous Flux 2 - * Present Outdoor Ambient Temperature org.bluetooth.property.present_outdoor_ambient_temperature 0x005B Temperature 8 1 - * Present Output Current org.bluetooth.property.present_output_current 0x005C Electric Current 2 - * Present Output Voltage org.bluetooth.property.present_output_voltage 0x005D Voltage 2 - * Present Planckian Distance org.bluetooth.property.present_planckian_distance 0x005E Chromatic Distance From Planckian 2 - * Present Relative Output Ripple Voltage org.bluetooth.property.present_relative_output_ripple_voltage 0x005F Percentage 8 1 - * Relative Device Energy Use In A Period Of Day org.bluetooth.property.relative_device_energy_use_in_a_period_of_day 0x0060 Energy In A Period Of Day 6 - * Relative Device Runtime In A Generic Level Range org.bluetooth.property.relative_device_runtime_in_a_generic_level_range 0x0061 Relative Runtime In A Generic Level Range 5 - * Relative Exposure Time In An Illuminance Range org.bluetooth.property.relative_exposure_time_in_an_illuminance_range 0x0062 Relative Value In An Illuminance Range 9 - * Relative Runtime In A Correlated Color Temperature Range org.bluetooth.property.relative_runtime_in_a_correlated_color_temperature_range 0x0063 Luminous Energy 4 - * Relative Runtime In A Device Operating Temperature Range org.bluetooth.property.relative_runtime_in_a_device_operating_temperature_range 0x0064 Relative Value In A Temperature Range 5 - * Relative Runtime In An Input Current Range org.bluetooth.property.relative_runtime_in_an_input_current_range 0x0065 Relative Runtime In A Current Range 5 - * Relative Runtime In An Input Voltage Range org.bluetooth.property.relative_runtime_in_an_input_voltage_range 0x0066 Relative Value In A Voltage Range 5 - * Short Circuit Event Statistics org.bluetooth.property.short_circuit_event_statistics 0x0067 Event Statistics 6 - * Time Since Motion Sensed org.bluetooth.property.time_since_motion_sensed 0x0068 Time Second 16 2 - * Time Since Presence Detected org.bluetooth.property.time_since_presence_detected 0x0069 Time Second 16 2 - * Total Device Energy Use org.bluetooth.property.total_device_energy_use 0x006A Energy 4 - * Total Device Off On Cycles org.bluetooth.property.total_device_off_on_cycles 0x006B Count 24 4 - * Total Device Power On Cycles org.bluetooth.property.total_device_power_on_cycles 0x006C Count 24 4 - * Total Device Power On Time org.bluetooth.property.total_device_power_on_time 0x006D Time Hour 24 4 - * Total Device Runtime org.bluetooth.property.total_device_runtime 0x006E Time Hour 24 4 - * Total Light Exposure Time org.bluetooth.property.total_light_exposure_time 0x006F Time Hour 24 4 - * Total Luminous Energy org.bluetooth.property.total_luminous_energy 0x0070 Luminous Energy 4 - */ - -/** - * Characteristics referenced by BLE Mesh Device Properties. - * - * Name Uniform Type Identifier Assigned Number Specification Level - * Average Current org.bluetooth.characteristic.average_current 2AE0 Adopted - * Average Voltage org.bluetooth.characteristic.average_voltage 2AE1 Adopted - * Boolean org.bluetooth.characteristic.boolean 2AE2 Adopted - * Chromatic Distance From Planckian org.bluetooth.characteristic.chromatic_distance_from_planckian 2AE3 Adopted - * Chromaticity Coordinate org.bluetooth.characteristic.chromaticity_coordinate 2B1C Adopted - * Chromaticity Coordinates org.bluetooth.characteristic.chromaticity_coordinates 2AE4 Adopted - * Chromaticity In CCT And Duv Values org.bluetooth.characteristic.chromaticity_in_cct_and_duv_values 2AE5 Adopted - * Chromaticity Tolerance org.bluetooth.characteristic.chromaticity_tolerance 2AE6 Adopted - * CIE 13.3-1995 Color Rendering Index org.bluetooth.characteristic.cie_13.3-1995_color_rendering_index 2AE7 Adopted - * Coefficient org.bluetooth.characteristic.coefficient 2AE8 Adopted - * Correlated Color Temperature org.bluetooth.characteristic.correlated_color_temperature 2AE9 Adopted - * Count 16 org.bluetooth.characteristic.count_16 2AEA Adopted - * Count 24 org.bluetooth.characteristic.count_24 2AEB Adopted - * Country Code org.bluetooth.characteristic.country_code 2AEC Adopted - * Date UTC org.bluetooth.characteristic.date_utc 2AED Adopted - * Electric Current org.bluetooth.characteristic.electric_current 2AEE Adopted - * Electric Current Range org.bluetooth.characteristic.electric_current_range 2AEF Adopted - * Electric Current Specification org.bluetooth.characteristic.electric_current_specification 2AF0 Adopted - * Electric Current Statistics org.bluetooth.characteristic.electric_current_statistics 2AF1 Adopted - * Energy org.bluetooth.characteristic.energy 2AF2 Adopted - * Energy In A Period Of Day org.bluetooth.characteristic.energy_in_a_period_of_day 2AF3 Adopted - * Event Statistics org.bluetooth.characteristic.event_statistics 2AF4 Adopted - * Fixed String 16 org.bluetooth.characteristic.fixed_string_16 2AF5 Adopted - * Fixed String 24 org.bluetooth.characteristic.fixed_string_24 2AF6 Adopted - * Fixed String 36 org.bluetooth.characteristic.fixed_string_36 2AF7 Adopted - * Fixed String 8 org.bluetooth.characteristic.fixed_string_8 2AF8 Adopted - * Generic Level org.bluetooth.characteristic.generic_level 2AF9 Adopted - * Global Trade Item Number org.bluetooth.characteristic.global_trade_item_number 2AFA Adopted - * Illuminance org.bluetooth.characteristic.illuminance 2AFB Adopted - * Luminous Efficacy org.bluetooth.characteristic.luminous_efficacy 2AFC Adopted - * Luminous Energy org.bluetooth.characteristic.luminous_energy 2AFD Adopted - * Luminous Exposure org.bluetooth.characteristic.luminous_exposure 2AFE Adopted - * Luminous Flux org.bluetooth.characteristic.luminous_flux 2AFF Adopted - * Luminous Flux Range org.bluetooth.characteristic.luminous_flux_range 2B00 Adopted - * Luminous Intensity org.bluetooth.characteristic.luminous_intensity 2B01 Adopted - * Mass Flow org.bluetooth.characteristic.mass_flow 2B02 Adopted - * Mesh Provisioning Data In org.bluetooth.characteristic.mesh_provisioning_data_in 2ADB Adopted - * Mesh Provisioning Data Out org.bluetooth.characteristic.mesh_provisioning_data_out 2ADC Adopted - * Mesh Proxy Data In org.bluetooth.characteristic.mesh_proxy_data_in 2ADD Adopted - * Mesh Proxy Data Out org.bluetooth.characteristic.mesh_proxy_data_out 2ADE Adopted - * Perceived Lightness org.bluetooth.characteristic.perceived_lightness 2B03 Adopted - * Percentage 8 org.bluetooth.characteristic.percentage_8 2B04 Adopted - * Power org.bluetooth.characteristic.power 2B05 Adopted - * Power Specification org.bluetooth.characteristic.power_specification 2B06 Adopted - * Relative Runtime In A Current Range org.bluetooth.characteristic.relative_runtime_in_a_current_range 2B07 Adopted - * Relative Runtime In A Generic Level Range org.bluetooth.characteristic.relative_runtime_in_a_generic_level_range 2B08 Adopted - * Relative Value In A Period of Day org.bluetooth.characteristic.relative_value_in_a_period_of_day 2B0B Adopted - * Relative Value In A Temperature Range org.bluetooth.characteristic.relative_value_in_a_temperature_range 2B0C Adopted - * Relative Value In A Voltage Range org.bluetooth.characteristic.relative_value_in_a_voltage_range 2B09 Adopted - * Relative Value In An Illuminance Range org.bluetooth.characteristic.relative_value_in_an_illuminance_range 2B0A Adopted - * Temperature 8 org.bluetooth.characteristic.temperature_8 2B0D Adopted - * Temperature 8 In A Period Of Day org.bluetooth.characteristic.temperature_8_in_a_period_of_day 2B0E Adopted - * Temperature 8 Statistics org.bluetooth.characteristic.temperature_8_statistics 2B0F Adopted - * Temperature Range org.bluetooth.characteristic.temperature_range 2B10 Adopted - * Temperature Statistics org.bluetooth.characteristic.temperature_statistics 2B11 Adopted - * Time Decihour 8 org.bluetooth.characteristic.time_decihour_8 2B12 Adopted - * Time Exponential 8 org.bluetooth.characteristic.time_exponential_8 2B13 Adopted - * Time Hour 24 org.bluetooth.characteristic.time_hour_24 2B14 Adopted - * Time Millisecond 24 org.bluetooth.characteristic.time_millisecond_24 2B15 Adopted - * Time Second 16 org.bluetooth.characteristic.time_second_16 2B16 Adopted - * Time Second 8 org.bluetooth.characteristic.time_second_8 2B17 Adopted - * Voltage org.bluetooth.characteristic.voltage 2B18 Adopted - * Voltage Specification org.bluetooth.characteristic.voltage_specification 2B19 Adopted - * Voltage Statistics org.bluetooth.characteristic.voltage_statistics 2B1A Adopted - * Volume Flow org.bluetooth.characteristic.volume_flow 2B1B Adopted - */ - -/** - * @brief BLE Mesh Device Property IDs - */ -#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY 0x0001 -#define BLE_MESH_AVERAGE_INPUT_CURRENT 0x0002 -#define BLE_MESH_AVERAGE_INPUT_VOLTAGE 0x0003 -#define BLE_MESH_AVERAGE_OUTPUT_CURRENT 0x0004 -#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE 0x0005 -#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER 0x0006 -#define BLE_MESH_CHROMATICITY_TOLERANCE 0x0007 -#define BLE_MESH_COLOR_RENDERING_INDEX_R9 0x0008 -#define BLE_MESH_COLOR_RENDERING_INDEX_RA 0x0009 -#define BLE_MESH_DEVICE_APPEARANCE 0x000A -#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN 0x000B -#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE 0x000C -#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON 0x000D -#define BLE_MESH_DEVICE_FIRMWARE_REVISION 0x000E -#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER 0x000F -#define BLE_MESH_DEVICE_HARDWARE_REVISION 0x0010 -#define BLE_MESH_DEVICE_MANUFACTURER_NAME 0x0011 -#define BLE_MESH_DEVICE_MODEL_NUMBER 0x0012 -#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION 0x0013 -#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES 0x0014 -#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS 0x0015 -#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION 0x0016 -#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON 0x0017 -#define BLE_MESH_DEVICE_RUNTIME_WARRANTY 0x0018 -#define BLE_MESH_DEVICE_SERIAL_NUMBER 0x0019 -#define BLE_MESH_DEVICE_SOFTWARE_REVISION 0x001A -#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS 0x001B -#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES 0x001C -#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES 0x001D -#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE 0x001E -#define BLE_MESH_INITIAL_LUMINOUS_FLUX 0x001F -#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE 0x0020 -#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION 0x0021 -#define BLE_MESH_INPUT_CURRENT_STATISTICS 0x0022 -#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS 0x0023 -#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x0024 -#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS 0x0025 -#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS 0x0026 -#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS 0x0027 -#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION 0x0028 -#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION 0x0029 -#define BLE_MESH_INPUT_VOLTAGE_STATISTICS 0x002A -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON 0x002B -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG 0x002C -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY 0x002D -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON 0x002E -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG 0x002F -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY 0x0030 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY 0x0031 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID 0x0032 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU 0x0033 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD 0x0034 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU 0x0035 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE 0x0036 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON 0x0037 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO 0x0038 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL 0x0039 -#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY 0x003A -#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG 0x003B -#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON 0x003C -#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR 0x003D -#define BLE_MESH_LUMINOUS_EFFICACY 0x003E -#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON 0x003F -#define BLE_MESH_LUMINOUS_EXPOSURE 0x0040 -#define BLE_MESH_LUMINOUS_FLUX_RANGE 0x0041 -#define BLE_MESH_MOTION_SENSED 0x0042 -#define BLE_MESH_MOTION_THRESHOLD 0x0043 -#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS 0x0044 -#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES 0x0045 -#define BLE_MESH_OUTPUT_CURRENT_RANGE 0x0046 -#define BLE_MESH_OUTPUT_CURRENT_STATISTICS 0x0047 -#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION 0x0048 -#define BLE_MESH_OUTPUT_VOLTAGE_RANGE 0x0049 -#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS 0x004A -#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x004B -#define BLE_MESH_PEOPLE_COUNT 0x004C -#define BLE_MESH_PRESENCE_DETECTED 0x004D -#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL 0x004E -#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE 0x004F -#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY 0x0050 -#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE 0x0051 -#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER 0x0052 -#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY 0x0053 -#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE 0x0054 -#define BLE_MESH_PRESENT_ILLUMINANCE 0x0055 -#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE 0x0056 -#define BLE_MESH_PRESENT_INPUT_CURRENT 0x0057 -#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE 0x0058 -#define BLE_MESH_PRESENT_INPUT_VOLTAGE 0x0059 -#define BLE_MESH_PRESENT_LUMINOUS_FLUX 0x005A -#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE 0x005B -#define BLE_MESH_PRESENT_OUTPUT_CURRENT 0x005C -#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE 0x005D -#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE 0x005E -#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE 0x005F -#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY 0x0060 -#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE 0x0061 -#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE 0x0062 -#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE 0x0063 -#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE 0x0064 -#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE 0x0065 -#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE 0x0066 -#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS 0x0067 -#define BLE_MESH_TIME_SINCE_MOTION_SENSED 0x0068 -#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED 0x0069 -#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE 0x006A -#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES 0x006B -#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES 0x006C -#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME 0x006D -#define BLE_MESH_TOTAL_DEVICE_RUNTIME 0x006E -#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME 0x006F -#define BLE_MESH_TOTAL_LUMINOUS_ENERGY 0x0070 - -/** - * @brief BLE Mesh Device Property value length - */ -#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY_LEN 0x03 -#define BLE_MESH_AVERAGE_INPUT_CURRENT_LEN 0x03 -#define BLE_MESH_AVERAGE_INPUT_VOLTAGE_LEN 0x03 -#define BLE_MESH_AVERAGE_OUTPUT_CURRENT_LEN 0x03 -#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE_LEN 0x03 -#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER_LEN 0x02 -#define BLE_MESH_CHROMATICITY_TOLERANCE_LEN 0x01 -#define BLE_MESH_COLOR_RENDERING_INDEX_R9_LEN 0x01 -#define BLE_MESH_COLOR_RENDERING_INDEX_RA_LEN 0x01 -#define BLE_MESH_DEVICE_APPEARANCE_LEN 0x02 -#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN_LEN 0x02 -#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE_LEN 0x04 -#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON_LEN 0x04 -#define BLE_MESH_DEVICE_FIRMWARE_REVISION_LEN 0x08 -#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER_LEN 0x08 -#define BLE_MESH_DEVICE_HARDWARE_REVISION_LEN 0x16 -#define BLE_MESH_DEVICE_MANUFACTURER_NAME_LEN 0x36 -#define BLE_MESH_DEVICE_MODEL_NUMBER_LEN 0x24 -#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION_LEN 0x04 -#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES_LEN 0x09 -#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION_LEN 0x12 -#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON_LEN 0x04 -#define BLE_MESH_DEVICE_RUNTIME_WARRANTY_LEN 0x04 -#define BLE_MESH_DEVICE_SERIAL_NUMBER_LEN 0x16 -#define BLE_MESH_DEVICE_SOFTWARE_REVISION_LEN 0x08 -#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES_LEN 0x05 -#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES_LEN 0x04 -#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE_LEN 0x02 -#define BLE_MESH_INITIAL_LUMINOUS_FLUX_LEN 0x02 -#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE_LEN 0x02 -#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION_LEN 0x06 -#define BLE_MESH_INPUT_CURRENT_STATISTICS_LEN 0x09 -#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION_LEN 0x06 -#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION_LEN 0x01 -#define BLE_MESH_INPUT_VOLTAGE_STATISTICS_LEN 0x09 -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON_LEN 0x02 -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG_LEN 0x02 -#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY_LEN 0x02 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY_LEN 0x01 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU_LEN 0x04 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG_LEN 0x03 -#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON_LEN 0x03 -#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR_LEN 0x01 -#define BLE_MESH_LUMINOUS_EFFICACY_LEN 0x02 -#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON_LEN 0x04 -#define BLE_MESH_LUMINOUS_EXPOSURE_LEN 0x04 -#define BLE_MESH_LUMINOUS_FLUX_RANGE_LEN 0x04 -#define BLE_MESH_MOTION_SENSED_LEN 0x01 -#define BLE_MESH_MOTION_THRESHOLD_LEN 0x01 -#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES_LEN 0x05 -#define BLE_MESH_OUTPUT_CURRENT_RANGE_LEN 0x04 -#define BLE_MESH_OUTPUT_CURRENT_STATISTICS_LEN 0x09 -#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION_LEN 0x01 -#define BLE_MESH_OUTPUT_VOLTAGE_RANGE_LEN 0x06 -#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS_LEN 0x09 -#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_PEOPLE_COUNT_LEN 0x02 -#define BLE_MESH_PRESENCE_DETECTED_LEN 0x01 -#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL_LEN 0x04 -#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE_LEN 0x01 -#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY_LEN 0x04 -#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE_LEN 0x02 -#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER_LEN 0x04 -#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY_LEN 0x01 -#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE_LEN 0x02 -#define BLE_MESH_PRESENT_ILLUMINANCE_LEN 0x04 -#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE_LEN 0x01 -#define BLE_MESH_PRESENT_INPUT_CURRENT_LEN 0x02 -#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE_LEN 0x01 -#define BLE_MESH_PRESENT_INPUT_VOLTAGE_LEN 0x02 -#define BLE_MESH_PRESENT_LUMINOUS_FLUX_LEN 0x02 -#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE_LEN 0x01 -#define BLE_MESH_PRESENT_OUTPUT_CURRENT_LEN 0x02 -#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE_LEN 0x02 -#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE_LEN 0x02 -#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE_LEN 0x01 -#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY_LEN 0x06 -#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_LEN 0x05 -#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE_LEN 0x09 -#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE_LEN 0x04 -#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE_LEN 0x05 -#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE_LEN 0x05 -#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE_LEN 0x05 -#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS_LEN 0x06 -#define BLE_MESH_TIME_SINCE_MOTION_SENSED_LEN 0x02 -#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED_LEN 0x02 -#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE_LEN 0x04 -#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES_LEN 0x04 -#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES_LEN 0x04 -#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME_LEN 0x04 -#define BLE_MESH_TOTAL_DEVICE_RUNTIME_LEN 0x04 -#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME_LEN 0x04 -#define BLE_MESH_TOTAL_LUMINOUS_ENERGY_LEN 0x04 - -/** - * @brief BLE Mesh Device Property referenced Characteristic UUIDs - */ -#define BLE_MESH_UUID_AVERAGE_CURRENT_VAL 0x2AE0 -#define BLE_MESH_UUID_AVERAGE_VOLTAGE_VAL 0x2AE1 -#define BLE_MESH_UUID_BOOLEAN_VAL 0x2AE2 -#define BLE_MESH_UUID_CHROMATIC_DISTANCE_FROM_PLANCKIAN_VAL 0x2AE3 -#define BLE_MESH_UUID_CHROMATICITY_COORDINATE_VAL 0x2B1C -#define BLE_MESH_UUID_CHROMATICITY_COORDINATES_VAL 0x2AE4 -#define BLE_MESH_UUID_CHROMATICITY_IN_CCT_AND_DUV_VALUES_VAL 0x2AE5 -#define BLE_MESH_UUID_CHROMATICITY_TOLERANCE_VAL 0x2AE6 -#define BLE_MESH_UUID_CIE_13_3_1995_COLOR_RENDERING_INDEX_VAL 0x2AE7 -#define BLE_MESH_UUID_COEFFICIENT_VAL 0x2AE8 -#define BLE_MESH_UUID_CORRELATED_COLOR_TEMPERATURE_VAL 0x2AE9 -#define BLE_MESH_UUID_COUNT_16_VAL 0x2AEA -#define BLE_MESH_UUID_COUNT_24_VAL 0x2AEB -#define BLE_MESH_UUID_COUNTRY_CODE_VAL 0x2AEC -#define BLE_MESH_UUID_DATE_UTC_VAL 0x2AED -#define BLE_MESH_UUID_ELECTRIC_CURRENT_VAL 0x2AEE -#define BLE_MESH_UUID_ELECTRIC_CURRENT_RANGE_VAL 0x2AEF -#define BLE_MESH_UUID_ELECTRIC_CURRENT_SPECIFICATION_VAL 0x2AF0 -#define BLE_MESH_UUID_ELECTRIC_CURRENT_STATISTICS_VAL 0x2AF1 -#define BLE_MESH_UUID_ENERGY_VAL 0x2AF2 -#define BLE_MESH_UUID_ENERGY_IN_A_PERIOD_OF_DAY_VAL 0x2AF3 -#define BLE_MESH_UUID_EVENT_STATISTICS_VAL 0x2AF4 -#define BLE_MESH_UUID_FIXED_STRING_16_VAL 0x2AF5 -#define BLE_MESH_UUID_FIXED_STRING_24_VAL 0x2AF6 -#define BLE_MESH_UUID_FIXED_STRING_36_VAL 0x2AF7 -#define BLE_MESH_UUID_FIXED_STRING_8_VAL 0x2AF8 -#define BLE_MESH_UUID_GENERIC_LEVEL_VAL 0x2AF9 -#define BLE_MESH_UUID_GLOBAL_TRADE_ITEM_NUMBER_VAL 0x2AFA -#define BLE_MESH_UUID_ILLUMINANCE_VAL 0x2AFB -#define BLE_MESH_UUID_LUMINOUS_EFFICACY_VAL 0x2AFC -#define BLE_MESH_UUID_LUMINOUS_ENERGY_VAL 0x2AFD -#define BLE_MESH_UUID_LUMINOUS_EXPOSURE_VAL 0x2AFE -#define BLE_MESH_UUID_LUMINOUS_FLUX_VAL 0x2AFF -#define BLE_MESH_UUID_LUMINOUS_FLUX_RANGE_VAL 0x2B00 -#define BLE_MESH_UUID_LUMINOUS_INTENSITY_VAL 0x2B01 -#define BLE_MESH_UUID_MASS_FLOW_VAL 0x2B02 -/** - * The following four have been defined in mesh_uuid.h - * #define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2ADB - * #define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2ADC - * #define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2ADD - * #define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ADE - */ -#define BLE_MESH_UUID_PERCEIVED_LIGHTNESS_VAL 0x2B03 -#define BLE_MESH_UUID_PERCENTAGE_8_VAL 0x2B04 -#define BLE_MESH_UUID_POWER_VAL 0x2B05 -#define BLE_MESH_UUID_POWER_SPECIFICATION_VAL 0x2B06 -#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_CURRENT_RANGE_VAL 0x2B07 -#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_VAL 0x2B08 -#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_PERIOD_OF_DAY_VAL 0x2B0B -#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_TEMPERATURE_RANGE_VAL 0x2B0C -#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_VOLTAGE_RANGE_VAL 0x2B09 -#define BLE_MESH_UUID_RELATIVE_VALUE_IN_AN_ILLUMINANCE_RANGE_VAL 0x2B0A -#define BLE_MESH_UUID_TEMPERATURE_8_VAL 0x2B0D -#define BLE_MESH_UUID_TEMPERATURE_8_IN_A_PERIOD_OF_DAY_VAL 0x2B0E -#define BLE_MESH_UUID_TEMPERATURE_8_STATISTICS_VAL 0x2B0F -#define BLE_MESH_UUID_TEMPERATURE_RANGE_VAL 0x2B10 -#define BLE_MESH_UUID_TEMPERATURE_STATISTICS_VAL 0x2B11 -#define BLE_MESH_UUID_TIME_DECIHOUR_8_VAL 0x2B12 -#define BLE_MESH_UUID_TIME_EXPONENTIAL_8_VAL 0x2B13 -#define BLE_MESH_UUID_TIME_HOUR_24_VAL 0x2B14 -#define BLE_MESH_UUID_TIME_MILLISECOND_24_VAL 0x2B15 -#define BLE_MESH_UUID_TIME_SECOND_16_VAL 0x2B16 -#define BLE_MESH_UUID_TIME_SECOND_8_VAL 0x2B17 -#define BLE_MESH_UUID_VOLTAGE_VAL 0x2B18 -#define BLE_MESH_UUID_VOLTAGE_SPECIFICATION_VAL 0x2B19 -#define BLE_MESH_UUID_VOLTAGE_STATISTICS_VAL 0x2B1A -#define BLE_MESH_UUID_VOLUME_FLOW_VAL 0x2B1B - -/** - * @brief BLE Mesh Device Property referenced Characteristic Type Definitions - */ - -/* Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius. */ -typedef s16_t bt_mesh_temperature_t; - -typedef u16_t bt_mesh_gap_appearance_t; - -/* Mesh Characteristics Type Definitions */ - -/* This characteristic represents an electric current. - * Note: Unit is ampere with a resolution of 0.01. - * Minimum value: 0, maximum value: 655.34; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_electric_current_t; - -/* The Time Exponential 8 characteristic is used to represent a measure of period of - * time in seconds. - * Note: The time duration is given by the value 1.1^(N-64) in seconds, with N being - * the raw 8-bit value; - * Minimum value: 0.0, maximum value: 73216705; - * A raw value of 0x00 represents 0 seconds, and a raw value of 0xFF represents - * the total life of the device. - */ -typedef u8_t bt_mesh_time_exponential_8_t; - -/* The Voltage characteristic is used to represent a measure of positive electric - * potential difference in units of volts. - * Note: Unit is volt with a resolution of 1/64V; - * Minimum value: 0.0, maximum value: 1022.0; - * A value of 0xFFFF represents 'value is not known'. The minimum representable - * value represents the minimum value or lower, the maximum representable value - * represents the maximum value or higher. - */ -typedef u16_t bt_mesh_voltage_t; - -/* This characteristic aggregates the Electric Current characteristic and instance of - * the Time Exponential 8 characteristic. - */ -typedef struct __packed average_current { - bt_mesh_electric_current_t electric_current; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_average_current_t; - -/* This characteristic aggregates the Voltage characteristic and instance of the Time - * Exponential 8 characteristic. - */ -typedef struct __packed average_voltage { - bt_mesh_voltage_t voltage; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_average_voltage_t; - -/* The Boolean characteristic defines the predefined Boolean values as an enumeration. - * Key | Value - * 0 | False - * 1 | True - * 2 to 255 | Prohibited - */ -typedef u8_t bt_mesh_boolean_t; - -/* The Chromatic Distance From Planckian characteristic represents a distance of a - * chromaticity coordinate from the Planckian locus in the (u',2/3 v') diagram as - * defined by ANSI standard C78.377-2008. The distance is positive if the chromaticity - * coordinate is located above the Planckian locus (i.e. has as higher y value than the - * Planckian), and negative if it is located below. The distance is only valid within - * the range from -0.05 to 0.05. - * Note: Unit is unitless with a resolution of 0.00001; - * Minimum value: -0.05, maximum value: 0.05; - * A value of 0xFFFF represents 'value is not known'; - * A value of 0xFFFE represents 'value is not valid'. - */ -typedef s16_t bt_mesh_chromatic_distance_from_planckian_t; - -/* This characteristic represents a chromaticity coordinate in a color diagram such as - * the CIE1931 diagram. It can represent an x or y coordinate. - * Note: Unit is unitless with a resolution of 1/65535; - * Minimum value: 0, maximum value: 1.0. - */ -typedef u16_t bt_mesh_chromaticity_coordinate_t; - -/* This characteristic represents a chromaticity coordinate as a tuple with an x and - * y coordinate. - */ -typedef struct __packed chromaticity_coordinates { - bt_mesh_chromaticity_coordinate_t chromaticity_x_coordinate; - bt_mesh_chromaticity_coordinate_t chromaticity_y_coordinate; -} bt_mesh_chromaticity_coordinates_t; - -/* The Correlated Color Temperature characteristic is used to represent correlated color - * temperature in a range from 800 to 65534 Kelvin with a resolution of 1 Kelvin. - * Note: Unit is Kelvin with a resolution of 1; - * Minimum value: 800, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_correlated_color_temperature_t; - -/* The Chromaticity In CCT And Duv Values characteristic is a composite characteristic - * consisting of the Correlated Color Temperature characteristic and the Chromatic - * Distance From Planckian characteristic. - */ -typedef struct __packed chromaticity_in_cct_and_duv_values { - bt_mesh_correlated_color_temperature_t correlated_color_temperature; - bt_mesh_chromatic_distance_from_planckian_t chromaticity_distance_from_planckian; -} bt_mesh_chromaticity_in_cct_and_duv_values_t; - -/* The Chromaticity Tolerance characteristic is a tolerance of a tuple of chromaticity - * values represented as a value of a radius of a circle in the CIE 1976 (u',v') diagram; - * value corresponding to the 3-sigma values of the expected chromaticity deviations. - * Note: Unit is unitless with a resolution of 0.0001; - * Minimum value: 0, maximum value: 0.0255. - */ -typedef u8_t bt_mesh_chromaticity_tolerance_t; - -/* The CIE 13.3-1995 Color Rendering Index characteristic is a color rendition index value - * for a color patch as calculated in accordance with the CIE 13.3-1995 standard. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: -128, maximum value: 100. - */ -typedef s8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; - -/* The Coefficient characteristic is used to represent a general coefficient value. */ -typedef float bt_mesh_coefficient_t; - -/* The Count 16 characteristic is used to represent a general count value. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: 0, maximum value 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_count_16_t; - -/* The Count 24 characteristic is used to represent a general count value. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: 0, maximum value 16777214; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_count_24_t[3]; - -/* This characteristic represents a country or dependent areas in accordance with - * the ISO 3166-1 Numeric standard. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: 0, maximum value: 4095; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_country_code_t; - -/* Date as days elapsed since the Epoch (Jan 1, 1970) in the Coordinated Universal - * Time (UTC) time zone. - * Note: Unit is a day with a resolution of 1; - * Minimum value: 1, maximum value: 16777214; - * A value of 0x000000 represents 'value is not known'. - */ -typedef u8_t bt_mesh_date_utc_t[3]; - -/* This characteristic aggregates two instances of the Electric Current characteristic - * to represent a range of Electric Current values. - */ -typedef struct __packed electric_current_range { - bt_mesh_electric_current_t minimum_electric_current_value; - bt_mesh_electric_current_t maximum_electric_current_value; -} bt_mesh_electric_current_range_t; - -/* This characteristic aggregates three instances of the Electric Current characteristic - * to represent a specification of electric current values. - */ -typedef struct __packed electric_current_specification { - bt_mesh_electric_current_t minimum_electric_current_value; - bt_mesh_electric_current_t typical_electric_current_value; - bt_mesh_electric_current_t maximum_electric_current_value; -} bt_mesh_electric_current_specification_t; - -/* This characteristic aggregates four instances of the Electric Current characteristic - * with a Sensing Duration to represent a set of statistical electric current values. - */ -typedef struct __packed electric_current_statistics { - bt_mesh_electric_current_t average_electric_current_value; - bt_mesh_electric_current_t standard_electric_current_value; - bt_mesh_electric_current_t minimum_electric_current_value; - bt_mesh_electric_current_t maximum_electric_current_value; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_electric_current_statistics_t; - -/* The Energy characteristic is used to represent a measure of energy in units of - * kilowatt hours. - * Note: Unit is kilowatt-hour with a resolution of 1; - * Minimum value: 0, maximum value: 16777214; - * A value of 0xFFFFFF represents ‘value is not known’. - */ -typedef u8_t bt_mesh_energy_t[3]; - -/* The Time Decihour 8 characteristic is used to represent a period of time in - * tenths of an hour. - * Note: Unit is hour with a resolution of 0.1; - * Minimum value: 0.0, maximum value: 24.0; - * A value of 0xFF represents 'value is not known'. All other values are Prohibited. - */ -typedef u8_t bt_mesh_time_decihour_8_t; - -/* This characteristic aggregates the Energy characteristic, and two instances of - * the Time Decihour 8 characteristic, to represent energy use in a period of day. - */ -typedef struct __packed energy_in_a_period_of_day { - bt_mesh_energy_t energy_value; - bt_mesh_time_decihour_8_t start_time; - bt_mesh_time_decihour_8_t end_time; -} bt_mesh_energy_in_a_period_of_day_t; - -/* The Time Second 16 characteristic is used to represent a period of time with a - * unit of 1 second. - * Note: Unit is second with a resolution of 1; - * Minimum value: 0, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_time_second_16_t; - -/* This characteristic aggregates the Count 16 characteristic, two instances of the - * Time Decihour 8 characteristic and an instance of the Sensing Duration characteristic, - * to represent statistical values of events. - */ -typedef struct __packed event_statistics { - bt_mesh_count_16_t number_of_events; - bt_mesh_time_second_16_t average_event_duration; - bt_mesh_time_exponential_8_t time_elapsed_since_last_event; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_event_statistics_t; - -/* The Fixed String 16 characteristic represents a 16-octet UTF-8 string. */ -typedef char bt_mesh_fixed_string_16_t[16]; - -/* The Fixed String 24 characteristic represents a 24-octet UTF-8 string. */ -typedef char bt_mesh_fixed_string_24_t[24]; - -/* The Fixed String 36 characteristic represents a 36-octet UTF-8 string. */ -typedef char bt_mesh_fixed_string_36_t[36]; - -/* The Fixed String 8 characteristic represents an 8-octet UTF-8 string. */ -typedef char bt_mesh_fixed_string_8_t[8]; - -/* The Generic Level characteristic represents a general level value of a - * setting of a device. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: 0, maximum value: 65535. - */ -typedef u16_t bt_mesh_generic_level_t; - -/* The Global Trade Item Number characteristic represents an identifier as - * issued by GS1 General Specifications, which may consist up to 14 digits, - * and is here represented as a 48-bit unsigned integer. - */ -typedef u8_t bt_mesh_global_trade_item_number_t[6]; - -/* The Illuminance characteristic is used to represent a measure of illuminance - * in units of lux. - * Note: Unit is lux with a resolution of 0.01; - * Minimum value: 0, maximum value: 167772.14; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_illuminance_t[3]; - -/* The Luminous Efficacy characteristic is used to represent a measure of luminous - * efficacy in units of lumen per watt. - * Note: Unit is lumen per watt with a resolution of 0.1; - * Minimum value: 0, maximum value: 1800; - * A value of 0xFFFF represents 'value is not known'. All other values are Prohibited. - */ -typedef u16_t bt_mesh_luminous_efficacy_t; - -/* The Luminous Energy characteristic is used to represent a measure of luminous - * energy in units of lumen hour. - * Note: Unit is lumen hour with a resolution of 1000; - * Minimum value: 0, maximum value: 16777214000; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_luminous_energy_t[3]; - -/* The Luminous Exposure characteristic is used to represent a measure of luminous - * exposure in units of lux-hour. - * Note: Unit is lux hour with a resolution of 1000; - * Minimum value: 0, maximum value: 16777214000; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_luminous_exposure_t[3]; - -/* The Luminous Flux characteristic is used to represent a measure of luminous flux - * in units of lumen. - * Note: Unit is lumen with a resolution of 1; - * Minimum value: 0, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_luminous_flux_t; - -/* This characteristic aggregates two instances of the Luminous Flux characteristic - * to represent a luminous flux range. - */ -typedef struct __packed luminous_flux_range { - bt_mesh_luminous_flux_t minimum_luminous_flux; - bt_mesh_luminous_flux_t maximum_luminous_flux; -} bt_mesh_luminous_flux_range_t; - -/* The Luminous Intensity characteristic is used to represent a luminous intensity of - * a beam of light in units of candela. - * Note: Unit is candela with a resolution of 1; - * Minimum value: 0, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_luminous_intensity_t; - -/* The Mass Flow characteristic is used to represent a flow of mass. - * Note: Unit is gram/second with a resolution of 1; - * Minimum value: 0, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_mass_flow_t; - -/* The Mesh Provisioning Data In characteristic can be written to send a Proxy PDU - * message containing Provisioning PDU to the Provisioning Server. - */ -struct mesh_provisioning_data_in { - -}; - -/* The Mesh Provisioning Data Out characteristic can be notified to send a Proxy PDU - * message containing Provisioning PDU from a Provisioning Server to a Provisioning Client. - */ -struct mesh_provisioning_data_out { - -}; - -/* The Mesh Proxy Data In characteristic is used by the client to send Proxy PDUs to - * the server. - */ -struct mesh_proxy_data_in { - -}; - -/* The Mesh Proxy Data Out characteristic is used by the server to send Proxy PDUs to - * the client. - */ -struct mesh_proxy_data_out { - -}; - -/* The Perceived Lightness characteristic is used to represent the perceived lightness - * of a light. - * Note: Unit is unitless with a resolution of 1; - * Minimum value: 0, maximum value: 65535. - */ -typedef u16_t bt_mesh_perceived_lightness_t; - -/* The Percentage 8 characteristic is used to represent a measure of percentage. - * Note: Unit is a percentage with a resolution of 0.5; - * Minimum value: 0, maximum value: 100; - * A value of 0xFF represents 'value is not known'. All other values are Prohibited. - */ -typedef u8_t bt_mesh_percentage_8_t; - -/* The Power characteristic is used to represent a measure of power in units of watts. - * Note: Unit is watt with a resolution of 0.1; - * Minimum value: 0, maximum value: 1677721.4; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_power_t[3]; - -/* This characteristic aggregates three instances of the Power characteristic to - * represent a specification of Power values. - */ -typedef struct __packed power_specification { - bt_mesh_power_t minimum_power_value; - bt_mesh_power_t typical_power_value; - bt_mesh_power_t maximum_power_value; -} bt_mesh_power_specification_t; - -/* This characteristic aggregates the Percentage 8 characteristic and two instances of - * the Electric Current characteristic to represent a relative value in an electric - * current range. - */ -typedef struct __packed relative_runtime_in_a_current_range { - bt_mesh_percentage_8_t relative_runtime_value; - bt_mesh_electric_current_t minimum_current; - bt_mesh_electric_current_t maximum_current; -} bt_mesh_relative_runtime_in_a_current_range_t; - -/* This characteristic aggregates the Percentage 8 characteristic and two instances of - * the Generic Level characteristic to represent a runtime in a generic level range. - */ -typedef struct __packed relative_runtime_in_a_generic_level_range { - bt_mesh_percentage_8_t relative_value; - bt_mesh_generic_level_t minimum_generic_level; - bt_mesh_generic_level_t maximum_generic_level; -} bt_mesh_relative_runtime_in_a_generic_level_range_t; - -/* This characteristic aggregates the Percentage 8 characteristic, and two instances of - * the Time Decihour 8 characteristic. - */ -typedef struct __packed relative_value_in_a_period_of_day { - bt_mesh_percentage_8_t relative_value; - bt_mesh_time_decihour_8_t start_time; - bt_mesh_time_decihour_8_t end_time; -} bt_mesh_relative_value_in_a_period_of_day_t; - -/* This characteristic aggregates the Percentage 8 characteristic, and two instances of - * the Temperature characteristic. - */ -typedef struct __packed relative_value_in_a_temperature_range { - bt_mesh_percentage_8_t relative_value; - bt_mesh_temperature_t minimum_temperature_value; - bt_mesh_temperature_t maximum_temperature_value; -} bt_mesh_relative_value_in_a_temperature_range_t; - -/* This characteristic aggregates the Percentage 8 characteristic and two instances of - * the Voltage characteristic to represent a relative value in a voltage range. - */ -typedef struct __packed relative_value_in_a_voltage_range { - bt_mesh_percentage_8_t relative_value; - bt_mesh_voltage_t minimum_voltage; - bt_mesh_voltage_t maximum_voltage; -} bt_mesh_relative_value_in_a_voltage_range_t; - -/* This characteristic aggregates the Percentage 8 characteristic and two instances of - * the Illuminance characteristic to represent a relative value in a illuminance range. - */ -typedef struct __packed relative_value_in_an_illuminance_range { - bt_mesh_percentage_8_t relative_value; - bt_mesh_illuminance_t minimum_illuminance; - bt_mesh_illuminance_t maximum_illuminance; -} bt_mesh_relative_value_in_an_illuminance_range_t; - -/* The Temperature 8 characteristic is used to represent a measure of temperature with - * a unit of 0.5 degree Celsius. - * Note: Unit is degree Celsius with a resolution of 0.5; - * Minimum value: -64.0, maximum value: 63.5; - * A value of 0xFF represents 'value is not known'. - */ -typedef s8_t bt_mesh_temperature_8_t; - -/* This characteristic aggregates the Temperature 8 characteristic, and two instances - * of the Time Decihour 8 characteristic, to represent a temperature value in a period - * of day. - */ -typedef struct __packed temperature_8_in_a_period_of_day { - bt_mesh_temperature_8_t temperature; - bt_mesh_time_decihour_8_t start_time; - bt_mesh_time_decihour_8_t end_time; -} bt_mesh_temperature_8_in_a_period_of_day_t; - -/* This characteristic aggregates four instances of the Temperature 8 characteristic, - * and one instance of the Time Exponential 8 characteristic. - */ -typedef struct __packed temperature_8_statistics { - bt_mesh_temperature_8_t average; - bt_mesh_temperature_8_t standard_deviation_value; - bt_mesh_temperature_8_t minimum_value; - bt_mesh_temperature_8_t maximum_value; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_temperature_8_statistics_t; - -/* This characteristic aggregates two instances of the Temperature characteristic to - * represent a temperature range. - */ -typedef struct __packed temperature_range { - bt_mesh_temperature_t minimum_temperature; - bt_mesh_temperature_t maximum_temperature; -} bt_mesh_temperature_range_t; - -/* This characteristic aggregates four instances of the Temperature characteristic, - * and one instance of the Time Exponential 8 characteristic. - */ -typedef struct __packed temperature_statistics { - bt_mesh_temperature_t average_temperature; - bt_mesh_temperature_t standard_deviation_temperature; - bt_mesh_temperature_t minimum_temperature; - bt_mesh_temperature_t maximum_temperature; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_temperature_statistics_t; - -/* The Time Hour 24 characteristic is used to represent a period of time in hours. - * Note: Unit is hour with a resolution of 1; - * Minimum value: 0, maximum value: 16777214; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_time_hour_24_t[3]; - -/* The Time Millisecond 24 characteristic is used to represent a period of time with - * a resolution of 1 millisecond. - * Note: Unit is second with a resolution of 0.001; - * Minimum value: 0, maximum value: 16777.214; - * A value of 0xFFFFFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_time_millisecond_24_t[3]; - -/* The Time Second 8 characteristic is used to represent a period of time with a unit - * of 1 second. - * Note: Unit is second with a resolution of 1; - * Minimum value: 0, maximum value: 254; - * A value of 0xFF represents 'value is not known'. - */ -typedef u8_t bt_mesh_time_second_8_t; - -/* This characteristic aggregates three instances of the Voltage characteristic to - * represent a specification of voltage values. - */ -typedef struct __packed voltage_specification { - bt_mesh_voltage_t minimum_voltage_value; - bt_mesh_voltage_t typical_voltage_value; - bt_mesh_voltage_t maximum_voltage_value; -} bt_mesh_voltage_specification_t; - -/* This characteristic aggregates four instances of the Voltage characteristic and an - * instance of the Time Exponential 8 characteristic to represent a set of statistical - * voltage values over a period of time. - */ -typedef struct __packed voltage_statistics { - bt_mesh_voltage_t average_voltage_value; - bt_mesh_voltage_t standard_deviation_voltage_value; - bt_mesh_voltage_t minimum_voltage_value; - bt_mesh_voltage_t maximum_voltage_value; - bt_mesh_time_exponential_8_t sensing_duration; -} bt_mesh_voltage_statistics_t; - -/* The Volume Flow characteristic is used to represent a flow of a general volume such - * as a volume of material or gas. - * Note: Unit is liter/second with a resolution of 0.001 (1 milliliter); - * Minimum value: 0, maximum value: 65534; - * A value of 0xFFFF represents 'value is not known'. - */ -typedef u16_t bt_mesh_volume_flow_t; - -/* Mesh Device Property related function */ - -u8_t bt_mesh_get_dev_prop_len(u16_t prop_id); - -#ifdef __cplusplus -} -#endif - -#endif /* _DEVICE_PROPERTY_H_ */ \ No newline at end of file diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h index 241f1112a..6ca0805be 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h @@ -360,36 +360,6 @@ void gen_level_publish(struct bt_mesh_model *model); void gen_onpowerup_publish(struct bt_mesh_model *model); void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode); -int bt_mesh_gen_onoff_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_level_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_def_trans_time_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_onoff_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_onoff_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_level_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_level_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_battery_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_location_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_location_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_user_prop_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_admin_prop_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_manu_prop_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_client_prop_srv_init(struct bt_mesh_model *model, bool primary); - -int bt_mesh_gen_onoff_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_level_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_def_trans_time_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_onoff_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_onoff_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_level_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_power_level_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_battery_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_location_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_location_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_user_prop_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_admin_prop_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_manu_prop_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_gen_client_prop_srv_deinit(struct bt_mesh_model *model, bool primary); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h index 34195dd0d..7f5bc348c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h @@ -503,34 +503,6 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode); void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode); void light_lc_publish(struct bt_mesh_model *model, u16_t opcode); -int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lightness_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_temp_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_hue_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_sat_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_xyl_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lc_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary); - -int bt_mesh_light_lightness_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lightness_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_ctl_temp_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_hue_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_hsl_sat_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_xyl_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_xyl_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lc_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_light_lc_setup_srv_deinit(struct bt_mesh_model *model, bool primary); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h index 8d7d6fe06..ca75d7d80 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h @@ -247,12 +247,6 @@ typedef union { } sensor_setting_set; } bt_mesh_sensor_server_recv_set_msg_t; -int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary); - -int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h b/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h index 08d6437b8..835940307 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h @@ -53,8 +53,6 @@ extern "C" { #define BLE_MESH_UNKNOWN_REMAIN_TIME 0x3F #define BLE_MESH_DEVICE_SPECIFIC_RESOLUTION 10 -#define BLE_MESH_INVALID_DEVICE_PROPERTY_ID 0x0000 - enum { BLE_MESH_TRANS_TIMER_START, /* Proper transition timer has been started */ BLE_MESH_TRANS_FLAG_MAX, diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h index dcd3efd71..6280bd76c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h @@ -385,20 +385,6 @@ void bt_mesh_time_scene_server_unlock(void); void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16_t opcode); -int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary); -int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary); - -int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_scene_setup_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary); -int bt_mesh_scheduler_setup_srv_deinit(struct bt_mesh_model *model, bool primary); - #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c index e3d6e51e9..a974c244d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c @@ -59,7 +59,7 @@ static void send_light_lightness_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -119,7 +119,7 @@ static void send_light_lightness_status(struct bt_mesh_model *model, } break; default: - BT_WARN("%s, Unknown Light Lightness status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Light Lightness status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -143,7 +143,7 @@ static void light_lightness_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -171,7 +171,7 @@ static void light_lightness_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS; break; default: - BT_WARN("%s, Unknown Light Lightness Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Light Lightness Get opcode 0x%04x", ctx->recv_op); return; } @@ -182,7 +182,7 @@ static void light_lightness_get(struct bt_mesh_model *model, void light_lightness_publish(struct bt_mesh_model *model, u16_t opcode) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -190,7 +190,7 @@ void light_lightness_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV: { struct bt_mesh_light_lightness_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light Lightness Server state", __func__); + BT_ERR("Invalid Light Lightness Server state"); return; } break; @@ -198,13 +198,13 @@ void light_lightness_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV: { struct bt_mesh_light_lightness_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light Lightness Setup Server state", __func__); + BT_ERR("Invalid Light Lightness Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Light Lightness Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light Lightness Server model 0x%04x", model->id); return; } @@ -223,7 +223,7 @@ static void light_lightness_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -335,7 +335,7 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -428,7 +428,7 @@ static void light_lightness_default_set(struct bt_mesh_model *model, u16_t lightness = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -470,7 +470,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model, u16_t range_min = 0U, range_max = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -478,8 +478,8 @@ static void light_lightness_range_set(struct bt_mesh_model *model, range_max = net_buf_simple_pull_le16(buf); if (range_min > range_max) { - BT_ERR("%s, Range Min 0x%04x is greater than Range Max 0x%04x", - __func__, range_min, range_max); + BT_ERR("Range min 0x%04x is greater than range max 0x%04x", + range_min, range_max); return; } @@ -556,7 +556,7 @@ static void send_light_ctl_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -620,7 +620,7 @@ static void send_light_ctl_status(struct bt_mesh_model *model, break; } default: - BT_WARN("%s, Unknown Light CTL status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Light CTL status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -644,7 +644,7 @@ static void light_ctl_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -652,7 +652,7 @@ static void light_ctl_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV: { struct bt_mesh_light_ctl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Server state", __func__); + BT_ERR("Invalid Light CTL Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; @@ -661,14 +661,14 @@ static void light_ctl_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV: { struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Temperature Server state", __func__); + BT_ERR("Invalid Light CTL Temperature Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; break; } default: - BT_ERR("%s, Invalid Light CTL Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light CTL Server model 0x%04x", model->id); return; } @@ -693,7 +693,7 @@ static void light_ctl_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS; break; default: - BT_WARN("%s, Unknown Light CTL Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Light CTL Get opcode 0x%04x", ctx->recv_op); return; } @@ -704,7 +704,7 @@ static void light_ctl_get(struct bt_mesh_model *model, void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -712,7 +712,7 @@ void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV: { struct bt_mesh_light_ctl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Server state", __func__); + BT_ERR("Invalid Light CTL Server state"); return; } break; @@ -720,7 +720,7 @@ void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV: { struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Temperature Server state", __func__); + BT_ERR("Invalid Light CTL Temperature Server state"); return; } break; @@ -728,13 +728,13 @@ void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV: { struct bt_mesh_light_ctl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Setup Server state", __func__); + BT_ERR("Invalid Light CTL Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Light CTL Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light CTL Server model 0x%04x", model->id); return; } @@ -754,7 +754,7 @@ static void light_ctl_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -764,7 +764,7 @@ static void light_ctl_set(struct bt_mesh_model *model, tid = net_buf_simple_pull_u8(buf); if (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { - BT_ERR("%s, Invalid temperature 0x%04x", __func__, temperature); + BT_ERR("Invalid temperature 0x%04x", temperature); return; } @@ -870,7 +870,7 @@ static void light_ctl_default_set(struct bt_mesh_model *model, s16_t delta_uv = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -879,7 +879,7 @@ static void light_ctl_default_set(struct bt_mesh_model *model, delta_uv = (s16_t) net_buf_simple_pull_le16(buf); if (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { - BT_ERR("%s, Invalid temperature 0x%04x", __func__, temperature); + BT_ERR("Invalid temperature 0x%04x", temperature); return; } @@ -933,7 +933,7 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, u16_t min = 0U, max = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -944,8 +944,8 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, if (min > max || min < BLE_MESH_TEMPERATURE_MIN || (min != BLE_MESH_TEMPERATURE_UNKNOWN && min > BLE_MESH_TEMPERATURE_MAX) || max < BLE_MESH_TEMPERATURE_MIN || (max != BLE_MESH_TEMPERATURE_UNKNOWN && max > BLE_MESH_TEMPERATURE_MAX)) { - BT_ERR("%s, Invalid parameter, range Min 0x%04x, range max 0x%04x", - __func__, min, max); + BT_ERR("Invalid parameter, range min 0x%04x, range max 0x%04x", + min, max); return; } @@ -1003,7 +1003,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1012,7 +1012,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, tid = net_buf_simple_pull_u8(buf); if (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { - BT_ERR("%s, Invalid temperature 0x%04x", __func__, temperature); + BT_ERR("Invalid temperature 0x%04x", temperature); return; } @@ -1121,7 +1121,7 @@ static void send_light_hsl_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -1206,7 +1206,7 @@ static void send_light_hsl_status(struct bt_mesh_model *model, break; } default: - BT_WARN("%s, Unknown Light HSL status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Light HSL status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -1230,7 +1230,7 @@ static void light_hsl_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1238,7 +1238,7 @@ static void light_hsl_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV: { struct bt_mesh_light_hsl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Server state", __func__); + BT_ERR("Invalid Light HSL Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; @@ -1247,7 +1247,7 @@ static void light_hsl_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV: { struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Hue Server state", __func__); + BT_ERR("Invalid Light HSL Hue Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; @@ -1256,14 +1256,14 @@ static void light_hsl_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV: { struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Saturation Server state", __func__); + BT_ERR("Invalid Light HSL Saturation Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; break; } default: - BT_ERR("%s, Invalid Light HSL Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light HSL Server model 0x%04x", model->id); return; } @@ -1294,7 +1294,7 @@ static void light_hsl_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS; break; default: - BT_WARN("%s, Unknown Light HSL Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Light HSL Get opcode 0x%04x", ctx->recv_op); return; } @@ -1305,7 +1305,7 @@ static void light_hsl_get(struct bt_mesh_model *model, void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1313,7 +1313,7 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV: { struct bt_mesh_light_hsl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Server state", __func__); + BT_ERR("Invalid Light HSL Server state"); return; } break; @@ -1321,7 +1321,7 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV: { struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Hue Server state", __func__); + BT_ERR("Invalid Light HSL Hue Server state"); return; } break; @@ -1329,7 +1329,7 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV: { struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Saturation Server state", __func__); + BT_ERR("Invalid Light HSL Saturation Server state"); return; } break; @@ -1337,13 +1337,13 @@ void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV: { struct bt_mesh_light_hsl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Setup Server state", __func__); + BT_ERR("Invalid Light HSL Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Light HSL Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light HSL Server model 0x%04x", model->id); return; } @@ -1362,7 +1362,7 @@ static void light_hsl_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1477,7 +1477,7 @@ static void light_hsl_default_set(struct bt_mesh_model *model, u16_t lightness = 0U, hue = 0U, saturation = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1537,7 +1537,7 @@ static void light_hsl_range_set(struct bt_mesh_model *model, u16_t hue_min = 0U, hue_max = 0U, saturation_min = 0U, saturation_max = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1547,14 +1547,14 @@ static void light_hsl_range_set(struct bt_mesh_model *model, saturation_max = net_buf_simple_pull_le16(buf); if (hue_min > hue_max) { - BT_ERR("%s, Invalid parameter, Hue min 0x%04x, Hue max 0x%04x", - __func__, hue_min, hue_max); + BT_ERR("Invalid parameter, hue min 0x%04x, hue max 0x%04x", + hue_min, hue_max); return; } if (saturation_min > saturation_max) { - BT_ERR("%s, Invalid parameter, Saturation min 0x%04x, Saturation max 0x%04x", - __func__, hue_min, hue_max); + BT_ERR("Invalid parameter, saturation min 0x%04x, saturation max 0x%04x", + saturation_min, saturation_max); return; } @@ -1605,7 +1605,7 @@ static void light_hsl_hue_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1706,7 +1706,7 @@ static void light_hsl_sat_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1813,7 +1813,7 @@ static void send_light_xyl_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -1878,7 +1878,7 @@ static void send_light_xyl_status(struct bt_mesh_model *model, } break; default: - BT_WARN("%s, Unknown Light xyL status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Light xyL status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -1902,7 +1902,7 @@ static void light_xyl_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1927,7 +1927,7 @@ static void light_xyl_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS; break; default: - BT_WARN("%s, Unknown Light xyL Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Light xyL Get opcode 0x%04x", ctx->recv_op); return; } @@ -1938,7 +1938,7 @@ static void light_xyl_get(struct bt_mesh_model *model, void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode) { if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1946,7 +1946,7 @@ void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_XYL_SRV: { struct bt_mesh_light_xyl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light xyL Server state", __func__); + BT_ERR("Invalid Light xyL Server state"); return; } break; @@ -1954,13 +1954,13 @@ void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode) case BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV: { struct bt_mesh_light_xyl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light xyL Setup Server state", __func__); + BT_ERR("Invalid Light xyL Setup Server state"); return; } break; } default: - BT_ERR("%s, Invalid Light xyL Server Model 0x%04x", __func__, model->id); + BT_ERR("Invalid Light xyL Server model 0x%04x", model->id); return; } @@ -1979,7 +1979,7 @@ static void light_xyl_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2094,7 +2094,7 @@ static void light_xyl_default_set(struct bt_mesh_model *model, u16_t lightness = 0U, x = 0U, y = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2154,7 +2154,7 @@ static void light_xyl_range_set(struct bt_mesh_model *model, u16_t x_min = 0U, x_max = 0U, y_min = 0U, y_max = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2164,14 +2164,14 @@ static void light_xyl_range_set(struct bt_mesh_model *model, y_max = net_buf_simple_pull_le16(buf); if (x_min > x_max) { - BT_ERR("%s, Invalid parameter, xyL x min 0x%04x, xyL x max 0x%04x", - __func__, x_min, x_max); + BT_ERR("Invalid parameter, x min 0x%04x, x max 0x%04x", + x_min, x_max); return; } if (y_min > y_max) { - BT_ERR("%s, Invalid parameter, xyL y min 0x%04x, xyL y max 0x%04x", - __func__, y_min, y_max); + BT_ERR("Invalid parameter, y min 0x%04x, y max 0x%04x", + y_min, y_max); return; } @@ -2228,7 +2228,7 @@ static void send_light_lc_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -2255,7 +2255,7 @@ static void send_light_lc_status(struct bt_mesh_model *model, } break; default: - BT_WARN("%s, Unknown Light LC status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Light LC status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -2279,7 +2279,7 @@ static void light_lc_get(struct bt_mesh_model *model, u16_t opcode = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2301,7 +2301,7 @@ static void light_lc_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS; break; default: - BT_WARN("%s, Unknown Light LC Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Light LC Get opcode 0x%04x", ctx->recv_op); return; } @@ -2314,7 +2314,7 @@ void light_lc_publish(struct bt_mesh_model *model, u16_t opcode) struct bt_mesh_light_lc_srv *srv = model->user_data; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2330,13 +2330,13 @@ static void light_lc_mode_set(struct bt_mesh_model *model, u8_t mode = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } mode = net_buf_simple_pull_u8(buf); if (mode > BLE_MESH_STATE_ON) { - BT_ERR("%s, Invalid LC Mode 0x%02x", __func__, mode); + BT_ERR("Invalid LC Mode 0x%02x", mode); return; } @@ -2374,13 +2374,13 @@ static void light_lc_om_set(struct bt_mesh_model *model, u8_t om = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } om = net_buf_simple_pull_u8(buf); if (om > BLE_MESH_STATE_ON) { - BT_ERR("%s, Invalid LC Occupancy Mode 0x%02x", __func__, om); + BT_ERR("Invalid LC Occupancy Mode 0x%02x", om); return; } @@ -2421,7 +2421,7 @@ static void light_lc_light_onoff_set(struct bt_mesh_model *model, s64_t now = 0; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2537,7 +2537,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, u8_t length = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -2565,7 +2565,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, switch (prop_id) { case BLE_MESH_MOTION_SENSED: { if (length != BLE_MESH_MOTION_SENSED_LEN || length != buf->len) { - BT_WARN("%s, Invalid Motion Sensed Property length", __func__); + BT_WARN("Invalid Motion Sensed Property length %d", length); return; } u8_t val = net_buf_simple_pull_u8(buf); @@ -2580,7 +2580,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, } case BLE_MESH_PEOPLE_COUNT: { if (length != BLE_MESH_PEOPLE_COUNT_LEN || length != buf->len) { - BT_WARN("%s, Invalid Motion Sensed Property length", __func__); + BT_WARN("Invalid Motion Sensed Property length %d", length); return; } u16_t val = net_buf_simple_pull_le16(buf); @@ -2595,7 +2595,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, } case BLE_MESH_PRESENCE_DETECTED: { if (length != BLE_MESH_PRESENCE_DETECTED_LEN || length != buf->len) { - BT_WARN("%s, Invalid Motion Sensed Property length", __func__); + BT_WARN("Invalid Motion Sensed Property length %d", length); return; } u8_t val = net_buf_simple_pull_u8(buf); @@ -2610,7 +2610,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, } case BLE_MESH_TIME_SINCE_MOTION_SENSED: { if (length != BLE_MESH_TIME_SINCE_MOTION_SENSED_LEN || length != buf->len) { - BT_WARN("%s, Invalid Motion Sensed Property length", __func__); + BT_WARN("Invalid Motion Sensed Property length %d", length); return; } u16_t val = net_buf_simple_pull_le16(buf); @@ -2632,7 +2632,7 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, * Here we just check if the length is larger than 3. */ if (buf->len < 3) { - BT_WARN("%s, Invalid Motion Sensed Property length", __func__); + BT_WARN("Invalid Motion Sensed Property length %d", buf->len); return; } u16_t lsb = net_buf_simple_pull_le16(buf); @@ -2734,14 +2734,14 @@ static void send_light_lc_prop_status(struct bt_mesh_model *model, prop_val = get_light_lc_prop_val(model, prop_id); if (prop_val == NULL) { - BT_ERR("%s, Failed to get Light LC Property value", __func__); + BT_ERR("Failed to get Light LC Property value"); return; } if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -2772,13 +2772,13 @@ static void light_lc_prop_get(struct bt_mesh_model *model, u16_t prop_id = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } prop_id = net_buf_simple_pull_le16(buf); if (prop_id < 0x002B || prop_id > 0x003C) { - BT_ERR("%s, Invalid Light LC Property ID 0x%04x", __func__, prop_id); + BT_ERR("Invalid Light LC Property ID 0x%04x", prop_id); return; } @@ -2805,13 +2805,13 @@ static void light_lc_prop_set(struct bt_mesh_model *model, u16_t prop_id = 0U; if (srv == NULL || srv->lc == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } prop_id = net_buf_simple_pull_le16(buf); if (prop_id < 0x002B || prop_id > 0x003C) { - BT_ERR("%s, Invalid Light LC Property ID 0x%04x", __func__, prop_id); + BT_ERR("Invalid Light LC Property ID 0x%04x", prop_id); return; } @@ -2827,14 +2827,14 @@ static void light_lc_prop_set(struct bt_mesh_model *model, expect_len = bt_mesh_get_dev_prop_len(prop_id); if (buf->len != expect_len) { - BT_ERR("%s, Invalid Light LC Property length, ID 0x%04x, expect %d, actual %d", - __func__, prop_id, expect_len, buf->len); + BT_ERR("Invalid Light LC Property 0x%04x length, expect %d, actual %d", + prop_id, expect_len, buf->len); return; } prop_val = get_light_lc_prop_val(model, prop_id); if (prop_val == NULL) { - BT_ERR("%s, Failed to get Light LC Property value", __func__); + BT_ERR("Failed to get Light LC Property value"); return; } @@ -2858,7 +2858,7 @@ static void light_lc_prop_set(struct bt_mesh_model *model, /* message handlers (End) */ /* Mapping of message handlers for Light Lightness Server (0x1300) */ -const struct bt_mesh_model_op light_lightness_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lightness_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET, 0, light_lightness_get }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET, 3, light_lightness_set }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK, 3, light_lightness_set }, @@ -2872,7 +2872,7 @@ const struct bt_mesh_model_op light_lightness_srv_op[] = { }; /* Mapping of message handlers for Light Lightness Setup Server (0x1301) */ -const struct bt_mesh_model_op light_lightness_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lightness_setup_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET, 2, light_lightness_default_set }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK, 2, light_lightness_default_set }, { BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET, 4, light_lightness_range_set }, @@ -2881,7 +2881,7 @@ const struct bt_mesh_model_op light_lightness_setup_srv_op[] = { }; /* Mapping of message handlers for Light CTL Server (0x1303) */ -const struct bt_mesh_model_op light_ctl_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_ctl_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_CTL_GET, 0, light_ctl_get }, { BLE_MESH_MODEL_OP_LIGHT_CTL_SET, 7, light_ctl_set }, { BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK, 7, light_ctl_set }, @@ -2891,7 +2891,7 @@ const struct bt_mesh_model_op light_ctl_srv_op[] = { }; /* Mapping of message handlers for Light CTL Setup Server (0x1304) */ -const struct bt_mesh_model_op light_ctl_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_ctl_setup_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET, 6, light_ctl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK, 6, light_ctl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET, 4, light_ctl_temp_range_set }, @@ -2900,7 +2900,7 @@ const struct bt_mesh_model_op light_ctl_setup_srv_op[] = { }; /* Mapping of message handlers for Light CTL Temperature Server (0x1306) */ -const struct bt_mesh_model_op light_ctl_temp_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_ctl_temp_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET, 0, light_ctl_get }, { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET, 5, light_ctl_temp_set }, { BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK, 5, light_ctl_temp_set }, @@ -2908,7 +2908,7 @@ const struct bt_mesh_model_op light_ctl_temp_srv_op[] = { }; /* Mapping of message handlers for Light HSL Server (0x1307) */ -const struct bt_mesh_model_op light_hsl_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_hsl_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_HSL_GET, 0, light_hsl_get }, { BLE_MESH_MODEL_OP_LIGHT_HSL_SET, 7, light_hsl_set }, { BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK, 7, light_hsl_set }, @@ -2919,7 +2919,7 @@ const struct bt_mesh_model_op light_hsl_srv_op[] = { }; /* Mapping of message handlers for Light HSL Setup Server (0x1308) */ -const struct bt_mesh_model_op light_hsl_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_hsl_setup_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET, 6, light_hsl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK, 6, light_hsl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET, 8, light_hsl_range_set }, @@ -2928,7 +2928,7 @@ const struct bt_mesh_model_op light_hsl_setup_srv_op[] = { }; /* Mapping of message handlers for Light HSL Hue Server (0x130A) */ -const struct bt_mesh_model_op light_hsl_hue_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_hsl_hue_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET, 0, light_hsl_get }, { BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET, 3, light_hsl_hue_set }, { BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK, 3, light_hsl_hue_set }, @@ -2936,7 +2936,7 @@ const struct bt_mesh_model_op light_hsl_hue_srv_op[] = { }; /* Mapping of message handlers for Light HSL Saturation Server (0x130B) */ -const struct bt_mesh_model_op light_hsl_sat_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_hsl_sat_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET, 0, light_hsl_get }, { BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET, 3, light_hsl_sat_set }, { BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK, 3, light_hsl_sat_set }, @@ -2944,7 +2944,7 @@ const struct bt_mesh_model_op light_hsl_sat_srv_op[] = { }; /* Mapping of message handlers for Light xyL Server (0x130C) */ -const struct bt_mesh_model_op light_xyl_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_xyl_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_XYL_GET, 0, light_xyl_get }, { BLE_MESH_MODEL_OP_LIGHT_XYL_SET, 7, light_xyl_set }, { BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK, 7, light_xyl_set }, @@ -2955,7 +2955,7 @@ const struct bt_mesh_model_op light_xyl_srv_op[] = { }; /* Mapping of message handlers for Light xyL Setup Server (0x130D) */ -const struct bt_mesh_model_op light_xyl_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_xyl_setup_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET, 6, light_xyl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK, 6, light_xyl_default_set }, { BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET, 8, light_xyl_range_set }, @@ -2964,7 +2964,7 @@ const struct bt_mesh_model_op light_xyl_setup_srv_op[] = { }; /* Mapping of message handlers for Light LC Server (0x130F) */ -const struct bt_mesh_model_op light_lc_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET, 0, light_lc_get }, { BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET, 1, light_lc_mode_set }, { BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK, 1, light_lc_mode_set }, @@ -2979,7 +2979,7 @@ const struct bt_mesh_model_op light_lc_srv_op[] = { }; /* Mapping of message handlers for Light LC Setup Server (0x1310) */ -const struct bt_mesh_model_op light_lc_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[] = { { BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET, 2, light_lc_prop_get }, { BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET, 3, light_lc_prop_set }, { BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK, 3, light_lc_prop_set }, @@ -2989,7 +2989,7 @@ const struct bt_mesh_model_op light_lc_setup_srv_op[] = { static int light_server_init(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Light Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Lighting Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -2997,7 +2997,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV: { struct bt_mesh_light_lightness_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light Lightness State", __func__); + BT_ERR("Invalid Light Lightness State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3012,7 +3012,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV: { struct bt_mesh_light_lightness_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light Lightness State", __func__); + BT_ERR("Invalid Light Lightness State"); return -EINVAL; } srv->model = model; @@ -3021,7 +3021,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV: { struct bt_mesh_light_ctl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light CTL State", __func__); + BT_ERR("Invalid Light CTL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3034,7 +3034,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV: { struct bt_mesh_light_ctl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light CTL State", __func__); + BT_ERR("Invalid Light CTL State"); return -EINVAL; } srv->model = model; @@ -3043,7 +3043,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV: { struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light CTL State", __func__); + BT_ERR("Invalid Light CTL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3056,7 +3056,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV: { struct bt_mesh_light_hsl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3069,7 +3069,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV: { struct bt_mesh_light_hsl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } srv->model = model; @@ -3078,7 +3078,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV: { struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3091,7 +3091,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV: { struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3104,7 +3104,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_XYL_SRV: { struct bt_mesh_light_xyl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light xyL State", __func__); + BT_ERR("Invalid Light xyL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3117,7 +3117,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV: { struct bt_mesh_light_xyl_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light xyL State", __func__); + BT_ERR("Invalid Light xyL State"); return -EINVAL; } srv->model = model; @@ -3126,7 +3126,7 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LC_SRV: { struct bt_mesh_light_lc_srv *srv = model->user_data; if (srv->lc == NULL) { - BT_ERR("%s, NULL Light LC State", __func__); + BT_ERR("Invalid Light LC State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3139,14 +3139,14 @@ static int light_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV: { struct bt_mesh_light_lc_setup_srv *srv = model->user_data; if (srv->lc == NULL) { - BT_ERR("%s, NULL Light LC State", __func__); + BT_ERR("Invalid Light LC State"); return -EINVAL; } srv->model = model; break; } default: - BT_WARN("%s, Unknown Light Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Light Server, model id 0x%04x", model->id); return -EINVAL; } @@ -3155,10 +3155,10 @@ static int light_server_init(struct bt_mesh_model *model) return 0; } -int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary) +static int light_lightness_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light Lightness Server has no publication support", __func__); + BT_ERR("Light Lightness Server has no publication support"); return -EINVAL; } @@ -3167,21 +3167,21 @@ int bt_mesh_light_lightness_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV) == NULL) { - BT_WARN("%s, Light Lightness Setup Server is not present", __func__); + BT_WARN("Light Lightness Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return light_server_init(model); } -int bt_mesh_light_lightness_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int light_lightness_setup_srv_init(struct bt_mesh_model *model) { return light_server_init(model); } -int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary) +static int light_ctl_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light CTL Server has no publication support", __func__); + BT_ERR("Light CTL Server has no publication support"); return -EINVAL; } @@ -3195,35 +3195,35 @@ int bt_mesh_light_ctl_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV) == NULL) { - BT_WARN("%s, Light CTL Setup Server is not present", __func__); + BT_WARN("Light CTL Setup Server not present"); /* Just give a warning here, continue with the initialization */ } if (bt_mesh_elem_count() < 2) { - BT_WARN("%s, Light CTL Server requires two elements", __func__); + BT_WARN("Light CTL Server requires two elements"); /* Just give a warning here, continue with the initialization */ } return light_server_init(model); } -int bt_mesh_light_ctl_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int light_ctl_setup_srv_init(struct bt_mesh_model *model) { return light_server_init(model); } -int bt_mesh_light_ctl_temp_srv_init(struct bt_mesh_model *model, bool primary) +static int light_ctl_temp_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light CTL Temperature Server has no publication support", __func__); + BT_ERR("Light CTL Temperature Server has no publication support"); return -EINVAL; } return light_server_init(model); } -int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary) +static int light_hsl_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Server has no publication support", __func__); + BT_ERR("Light HSL Server has no publication support"); return -EINVAL; } @@ -3238,45 +3238,45 @@ int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV) == NULL) { - BT_WARN("%s, Light HSL Setup Server is not present", __func__); + BT_WARN("Light HSL Setup Server not present"); /* Just give a warning here, continue with the initialization */ } if (bt_mesh_elem_count() < 3) { - BT_WARN("%s, Light HSL Server requires three elements", __func__); + BT_WARN("Light HSL Server requires three elements"); /* Just give a warning here, continue with the initialization */ } return light_server_init(model); } -int bt_mesh_light_hsl_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int light_hsl_setup_srv_init(struct bt_mesh_model *model) { return light_server_init(model); } -int bt_mesh_light_hsl_hue_srv_init(struct bt_mesh_model *model, bool primary) +static int light_hsl_hue_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Hue Server has no publication support", __func__); + BT_ERR("Light HSL Hue Server has no publication support"); return -EINVAL; } return light_server_init(model); } -int bt_mesh_light_hsl_sat_srv_init(struct bt_mesh_model *model, bool primary) +static int light_hsl_sat_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Saturation Server has no publication support", __func__); + BT_ERR("Light HSL Saturation Server has no publication support"); return -EINVAL; } return light_server_init(model); } -int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary) +static int light_xyl_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light xyL Server has no publication support", __func__); + BT_ERR("Light xyL Server has no publication support"); return -EINVAL; } @@ -3286,31 +3286,31 @@ int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV) == NULL) { - BT_WARN("%s, Light xyL Setup Server is not present", __func__); + BT_WARN("Light xyL Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return light_server_init(model); } -int bt_mesh_light_xyl_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int light_xyl_setup_srv_init(struct bt_mesh_model *model) { return light_server_init(model); } -int bt_mesh_light_lc_srv_init(struct bt_mesh_model *model, bool primary) +static int light_lc_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light LC Server has no publication support", __func__); + BT_ERR("Light LC Server has no publication support"); return -EINVAL; } return light_server_init(model); } -int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int light_lc_setup_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light LC Setup Server has no publication support", __func__); + BT_ERR("Light LC Setup Server has no publication support"); return -EINVAL; } @@ -3320,7 +3320,7 @@ int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV) == NULL) { - BT_WARN("%s, Light LC Setup Server is not present", __func__); + BT_WARN("Light LC Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return light_server_init(model); @@ -3329,7 +3329,7 @@ int bt_mesh_light_lc_setup_srv_init(struct bt_mesh_model *model, bool primary) static int light_server_deinit(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Light Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Lighting Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -3337,7 +3337,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV: { struct bt_mesh_light_lightness_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light Lightness State", __func__); + BT_ERR("Invalid Light Lightness State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3351,7 +3351,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_CTL_SRV: { struct bt_mesh_light_ctl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light CTL State", __func__); + BT_ERR("Invalid Light CTL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3363,7 +3363,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV: { struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light CTL State", __func__); + BT_ERR("Invalid Light CTL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3375,7 +3375,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_SRV: { struct bt_mesh_light_hsl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3387,7 +3387,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV: { struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3399,7 +3399,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV: { struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light HSL State", __func__); + BT_ERR("Invalid Light HSL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3411,7 +3411,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_XYL_SRV: { struct bt_mesh_light_xyl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Light xyL State", __func__); + BT_ERR("Invalid Light xyL State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3423,7 +3423,7 @@ static int light_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_LIGHT_LC_SRV: { struct bt_mesh_light_lc_srv *srv = model->user_data; if (srv->lc == NULL) { - BT_ERR("%s, NULL Light LC State", __func__); + BT_ERR("Invalid Light LC State"); return -EINVAL; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_AUTO_RSP) { @@ -3433,7 +3433,7 @@ static int light_server_deinit(struct bt_mesh_model *model) break; } default: - BT_WARN("%s, Unknown Light Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Light Server, model id 0x%04x", model->id); return -EINVAL; } @@ -3442,112 +3442,177 @@ static int light_server_deinit(struct bt_mesh_model *model) return 0; } -int bt_mesh_light_lightness_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_lightness_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light Lightness Server has no publication support", __func__); + BT_ERR("Light Lightness Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_lightness_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_lightness_setup_srv_deinit(struct bt_mesh_model *model) { return light_server_deinit(model); } -int bt_mesh_light_ctl_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_ctl_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light CTL Server has no publication support", __func__); + BT_ERR("Light CTL Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_ctl_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_ctl_setup_srv_deinit(struct bt_mesh_model *model) { return light_server_deinit(model); } -int bt_mesh_light_ctl_temp_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_ctl_temp_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light CTL Temperature Server has no publication support", __func__); + BT_ERR("Light CTL Temperature Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_hsl_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_hsl_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Server has no publication support", __func__); + BT_ERR("Light HSL Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_hsl_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_hsl_setup_srv_deinit(struct bt_mesh_model *model) { return light_server_deinit(model); } -int bt_mesh_light_hsl_hue_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_hsl_hue_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Hue Server has no publication support", __func__); + BT_ERR("Light HSL Hue Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_hsl_sat_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_hsl_sat_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light HSL Saturation Server has no publication support", __func__); + BT_ERR("Light HSL Saturation Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_xyl_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_xyl_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light xyL Server has no publication support", __func__); + BT_ERR("Light xyL Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_xyl_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_xyl_setup_srv_deinit(struct bt_mesh_model *model) { return light_server_deinit(model); } -int bt_mesh_light_lc_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_lc_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light LC Server has no publication support", __func__); + BT_ERR("Light LC Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } -int bt_mesh_light_lc_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int light_lc_setup_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Light LC Setup Server has no publication support", __func__); + BT_ERR("Light LC Setup Server has no publication support"); return -EINVAL; } return light_server_deinit(model); } + +const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb = { + .init = light_lightness_srv_init, + .deinit = light_lightness_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb = { + .init = light_lightness_setup_srv_init, + .deinit = light_lightness_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb = { + .init = light_ctl_srv_init, + .deinit = light_ctl_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_ctl_setup_srv_cb = { + .init = light_ctl_setup_srv_init, + .deinit = light_ctl_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_ctl_temp_srv_cb = { + .init = light_ctl_temp_srv_init, + .deinit = light_ctl_temp_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_hsl_srv_cb = { + .init = light_hsl_srv_init, + .deinit = light_hsl_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb = { + .init = light_hsl_setup_srv_init, + .deinit = light_hsl_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_hsl_hue_srv_cb = { + .init = light_hsl_hue_srv_init, + .deinit = light_hsl_hue_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb = { + .init = light_hsl_sat_srv_init, + .deinit = light_hsl_sat_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb = { + .init = light_xyl_srv_init, + .deinit = light_xyl_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb = { + .init = light_xyl_setup_srv_init, + .deinit = light_xyl_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb = { + .init = light_lc_srv_init, + .deinit = light_lc_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb = { + .init = light_lc_setup_srv_init, + .deinit = light_lc_setup_srv_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c index 5cbcb1bdc..2cdccb8ca 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c @@ -39,7 +39,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -52,6 +52,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, total_len += SENSOR_DESCRIPTOR_LEN; if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ + BT_WARN("Too large sensor descriptor status"); break; } net_buf_simple_add_le16(msg, state->sensor_property_id); @@ -67,6 +68,12 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && state->sensor_property_id == prop_id) { + total_len += SENSOR_DESCRIPTOR_LEN; + if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { + /* Add this in case the message is too long */ + BT_WARN("Too large sensor descriptor status"); + break; + } net_buf_simple_add_le16(msg, state->sensor_property_id); net_buf_simple_add_le32(msg, (state->descriptor.sample_function << 24) | (state->descriptor.negative_tolerance << 12) | @@ -77,7 +84,7 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); net_buf_simple_add_le16(msg, prop_id); } } @@ -99,7 +106,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -115,6 +122,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, state->sensor_data.raw_value->len : 0)); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ + BT_WARN("Too large sensor status"); break; } if (state->sensor_data.format == SENSOR_DATA_FORMAT_A) { @@ -136,6 +144,15 @@ static void send_sensor_data_status(struct bt_mesh_model *model, state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && state->sensor_property_id == prop_id) { + u8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? + SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; + total_len += (mpid_len + (state->sensor_data.raw_value ? + state->sensor_data.raw_value->len : 0)); + if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { + /* Add this in case the message is too long */ + BT_WARN("Too large sensor status"); + break; + } if (state->sensor_data.format == SENSOR_DATA_FORMAT_A) { u16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | ((state->sensor_data.length & BIT_MASK(4)) << 1) | @@ -154,7 +171,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); u8_t mpid = (SENSOR_DATA_ZERO_LEN << 1) | SENSOR_DATA_FORMAT_B; net_buf_simple_add_u8(msg, mpid); net_buf_simple_add_le16(msg, prop_id); @@ -205,14 +222,14 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); length = SENSOR_PROPERTY_ID_LEN; } if (publish == false) { msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -280,7 +297,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -298,6 +315,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, total_len += SENSOR_SETTING_PROPERTY_ID_LEN; if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ + BT_WARN("Too large sensor settings status"); break; } net_buf_simple_add_le16(msg, item->property_id); @@ -307,7 +325,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); } BLE_MESH_CHECK_SEND_STATUS(bt_mesh_model_send(model, ctx, msg, NULL, NULL)); @@ -316,7 +334,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, } static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model, - u16_t prop_id, u16_t set_prop_id) + u16_t prop_id, u16_t set_prop_id) { struct bt_mesh_sensor_setup_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; @@ -359,14 +377,14 @@ static void send_sensor_setting_status(struct bt_mesh_model *model, * an unknown Sensor Setting Property ID field, the Sensor Setting Access * field and the Sensor Setting Raw field shall be omitted. */ - BT_WARN("%s, Sensor Setting not found, 0x%04x, 0x%04x", __func__, prop_id, set_prop_id); + BT_WARN("Sensor Setting not found, 0x%04x, 0x%04x", prop_id, set_prop_id); length = SENSOR_PROPERTY_ID_LEN + SENSOR_SETTING_PROPERTY_ID_LEN; } if (publish == false) { msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -445,13 +463,13 @@ static void send_sensor_column_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); length = SENSOR_PROPERTY_ID_LEN; } msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -519,13 +537,13 @@ static void send_sensor_series_status(struct bt_mesh_model *model, } } if (i == srv->state_count) { - BT_WARN("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); length = SENSOR_PROPERTY_ID_LEN; } msg = bt_mesh_alloc_buf(1 + length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } @@ -567,7 +585,7 @@ static void sensor_get(struct bt_mesh_model *model, u16_t prop_id = INVALID_SENSOR_PROPERTY_ID; if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -578,7 +596,7 @@ static void sensor_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SENSOR_SERIES_GET: { struct bt_mesh_sensor_srv *srv = model->user_data; if (srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid Sensor Server state", __func__); + BT_ERR("Invalid Sensor Server state"); return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET || @@ -587,7 +605,7 @@ static void sensor_get(struct bt_mesh_model *model, if (buf->len) { prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } } @@ -617,7 +635,7 @@ static void sensor_get(struct bt_mesh_model *model, } else { prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) { @@ -651,14 +669,14 @@ static void sensor_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SENSOR_SETTING_GET: { struct bt_mesh_sensor_setup_srv *srv = model->user_data; if (srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid Sensor Setup Server state", __func__); + BT_ERR("Invalid Sensor Setup Server state"); return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET || ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET) { prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET) { @@ -685,12 +703,12 @@ static void sensor_get(struct bt_mesh_model *model, } else { prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } set_prop_id = net_buf_simple_pull_le16(buf); if (set_prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Setting Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Setting Property ID 0x0000"); return; } @@ -708,7 +726,7 @@ static void sensor_get(struct bt_mesh_model *model, return; } default: - BT_WARN("%s, Unknown Sensor Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Sensor Get opcode 0x%04x", ctx->recv_op); return; } } @@ -727,13 +745,13 @@ static void sensor_cadence_set(struct bt_mesh_model *model, int i; if (srv == NULL || srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } @@ -774,7 +792,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, val = net_buf_simple_pull_u8(buf); divisor = val & BIT_MASK(7); if (divisor > SENSOR_PERIOD_DIVISOR_MAX_VALUE) { - BT_ERR("%s, Prohibited Fast Cadence Period Divisor 0x%02x", __func__, divisor); + BT_ERR("Prohibited Fast Cadence Period Divisor 0x%02x", divisor); return; } state->cadence->period_divisor = divisor; @@ -786,8 +804,8 @@ static void sensor_cadence_set(struct bt_mesh_model *model, trigger_len = SENSOR_STATUS_TRIGGER_UINT16_LEN; } if (buf->len < (trigger_len << 1) + SENSOR_STATUS_MIN_INTERVAL_LEN) { - BT_ERR("%s, Invalid Sensor Cadence Set length %d, trigger type %d", - __func__, buf->len + 3, state->cadence->trigger_type); + BT_ERR("Invalid Sensor Cadence Set length %d, trigger type %d", + buf->len + 3, state->cadence->trigger_type); return; } @@ -805,13 +823,13 @@ static void sensor_cadence_set(struct bt_mesh_model *model, /* The valid range for the Status Min Interval is 0–26 and other values are Prohibited. */ val = net_buf_simple_pull_u8(buf); if (val > SENSOR_STATUS_MIN_INTERVAL_MAX) { - BT_ERR("%s, Invalid Status Min Interval %d", __func__, val); + BT_ERR("Invalid Status Min Interval %d", val); return; } state->cadence->min_interval = val; if (buf->len % 2) { - BT_ERR("%s, Different length of Fast Cadence Low & High, length %d", __func__, buf->len); + BT_ERR("Different length of Fast Cadence Low & High, length %d", buf->len); return; } if (buf->len) { @@ -848,7 +866,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, element = bt_mesh_model_elem(model); sensor_model = bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SENSOR_SRV); if (sensor_model == NULL) { - BT_WARN("%s, Sensor Server Model does not exist in the element", __func__); + BT_WARN("Sensor Server model not exists in the element"); return; } @@ -867,13 +885,13 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i int i; if (model->id != BLE_MESH_MODEL_ID_SENSOR_SRV) { - BT_ERR("%s, Not a Sensor Server Model", __func__); + BT_ERR("Invalid Sensor Server model 0x%04x", model->id); return; } srv = (struct bt_mesh_sensor_srv *)model->user_data; if (srv == NULL || srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -885,12 +903,12 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i } } if (i == srv->state_count) { - BT_ERR("%s, Sensor Property ID 0x%04x does not exist", __func__, prop_id); + BT_ERR("Sensor Property ID 0x%04x not exists", prop_id); return; } if (state->cadence == NULL) { - BT_WARN("%s, Sensor Cadence state does not exist", __func__); + BT_WARN("Sensor Cadence state not exists"); return; } @@ -912,19 +930,19 @@ static void sensor_setting_set(struct bt_mesh_model *model, u16_t prop_id = 0U, set_prop_id = 0U; if (srv == NULL || srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Property ID 0x0000"); return; } set_prop_id = net_buf_simple_pull_le16(buf); if (set_prop_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Prohibited Sensor Setting Property ID 0x0000", __func__); + BT_ERR("Prohibited Sensor Setting Property ID 0x0000"); return; } @@ -967,7 +985,7 @@ static void sensor_setting_set(struct bt_mesh_model *model, /* message handlers (End) */ /* Mapping of message handlers for Sensor Server (0x1100) */ -const struct bt_mesh_model_op sensor_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_sensor_srv_op[] = { { BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET, 0, sensor_get }, { BLE_MESH_MODEL_OP_SENSOR_GET, 0, sensor_get }, { BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET, 2, sensor_get }, @@ -976,7 +994,7 @@ const struct bt_mesh_model_op sensor_srv_op[] = { }; /* Mapping of message handlers for Sensor Setup Server (0x1101) */ -const struct bt_mesh_model_op sensor_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[] = { { BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET, 2, sensor_get }, { BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET, 4, sensor_cadence_set }, { BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK, 4, sensor_cadence_set }, @@ -997,13 +1015,13 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, for (i = 0; i < state_count; i++) { state = &state_start[i]; if (state->sensor_property_id == INVALID_SENSOR_PROPERTY_ID) { - BT_ERR("%s, Invalid Sensor Property ID 0x%04x", __func__, state->sensor_property_id); + BT_ERR("Invalid Sensor Property ID 0x%04x", state->sensor_property_id); return -EINVAL; } /* Check if the same Sensor Property ID exists */ for (int k = i + 1; k < state_count; k++) { if (state->sensor_property_id == state_start[k].sensor_property_id) { - BT_ERR("%s, Same Sensor Property ID 0x%04x exists", __func__, state->sensor_property_id); + BT_ERR("Same Sensor Property ID 0x%04x exists", state->sensor_property_id); return -EINVAL; } } @@ -1011,13 +1029,13 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, for (j = 0; j < state->setting_count; j++) { setting = &state->settings[j]; if (setting->property_id == INVALID_SENSOR_SETTING_PROPERTY_ID || setting->raw == NULL) { - BT_ERR("%s, Invalid Sensor Setting state", __func__); + BT_ERR("Invalid Sensor Setting state"); return -EINVAL; } /* Check if the same Sensor Setting Property ID exists */ for (int k = j + 1; k < state->setting_count; k++) { if (setting->property_id == state->settings[k].property_id) { - BT_ERR("%s, Same Sensor Setting Property ID 0x%04x exists", __func__, setting->property_id); + BT_ERR("Same Sensor Setting Property ID 0x%04x exists", setting->property_id); return -EINVAL; } } @@ -1028,12 +1046,12 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, state->cadence->trigger_delta_up == NULL || state->cadence->fast_cadence_low == NULL || state->cadence->fast_cadence_high == NULL) { - BT_ERR("%s, Invalid Sensor Cadence state", __func__); + BT_ERR("Invalid Sensor Cadence state"); return -EINVAL; } } if (state->sensor_data.raw_value == NULL) { - BT_ERR("%s, Invalid Sensor Data state", __func__); + BT_ERR("Invalid Sensor Data state"); return -EINVAL; } } @@ -1044,7 +1062,7 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, static int sensor_server_init(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Sensor Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Sensor Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -1052,7 +1070,7 @@ static int sensor_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SENSOR_SRV: { struct bt_mesh_sensor_srv *srv = model->user_data; if (srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid Sensor state, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Sensor state, model id 0x%04x", model->id); return -EINVAL; } if (check_sensor_server_init(srv->states, srv->state_count)) { @@ -1064,7 +1082,7 @@ static int sensor_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV: { struct bt_mesh_sensor_setup_srv *srv = model->user_data; if (srv->state_count == 0U || srv->states == NULL) { - BT_ERR("%s, Invalid Sensor state, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Sensor state, model id 0x%04x", model->id); return -EINVAL; } if (check_sensor_server_init(srv->states, srv->state_count)) { @@ -1074,17 +1092,17 @@ static int sensor_server_init(struct bt_mesh_model *model) break; } default: - BT_WARN("%s, Unknown Sensor Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Sensor Server, model id 0x%04x", model->id); return -EINVAL; } return 0; } -int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary) +static int sensor_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Sensor Server has no publication support", __func__); + BT_ERR("Sensor Server has no publication support"); return -EINVAL; } @@ -1093,16 +1111,16 @@ int bt_mesh_sensor_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV) == NULL) { - BT_WARN("%s, Sensor Setup Server is not present", __func__); + BT_WARN("Sensor Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return sensor_server_init(model); } -int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int sensor_setup_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Sensor Setup Server has no publication support", __func__); + BT_ERR("Sensor Setup Server has no publication support"); return -EINVAL; } @@ -1112,29 +1130,39 @@ int bt_mesh_sensor_setup_srv_init(struct bt_mesh_model *model, bool primary) static int sensor_server_deinit(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Sensor Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Sensor Server user, model id 0x%04x", model->id); return -EINVAL; } return 0; } -int bt_mesh_sensor_srv_deinit(struct bt_mesh_model *model, bool primary) +static int sensor_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Sensor Server has no publication support", __func__); + BT_ERR("Sensor Server has no publication support"); return -EINVAL; } return sensor_server_deinit(model); } -int bt_mesh_sensor_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int sensor_setup_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Sensor Setup Server has no publication support", __func__); + BT_ERR("Sensor Setup Server has no publication support"); return -EINVAL; } return sensor_server_deinit(model); } + +const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb = { + .init = sensor_srv_init, + .deinit = sensor_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb = { + .init = sensor_setup_srv_init, + .deinit = sensor_setup_srv_deinit, +}; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c index ee698e2d7..b1efe926f 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c @@ -73,13 +73,13 @@ int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_tim } if (model->id != BLE_MESH_MODEL_ID_LIGHT_LC_SRV) { - BT_ERR("%s, Not a Light LC Server", __func__); + BT_ERR("Invalid a Light LC Server 0x%04x", model->id); return -EINVAL; } srv = (struct bt_mesh_light_lc_srv *)model->user_data; if (srv == NULL) { - BT_ERR("%s, Invalid Light LC Server user_data", __func__); + BT_ERR("Invalid Light LC Server user data"); return -EINVAL; } @@ -130,7 +130,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model, } if (buf->len != 0x00 && buf->len != 0x02) { - BT_ERR("%s, Invalid optional message length %d", __func__, buf->len); + BT_ERR("Invalid optional message length %d", buf->len); return -EINVAL; } @@ -152,7 +152,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model, * its appropriate transition times defined by the Light LC Property states. */ if (bt_mesh_get_light_lc_trans_time(model, trans_time)) { - BT_ERR("%s, Failed to get Light LC transition time", __func__); + BT_ERR("Failed to get Light LC transition time"); return -EIO; } } else { @@ -166,7 +166,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model, /* Optional fields are available */ *trans_time = net_buf_simple_pull_u8(buf); if ((*trans_time & 0x3F) == 0x3F) { - BT_ERR("%s, Invalid Transaction Number of Steps 0x3F", __func__); + BT_ERR("Invalid Transaction Number of Steps 0x3f"); return -EINVAL; } @@ -183,16 +183,16 @@ void bt_mesh_server_alloc_ctx(struct k_work *work) * bt_mesh_msg_ctx" info to the application layer after a certain delay. * Here we use the allocated heap memory to store the "struct bt_mesh_msg_ctx". */ - __ASSERT(work, "%s, Invalid parameter", __func__); + __ASSERT(work, "Invalid parameter"); if (!work->_reserved) { work->_reserved = bt_mesh_calloc(sizeof(struct bt_mesh_msg_ctx)); - __ASSERT(work->_reserved, "%s, Failed to allocate memory", __func__); + __ASSERT(work->_reserved, "Out of memory"); } } void bt_mesh_server_free_ctx(struct k_work *work) { - __ASSERT(work, "%s, Invalid parameter", __func__); + __ASSERT(work, "Invalid parameter"); if (work->_reserved) { bt_mesh_free(work->_reserved); work->_reserved = NULL; @@ -243,14 +243,14 @@ struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u if (model->pub == NULL || model->pub->msg == NULL || model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { - BT_DBG("%s, Model 0x%04x has no publication support", __func__, model->id); + BT_DBG("No publication support, model id 0x%04x", model->id); return NULL; } buf = model->pub->msg; if (buf->size < msg_len) { - BT_ERR("%s, Too small publication msg size %d, model 0x%04x", - __func__, buf->size, model->id); + BT_ERR("Too small publication msg size %d, model id 0x%04x", + buf->size, model->id); return NULL; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c index 9aef2081c..f54fcf3e7 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c @@ -104,7 +104,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, switch (type) { case GENERIC_ONOFF_STATE: { if (model->id != BLE_MESH_MODEL_ID_GEN_ONOFF_SRV) { - BT_ERR("%s, Not a Generic OnOff Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic OnOff Server, model id 0x%04x", model->id); return -EINVAL; } @@ -116,7 +116,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case GENERIC_LEVEL_STATE: { if (model->id != BLE_MESH_MODEL_ID_GEN_LEVEL_SRV) { - BT_ERR("%s, Not a Generic Level Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Level Server, model id 0x%04x", model->id); return -EINVAL; } @@ -128,13 +128,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case GENERIC_ONPOWERUP_STATE: { if (model->id != BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV) { - BT_ERR("%s, Not a Generic Power OnOff Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Power OnOff Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_gen_power_onoff_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power OnOff Server state", __func__); + BT_ERR("Invalid Generic Power OnOff Server state"); return -EINVAL; } @@ -144,13 +144,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case GENERIC_POWER_ACTUAL_STATE: { if (model->id != BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV) { - BT_ERR("%s, Not a Generic Power Level Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Generic Power Level Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_gen_power_level_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Generic Power Level Server state", __func__); + BT_ERR("Invalid Generic Power Level Server state"); return -EINVAL; } @@ -170,13 +170,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_LIGHTNESS_ACTUAL_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV) { - BT_ERR("%s, Not a Light Lightness Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light Lightness Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_lightness_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light Lightness Server state", __func__); + BT_ERR("Invalid Light Lightness Server state"); return -EINVAL; } @@ -196,13 +196,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_LIGHTNESS_LINEAR_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV) { - BT_ERR("%s, Not a Light Lightness Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light Lightness Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_lightness_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light Lightness Server state", __func__); + BT_ERR("Invalid Light Lightness Server state"); return -EINVAL; } @@ -213,13 +213,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_CTL_LIGHTNESS_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_CTL_SRV) { - BT_ERR("%s, Not a Light CTL Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light CTL Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_ctl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Server state", __func__); + BT_ERR("Invalid Light CTL Server state"); return -EINVAL; } @@ -230,13 +230,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_CTL_TEMP_DELTA_UV_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV) { - BT_ERR("%s, Not a Light CTL Temperature Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light CTL Temperature Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light CTL Temperature Server state", __func__); + BT_ERR("Invalid Light CTL Temperature Server state"); return -EINVAL; } @@ -248,13 +248,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_HSL_LIGHTNESS_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SRV) { - BT_ERR("%s, Not a Light HSL Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light HSL Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_hsl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Server state", __func__); + BT_ERR("Invalid Light HSL Server state"); return -EINVAL; } @@ -265,13 +265,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_HSL_HUE_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV) { - BT_ERR("%s, Not a Light HSL Hue Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light HSL Hue Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Hue Server state", __func__); + BT_ERR("Invalid Light HSL Hue Server state"); return -EINVAL; } @@ -282,13 +282,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_HSL_SATURATION_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV) { - BT_ERR("%s, Not a Light HSL Saturation Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light HSL Saturation Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light HSL Saturation Server state", __func__); + BT_ERR("Invalid Light HSL Saturation Server state"); return -EINVAL; } @@ -299,13 +299,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_XYL_LIGHTNESS_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_XYL_SRV) { - BT_ERR("%s, Not a Light xyL Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light xyL Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_xyl_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Light xyL Server state", __func__); + BT_ERR("Invalid Light xyL Server state"); return -EINVAL; } @@ -316,13 +316,13 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, } case LIGHT_LC_LIGHT_ONOFF_STATE: { if (model->id != BLE_MESH_MODEL_ID_LIGHT_LC_SRV) { - BT_ERR("%s, Not a Light LC Server Model, id 0x%04x", __func__, model->id); + BT_ERR("Invalid Light LC Server, model id 0x%04x", model->id); return -EINVAL; } struct bt_mesh_light_lc_srv *srv = model->user_data; if (srv->lc == NULL) { - BT_ERR("%s, Invalid Light LC Server state", __func__); + BT_ERR("Invalid Light LC Server state"); return -EINVAL; } @@ -332,7 +332,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, break; } default: - BT_WARN("%s, Unknown binding state type 0x%02x", __func__, type); + BT_WARN("Unknown binding state type 0x%02x", type); return -EINVAL; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c index 890dcc019..ad382b7cb 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c @@ -64,7 +64,7 @@ static void send_time_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -138,7 +138,7 @@ static void send_time_status(struct bt_mesh_model *model, break; } default: - BT_WARN("%s, Unknown Time status opcode 0x%04x", __func__, opcode); + BT_WARN("Unknown Time status opcode 0x%04x", opcode); if (publish == false) { bt_mesh_free_buf(msg); } @@ -164,7 +164,7 @@ static void time_get(struct bt_mesh_model *model, u8_t prev_ttl = 0U; if (model->user_data == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -172,7 +172,7 @@ static void time_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_TIME_SRV: { struct bt_mesh_time_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Time Server state", __func__); + BT_ERR("Invalid Time Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; @@ -181,14 +181,14 @@ static void time_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_ID_TIME_SETUP_SRV: { struct bt_mesh_time_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Time Setup Server state", __func__); + BT_ERR("Invalid Time Setup Server state"); return; } rsp_ctrl = &srv->rsp_ctrl; break; } default: - BT_ERR("%s, Invalid Time Server 0x%04x", __func__, model->id); + BT_ERR("Invalid Time Server, model id 0x%04x", model->id); return; } @@ -207,7 +207,7 @@ static void time_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TIME_STATUS: { struct bt_mesh_time_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, Invalid Time Server state", __func__); + BT_ERR("Invalid Time Server state"); return; } if (srv->state->time_role != TIME_RELAY && @@ -224,7 +224,7 @@ static void time_get(struct bt_mesh_model *model, net_buf_simple_pull(buf, TAI_SECONDS_LEN); if (memcmp(status.time_status.tai_seconds, zero, TAI_SECONDS_LEN)) { if (buf->len != TAI_SECONDS_LEN) { - BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len + TAI_SECONDS_LEN); + BT_ERR("Invalid Time Status length %d", buf->len + TAI_SECONDS_LEN); return; } status.time_status.subsecond = net_buf_simple_pull_u8(buf); @@ -247,7 +247,7 @@ static void time_get(struct bt_mesh_model *model, */ if (memcmp(srv->state->time.tai_seconds, zero, TAI_SECONDS_LEN)) { if (buf->len != TAI_SECONDS_LEN) { - BT_ERR("%s, Invalid Time Status length %d", __func__, buf->len + TAI_SECONDS_LEN); + BT_ERR("Invalid Time Status length %d", buf->len + TAI_SECONDS_LEN); return; } srv->state->time.subsecond = net_buf_simple_pull_u8(buf); @@ -294,7 +294,7 @@ static void time_get(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_TIME_ROLE_STATUS; break; default: - BT_WARN("%s, Unknown Time Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Time Get opcode 0x%04x", ctx->recv_op); return; } @@ -312,7 +312,7 @@ static void time_set(struct bt_mesh_model *model, u8_t role = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -360,7 +360,7 @@ static void time_set(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET: val = net_buf_simple_pull_le16(buf); if ((val >> 15) & BIT(0)) { - BT_ERR("%s, Invalid Padding value 1", __func__); + BT_ERR("Invalid Padding value 1"); return; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { @@ -380,7 +380,7 @@ static void time_set(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_TIME_ROLE_SET: role = net_buf_simple_pull_u8(buf); if (role > TIME_CLINET) { - BT_ERR("%s, Invalid Time Role 0x%02x", __func__, role); + BT_ERR("Invalid Time Role 0x%02x", role); return; } if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { @@ -395,7 +395,7 @@ static void time_set(struct bt_mesh_model *model, opcode = BLE_MESH_MODEL_OP_TIME_ROLE_STATUS; break; default: - BT_ERR("%s, Unknown Time Set opcode 0x%04x", __func__, ctx->recv_op); + BT_ERR("Unknown Time Set opcode 0x%04x", ctx->recv_op); return; } @@ -442,7 +442,7 @@ static void send_scene_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -504,7 +504,7 @@ static void send_scene_register_status(struct bt_mesh_model *model, if (publish == false) { msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); if (msg == NULL) { - BT_ERR("%s, Failed to allocate memory", __func__); + BT_ERR("%s, Out of memory", __func__); return; } } else { @@ -525,6 +525,7 @@ static void send_scene_register_status(struct bt_mesh_model *model, if ((publish == false && total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) || (publish == true && total_len > msg->size + BLE_MESH_SERVER_TRANS_MIC_SIZE)) { /* Add this in case the message is too long */ + BT_WARN("Too large scene register status"); break; } net_buf_simple_add_le16(msg, scene->scene_number); @@ -547,7 +548,7 @@ static void scene_get(struct bt_mesh_model *model, struct bt_mesh_scene_srv *srv = model->user_data; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -570,7 +571,7 @@ static void scene_get(struct bt_mesh_model *model, send_scene_register_status(model, ctx, SCENE_SUCCESS, false); return; default: - BT_WARN("%s, Unknown Scene Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Scene Get opcode 0x%04x", ctx->recv_op); return; } } @@ -580,7 +581,7 @@ void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16 struct bt_mesh_scene_srv *srv = model->user_data; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -601,13 +602,13 @@ static void scene_recall(struct bt_mesh_model *model, int i; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } scene_number = net_buf_simple_pull_le16(buf); if (scene_number == INVALID_SCENE_NUMBER) { - BT_ERR("%s, Invalid Scene Number 0x0000", __func__); + BT_ERR("Invalid Scene Number 0x0000"); return; } tid = net_buf_simple_pull_u8(buf); @@ -636,7 +637,7 @@ static void scene_recall(struct bt_mesh_model *model, } } if (i == srv->state->scene_count) { - BT_WARN("%s, Scene Number 0x%04x not exist", __func__, scene_number); + BT_WARN("Scene Number 0x%04x not exists", scene_number); srv->state->status_code = SCENE_NOT_FOUND; if (ctx->recv_op == BLE_MESH_MODEL_OP_SCENE_RECALL) { send_scene_status(model, ctx, false); @@ -730,13 +731,13 @@ static void scene_action(struct bt_mesh_model *model, int i; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } scene_number = net_buf_simple_pull_le16(buf); if (scene_number == INVALID_SCENE_NUMBER) { - BT_ERR("%s, Invalid Scene number 0x0000", __func__); + BT_ERR("Invalid Scene number 0x0000"); return; } @@ -762,7 +763,7 @@ static void scene_action(struct bt_mesh_model *model, } /* Try to find a unset entry if no matching Scene Number is found */ if (i == srv->state->scene_count) { - BT_DBG("%s, No matching Scene Number 0x%04x found", __func__, scene_number); + BT_DBG("No matching Scene Number 0x%04x found", scene_number); for (i = 0; i < srv->state->scene_count; i++) { scene = &srv->state->scenes[i]; if (scene->scene_number == INVALID_SCENE_NUMBER) { @@ -773,7 +774,7 @@ static void scene_action(struct bt_mesh_model *model, } } if (i == srv->state->scene_count) { - BT_WARN("%s, Scene Register full", __func__); + BT_WARN("Scene Register is full!"); srv->state->status_code = SCENE_REG_FULL; /* Get the Scene Number of the currently active scene */ for (i = 0; i < srv->state->scene_count; i++) { @@ -825,7 +826,7 @@ static void scene_action(struct bt_mesh_model *model, } } if (i == srv->state->scene_count) { - BT_WARN("%s, Scene Number 0x%04x not exist", __func__, scene_number); + BT_WARN("Scene Number 0x%04x not exists", scene_number); /** * When a Scene Server receives a Scene Delete message with the Scene * Number value that does not match a Scene Number stored within the @@ -880,13 +881,13 @@ static void scene_action(struct bt_mesh_model *model, scene_model = bt_mesh_model_find(bt_mesh_model_elem(model), BLE_MESH_MODEL_ID_SCENE_SRV); if (scene_model == NULL) { - BT_ERR("%s, Scene Server is not present in the element", __func__); + BT_ERR("Scene Server not present in the element"); break; } scene_srv = scene_model->user_data; if (scene_srv == NULL || scene_srv->state == NULL) { - BT_ERR("%s, Invalid Scene Server parameter", __func__); + BT_ERR("Invalid Scene Server user data"); break; } @@ -895,7 +896,7 @@ static void scene_action(struct bt_mesh_model *model, * Add this in case the Scene Setup Server is extending the Scene * Server in another element. */ - BT_WARN("%s, Different Scene state in Scene Server & Scene Setup Server", __func__); + BT_WARN("Different Scene state in Scene Server & Scene Setup Server"); break; } @@ -911,7 +912,7 @@ static void scene_action(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Unknown Scene setup action opcode 0x%04x", __func__, ctx->recv_op); + BT_ERR("Unknown Scene setup action opcode 0x%04x", ctx->recv_op); return; } @@ -978,7 +979,7 @@ static void send_scheduler_act_status(struct bt_mesh_model *model, break; } default: - BT_ERR("%s, Invalid Scheduler Server 0x%04x", __func__, model->id); + BT_ERR("Invalid Scheduler Server, model id 0x%04x", model->id); return; } @@ -994,7 +995,7 @@ static void scheduler_get(struct bt_mesh_model *model, NET_BUF_SIMPLE_DEFINE(msg, 2 + 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1014,7 +1015,7 @@ static void scheduler_get(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET: { u8_t index = net_buf_simple_pull_u8(buf); if (index > SCHEDULE_ENTRY_MAX_INDEX) { - BT_ERR("%s, Invalid Scheduler Register Entry index 0x%02x", __func__, index); + BT_ERR("Invalid Scheduler Register Entry index 0x%02x", index); return; } @@ -1031,7 +1032,7 @@ static void scheduler_get(struct bt_mesh_model *model, return; } default: - BT_WARN("%s, Unknown Scheduler Get opcode 0x%04x", __func__, ctx->recv_op); + BT_WARN("Unknown Scheduler Get opcode 0x%04x", ctx->recv_op); return; } } @@ -1057,7 +1058,7 @@ static void scheduler_act_set(struct bt_mesh_model *model, u64_t value = 0U; if (srv == NULL || srv->state == NULL) { - BT_ERR("%s, Invalid model user_data", __func__); + BT_ERR("%s, Invalid model user data", __func__); return; } @@ -1076,22 +1077,22 @@ static void scheduler_act_set(struct bt_mesh_model *model, trans_time = (value >> 56) & BIT_MASK(8); if (index > SCHEDULE_ENTRY_MAX_INDEX) { - BT_ERR("%s, Invalid Scheduler Register Entry index 0x%02x", __func__, index); + BT_ERR("Invalid Scheduler Register Entry index 0x%02x", index); return; } if (year > SCHEDULE_YEAR_ANY_YEAR) { - BT_ERR("%s, Invalid Scheduler Register year 0x%02x", __func__, year); + BT_ERR("Invalid Scheduler Register year 0x%02x", year); return; } if (hour > SCHEDULE_HOUR_ONCE_A_DAY) { - BT_ERR("%s, Invalid Scheduler Register hour 0x%02x", __func__, hour); + BT_ERR("Invalid Scheduler Register hour 0x%02x", hour); return; } if (action > SCHEDULE_ACT_SCENE_RECALL && action != SCHEDULE_ACT_NO_ACTION) { - BT_ERR("%s, Invalid Scheduler Register action 0x%02x", __func__, action); + BT_ERR("Invalid Scheduler Register action 0x%02x", action); return; } @@ -1154,7 +1155,7 @@ static void scheduler_act_set(struct bt_mesh_model *model, /* message handlers (End) */ /* Mapping of message handlers for Time Server (0x1200) */ -const struct bt_mesh_model_op time_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_time_srv_op[] = { { BLE_MESH_MODEL_OP_TIME_GET, 0, time_get }, { BLE_MESH_MODEL_OP_TIME_STATUS, 5, time_get }, { BLE_MESH_MODEL_OP_TIME_ZONE_GET, 0, time_get }, @@ -1163,7 +1164,7 @@ const struct bt_mesh_model_op time_srv_op[] = { }; /* Mapping of message handlers for Time Setup Server (0x1201) */ -const struct bt_mesh_model_op time_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_time_setup_srv_op[] = { { BLE_MESH_MODEL_OP_TIME_SET, 10, time_set }, { BLE_MESH_MODEL_OP_TIME_ZONE_SET, 6, time_set }, { BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET, 7, time_set }, @@ -1173,7 +1174,7 @@ const struct bt_mesh_model_op time_setup_srv_op[] = { }; /* Mapping of message handlers for Scene Server (0x1203) */ -const struct bt_mesh_model_op scene_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_scene_srv_op[] = { { BLE_MESH_MODEL_OP_SCENE_GET, 0, scene_get }, { BLE_MESH_MODEL_OP_SCENE_RECALL, 3, scene_recall }, { BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK, 3, scene_recall }, @@ -1182,7 +1183,7 @@ const struct bt_mesh_model_op scene_srv_op[] = { }; /* Mapping of message handlers for Scene Setup Server (0x1204) */ -const struct bt_mesh_model_op scene_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_scene_setup_srv_op[] = { { BLE_MESH_MODEL_OP_SCENE_STORE, 2, scene_action }, { BLE_MESH_MODEL_OP_SCENE_STORE_UNACK, 2, scene_action }, { BLE_MESH_MODEL_OP_SCENE_DELETE, 2, scene_action }, @@ -1191,14 +1192,14 @@ const struct bt_mesh_model_op scene_setup_srv_op[] = { }; /* Mapping of message handlers for Scheduler Server (0x1206) */ -const struct bt_mesh_model_op scheduler_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_scheduler_srv_op[] = { { BLE_MESH_MODEL_OP_SCHEDULER_GET, 0, scheduler_get }, { BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET, 1, scheduler_get }, BLE_MESH_MODEL_OP_END, }; /* Mapping of message handlers for Scheduler Setup Server (0x1207) */ -const struct bt_mesh_model_op scheduler_setup_srv_op[] = { +const struct bt_mesh_model_op bt_mesh_scheduler_setup_srv_op[] = { { BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET, 10, scheduler_act_set }, { BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK, 10, scheduler_act_set }, BLE_MESH_MODEL_OP_END, @@ -1209,13 +1210,13 @@ static int check_scene_server_init(struct bt_mesh_scenes_state *state) int i; if (state->scene_count == 0U || state->scenes == NULL) { - BT_ERR("%s, Invalid Scene state", __func__); + BT_ERR("Invalid Scene state"); return -EINVAL; } for (i = 0; i < state->scene_count; i++) { if (state->scenes[i].scene_value == NULL) { - BT_ERR("%s, Invalid Scene value, index %d", __func__, i); + BT_ERR("Invalid Scene value, index %d", i); return -EINVAL; } } @@ -1226,7 +1227,7 @@ static int check_scene_server_init(struct bt_mesh_scenes_state *state) static int time_scene_server_init(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Time Scene Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Time Scene Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -1234,7 +1235,7 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_TIME_SRV: { struct bt_mesh_time_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Time State", __func__); + BT_ERR("Invalid Time State"); return -EINVAL; } srv->model = model; @@ -1243,7 +1244,7 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_TIME_SETUP_SRV: { struct bt_mesh_time_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Time State", __func__); + BT_ERR("Invalid Time State"); return -EINVAL; } srv->model = model; @@ -1252,7 +1253,7 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SCENE_SRV: { struct bt_mesh_scene_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Scene State", __func__); + BT_ERR("Invalid Scene State"); return -EINVAL; } if (check_scene_server_init(srv->state)) { @@ -1268,7 +1269,7 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SCENE_SETUP_SRV: { struct bt_mesh_scene_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Scene State", __func__); + BT_ERR("Invalid Scene State"); return -EINVAL; } if (check_scene_server_init(srv->state)) { @@ -1280,11 +1281,11 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SCHEDULER_SRV: { struct bt_mesh_scheduler_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Scheduler State", __func__); + BT_ERR("Invalid Scheduler State"); return -EINVAL; } if (srv->state->schedule_count == 0U || srv->state->schedules == NULL) { - BT_ERR("%s, NULL Register Schedule", __func__); + BT_ERR("Invalid Register Schedule"); return -EINVAL; } srv->model = model; @@ -1293,18 +1294,18 @@ static int time_scene_server_init(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV: { struct bt_mesh_scheduler_setup_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Scheduler State", __func__); + BT_ERR("Invalid Scheduler State"); return -EINVAL; } if (srv->state->schedule_count == 0U || srv->state->schedules == NULL) { - BT_ERR("%s, NULL Register Schedule", __func__); + BT_ERR("Invalid Register Schedule"); return -EINVAL; } srv->model = model; break; } default: - BT_WARN("%s, Unknown Time Scene Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Time Scene Server, model id 0x%04x", model->id); return -EINVAL; } @@ -1313,10 +1314,10 @@ static int time_scene_server_init(struct bt_mesh_model *model) return 0; } -int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary) +static int time_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Time Server has no publication support", __func__); + BT_ERR("Time Server has no publication support"); return -EINVAL; } @@ -1326,33 +1327,33 @@ int bt_mesh_time_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_TIME_SETUP_SRV) == NULL) { - BT_WARN("%s, Time Setup Server is not present", __func__); + BT_WARN("Time Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return time_scene_server_init(model); } -int bt_mesh_time_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int time_setup_srv_init(struct bt_mesh_model *model) { /* This model does not support subscribing nor publishing */ if (model->pub) { - BT_ERR("%s, Time Setup Server shall not support publication", __func__); + BT_ERR("Time Setup Server shall not support publication"); return -EINVAL; } return time_scene_server_init(model); } -int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary) +static int scene_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Scene Server has no publication support", __func__); + BT_ERR("Scene Server has no publication support"); return -EINVAL; } /* The model may be present only on the Primary element of a node. */ - if (primary == false) { - BT_WARN("%s, Scene Server is not on the Primary element", __func__); + if (!bt_mesh_model_in_primary(model)) { + BT_WARN("Scene Server not on the Primary element"); /* Just give a warning here, continue with the initialization */ } /** @@ -1361,32 +1362,32 @@ int bt_mesh_scene_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SCENE_SETUP_SRV) == NULL) { - BT_WARN("%s, Scene Setup Server is not present", __func__); + BT_WARN("Scene Setup Server not present"); /* Just give a warning here, continue with the initialization */ } return time_scene_server_init(model); } -int bt_mesh_scene_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int scene_setup_srv_init(struct bt_mesh_model *model) { /* The model may be present only on the Primary element of a node. */ - if (primary == false) { - BT_WARN("%s, Scene Setup Server is not on the Primary element", __func__); + if (!bt_mesh_model_in_primary(model)) { + BT_WARN("Scene Setup Server not on the Primary element"); /* Just give a warning here, continue with the initialization */ } return time_scene_server_init(model); } -int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary) +static int scheduler_srv_init(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Scheduler Server has no publication support", __func__); + BT_ERR("Scheduler Server has no publication support"); return -EINVAL; } /* The model may be present only on the Primary element of a node. */ - if (primary == false) { - BT_WARN("%s, Scheduler Server is not on the Primary element", __func__); + if (!bt_mesh_model_in_primary(model)) { + BT_WARN("Scheduler Server not on the Primary element"); /* Just give a warning here, continue with the initialization */ } /** @@ -1396,21 +1397,21 @@ int bt_mesh_scheduler_srv_init(struct bt_mesh_model *model, bool primary) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV) == NULL) { - BT_WARN("%s, Scheduler Setup Server is not present", __func__); + BT_WARN("Scheduler Setup Server not present"); /* Just give a warning here, continue with the initialization */ } if (bt_mesh_model_find(element, BLE_MESH_MODEL_ID_TIME_SRV) == NULL) { - BT_WARN("%s, Time Server is not present", __func__); + BT_WARN("Time Server not present"); /* Just give a warning here, continue with the initialization */ } return time_scene_server_init(model); } -int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary) +static int scheduler_setup_srv_init(struct bt_mesh_model *model) { /* The model may be present only on the Primary element of a node. */ - if (primary == false) { - BT_WARN("%s, Scheduler Setup Server is not on the Primary element", __func__); + if (!bt_mesh_model_in_primary(model)) { + BT_WARN("Scheduler Setup Server not on the Primary element"); /* Just give a warning here, continue with the initialization */ } return time_scene_server_init(model); @@ -1419,7 +1420,7 @@ int bt_mesh_scheduler_setup_srv_init(struct bt_mesh_model *model, bool primary) static int time_scene_server_deinit(struct bt_mesh_model *model) { if (model->user_data == NULL) { - BT_ERR("%s, No Time Scene Server context provided, model_id 0x%04x", __func__, model->id); + BT_ERR("Invalid Time Scene Server user data, model id 0x%04x", model->id); return -EINVAL; } @@ -1427,7 +1428,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model) case BLE_MESH_MODEL_ID_SCENE_SRV: { struct bt_mesh_scene_srv *srv = model->user_data; if (srv->state == NULL) { - BT_ERR("%s, NULL Scene State", __func__); + BT_ERR("Invalid Scene State"); return -EINVAL; } if (check_scene_server_init(srv->state)) { @@ -1440,7 +1441,7 @@ static int time_scene_server_deinit(struct bt_mesh_model *model) break; } default: - BT_WARN("%s, Unknown Time Scene Server Model, model_id 0x%04x", __func__, model->id); + BT_WARN("Unknown Time Scene Server, model id 0x%04x", model->id); return -EINVAL; } @@ -1449,52 +1450,82 @@ static int time_scene_server_deinit(struct bt_mesh_model *model) return 0; } -int bt_mesh_time_srv_deinit(struct bt_mesh_model *model, bool primary) +static int time_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Time Server has no publication support", __func__); + BT_ERR("Time Server has no publication support"); return -EINVAL; } return time_scene_server_deinit(model); } -int bt_mesh_time_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int time_setup_srv_deinit(struct bt_mesh_model *model) { if (model->pub) { - BT_ERR("%s, Time Setup Server shall not support publication", __func__); + BT_ERR("Time Setup Server shall not support publication"); return -EINVAL; } return time_scene_server_deinit(model); } -int bt_mesh_scene_srv_deinit(struct bt_mesh_model *model, bool primary) +static int scene_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Scene Server has no publication support", __func__); + BT_ERR("Scene Server has no publication support"); return -EINVAL; } return time_scene_server_deinit(model); } -int bt_mesh_scene_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int scene_setup_srv_deinit(struct bt_mesh_model *model) { return time_scene_server_deinit(model); } -int bt_mesh_scheduler_srv_deinit(struct bt_mesh_model *model, bool primary) +static int scheduler_srv_deinit(struct bt_mesh_model *model) { if (model->pub == NULL) { - BT_ERR("%s, Scheduler Server has no publication support", __func__); + BT_ERR("Scheduler Server has no publication support"); return -EINVAL; } return time_scene_server_deinit(model); } -int bt_mesh_scheduler_setup_srv_deinit(struct bt_mesh_model *model, bool primary) +static int scheduler_setup_srv_deinit(struct bt_mesh_model *model) { return time_scene_server_deinit(model); } + +const struct bt_mesh_model_cb bt_mesh_time_srv_cb = { + .init = time_srv_init, + .deinit = time_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_time_setup_srv_cb = { + .init = time_setup_srv_init, + .deinit = time_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_scene_srv_cb = { + .init = scene_srv_init, + .deinit = scene_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb = { + .init = scene_setup_srv_init, + .deinit = scene_setup_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb = { + .init = scheduler_srv_init, + .deinit = scheduler_srv_deinit, +}; + +const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb = { + .init = scheduler_setup_srv_init, + .deinit = scheduler_setup_srv_deinit, +}; diff --git a/components/bt/include/esp_bt.h b/components/bt/include/esp_bt.h index acf346aab..fb38fe68d 100644 --- a/components/bt/include/esp_bt.h +++ b/components/bt/include/esp_bt.h @@ -25,7 +25,7 @@ extern "C" { #endif -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200106 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200611 /** * @brief Bluetooth mode for controller enable/disable @@ -102,6 +102,12 @@ the adv packet will be discarded until the memory is restored. */ #define BTDM_CTRL_AUTO_LATENCY_EFF false #endif +#ifdef CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF +#define BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF +#else +#define BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF false +#endif + #define BTDM_CONTROLLER_BLE_MAX_CONN_LIMIT 9 //Maximum BLE connection limitation #define BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_LIMIT 7 //Maximum ACL connection limitation #define BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_LIMIT 3 //Maximum SCO/eSCO connection limitation @@ -115,7 +121,7 @@ the adv packet will be discarded until the memory is restored. */ .hci_uart_no = BT_HCI_UART_NO_DEFAULT, \ .hci_uart_baudrate = BT_HCI_UART_BAUDRATE_DEFAULT, \ .scan_duplicate_mode = SCAN_DUPLICATE_MODE, \ - .scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \ + .scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \ .normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \ .mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \ .send_adv_reserved_size = SCAN_SEND_ADV_RESERVED_SIZE, \ @@ -125,6 +131,7 @@ the adv packet will be discarded until the memory is restored. */ .bt_max_acl_conn = CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF, \ .bt_sco_datapath = CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF, \ .auto_latency = BTDM_CTRL_AUTO_LATENCY_EFF, \ + .bt_legacy_auth_vs_evt = BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF, \ .bt_max_sync_conn = CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ }; @@ -157,6 +164,7 @@ typedef struct { uint8_t bt_max_acl_conn; /*!< BR/EDR maximum ACL connection numbers */ uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module */ bool auto_latency; /*!< BLE auto latency, used to enhance classic BT performance */ + bool bt_legacy_auth_vs_evt; /*!< BR/EDR Legacy auth complete event required to protect from BIAS attack */ /* * Following parameters can not be configured runtime when call esp_bt_controller_init() * It will be overwrite with a constant value which in menuconfig or from a macro. diff --git a/components/bt/lib b/components/bt/lib index 63e7a37c6..e96d99f61 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit 63e7a37c6c6c5647ed09ff5196c0b76ebd98de16 +Subproject commit e96d99f61358eb132d493e3ae3e541caecf8948e diff --git a/components/cxx/cxx_exception_stubs.cpp b/components/cxx/cxx_exception_stubs.cpp index f09f946dd..7a1898484 100644 --- a/components/cxx/cxx_exception_stubs.cpp +++ b/components/cxx/cxx_exception_stubs.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,12 @@ extern "C" void __cxx_fatal_exception_int(int i) abort(); } +extern "C" void __cxx_fatal_exception_regex_error_type(std::regex_constants::error_type error) +{ + printf("%s Regex error (%u)\n", FATAL_EXCEPTION, error); + abort(); +} + #if !GCC_NOT_5_2_0 void std::__throw_bad_exception(void) __attribute__((alias("__cxx_fatal_exception"))); void std::__throw_bad_alloc(void) __attribute__((alias("__cxx_fatal_exception"))); @@ -55,6 +62,7 @@ void std::__throw_ios_failure(const char*) __attribute__((alias("__cxx_fatal_exc void std::__throw_system_error(int) __attribute__((alias("__cxx_fatal_exception_int"))); void std::__throw_bad_function_call(void) __attribute__((alias("__cxx_fatal_exception"))); void std::__throw_future_error(int) __attribute__((alias("__cxx_fatal_exception_int"))); +void std::__throw_regex_error(std::regex_constants::error_type) __attribute__((alias("__cxx_fatal_exception_regex_error_type"))); #endif /* The following definitions are needed because libstdc++ is also compiled with diff --git a/components/driver/i2s.c b/components/driver/i2s.c index 843539593..58deb4d2f 100644 --- a/components/driver/i2s.c +++ b/components/driver/i2s.c @@ -492,6 +492,15 @@ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t b rate, real_rate, bits, clkmInteger, bck, (double)I2S_BASE_CLK / mclk, real_rate*bits*channel, 64, clkmDecimals); } + if (p_i2s_obj[i2s_num]->mode & I2S_MODE_TX) { + p_i2s_obj[i2s_num]->tx->curr_ptr = NULL; + p_i2s_obj[i2s_num]->tx->rw_pos = 0; + } + if (p_i2s_obj[i2s_num]->mode & I2S_MODE_RX) { + p_i2s_obj[i2s_num]->rx->curr_ptr = NULL; + p_i2s_obj[i2s_num]->rx->rw_pos = 0; + } + I2S[i2s_num]->sample_rate_conf.tx_bits_mod = bits; I2S[i2s_num]->sample_rate_conf.rx_bits_mod = bits; @@ -673,17 +682,16 @@ esp_err_t i2s_start(i2s_port_t i2s_num) I2S_CHECK((i2s_num < I2S_NUM_MAX), "i2s_num error", ESP_ERR_INVALID_ARG); //start DMA link I2S_ENTER_CRITICAL(); - i2s_reset_fifo(i2s_num); + I2S[i2s_num]->conf.tx_reset = 1; + I2S[i2s_num]->conf.tx_reset = 0; + I2S[i2s_num]->conf.rx_reset = 1; + I2S[i2s_num]->conf.rx_reset = 0; //reset dma I2S[i2s_num]->lc_conf.in_rst = 1; I2S[i2s_num]->lc_conf.in_rst = 0; I2S[i2s_num]->lc_conf.out_rst = 1; I2S[i2s_num]->lc_conf.out_rst = 0; - - I2S[i2s_num]->conf.tx_reset = 1; - I2S[i2s_num]->conf.tx_reset = 0; - I2S[i2s_num]->conf.rx_reset = 1; - I2S[i2s_num]->conf.rx_reset = 0; + i2s_reset_fifo(i2s_num); esp_intr_disable(p_i2s_obj[i2s_num]->i2s_isr_handle); I2S[i2s_num]->int_clr.val = 0xFFFFFFFF; @@ -898,7 +906,6 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co adc_power_always_on(); } // configure I2S data port interface. - i2s_reset_fifo(i2s_num); //reset i2s I2S[i2s_num]->conf.tx_reset = 1; I2S[i2s_num]->conf.tx_reset = 0; @@ -910,6 +917,7 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co I2S[i2s_num]->lc_conf.in_rst = 0; I2S[i2s_num]->lc_conf.out_rst = 1; I2S[i2s_num]->lc_conf.out_rst = 0; + i2s_reset_fifo(i2s_num); //Enable and configure DMA I2S[i2s_num]->lc_conf.check_owner = 0; diff --git a/components/driver/include/driver/periph_ctrl.h b/components/driver/include/driver/periph_ctrl.h index 9689a8cb2..1d010c0c2 100644 --- a/components/driver/include/driver/periph_ctrl.h +++ b/components/driver/include/driver/periph_ctrl.h @@ -62,6 +62,29 @@ void periph_module_disable(periph_module_t periph); */ void periph_module_reset(periph_module_t periph); +/** + * @brief enable wifi bt common module + * + * @note If wifi_bt_common_module_enable is called a number of times, + * wifi_bt_common_module_disable has to be called the same number of times + * in order to put the peripheral into disabled state. + * + * @return NULL + * + */ +void wifi_bt_common_module_enable(void); + +/** + * @brief disable wifi bt common module + * + * @note If wifi_bt_common_module_enable is called a number of times, + * wifi_bt_common_module_disable has to be called the same number of times + * in order to put the peripheral into disabled state. + * + * @return NULL + * + */ +void wifi_bt_common_module_disable(void); #ifdef __cplusplus } diff --git a/components/driver/mcpwm.c b/components/driver/mcpwm.c index 1ba554391..3674f15f1 100644 --- a/components/driver/mcpwm.c +++ b/components/driver/mcpwm.c @@ -103,8 +103,8 @@ esp_err_t mcpwm_set_pin(mcpwm_unit_t mcpwm_num, const mcpwm_pin_config_t *mcpwm_ mcpwm_gpio_init(mcpwm_num, MCPWM_SYNC_1, mcpwm_pin->mcpwm_sync1_in_num); //SYNC1 mcpwm_gpio_init(mcpwm_num, MCPWM_SYNC_2, mcpwm_pin->mcpwm_sync2_in_num); //SYNC2 mcpwm_gpio_init(mcpwm_num, MCPWM_FAULT_0, mcpwm_pin->mcpwm_fault0_in_num); //FAULT0 - mcpwm_gpio_init(mcpwm_num, MCPWM_FAULT_0, mcpwm_pin->mcpwm_fault1_in_num); //FAULT1 - mcpwm_gpio_init(mcpwm_num, MCPWM_FAULT_0, mcpwm_pin->mcpwm_fault2_in_num); //FAULT2 + mcpwm_gpio_init(mcpwm_num, MCPWM_FAULT_1, mcpwm_pin->mcpwm_fault1_in_num); //FAULT1 + mcpwm_gpio_init(mcpwm_num, MCPWM_FAULT_2, mcpwm_pin->mcpwm_fault2_in_num); //FAULT2 mcpwm_gpio_init(mcpwm_num, MCPWM_CAP_0, mcpwm_pin->mcpwm_cap0_in_num); //CAP0 mcpwm_gpio_init(mcpwm_num, MCPWM_CAP_1, mcpwm_pin->mcpwm_cap1_in_num); //CAP1 mcpwm_gpio_init(mcpwm_num, MCPWM_CAP_2, mcpwm_pin->mcpwm_cap2_in_num); //CAP2 diff --git a/components/driver/periph_ctrl.c b/components/driver/periph_ctrl.c index e877aa9b2..9083ccf95 100644 --- a/components/driver/periph_ctrl.c +++ b/components/driver/periph_ctrl.c @@ -20,6 +20,7 @@ #include "driver/periph_ctrl.h" static portMUX_TYPE periph_spinlock = portMUX_INITIALIZER_UNLOCKED; +static uint8_t ref_counts = 0; /* Static functions to return register address & mask for clk_en / rst of each peripheral */ static uint32_t get_clk_en_mask(periph_module_t periph); @@ -257,4 +258,26 @@ static uint32_t get_rst_en_reg(periph_module_t periph) } } +IRAM_ATTR void wifi_bt_common_module_enable(void) +{ + portENTER_CRITICAL_SAFE(&periph_spinlock); + if (ref_counts == 0) { + DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG,DPORT_WIFI_CLK_WIFI_BT_COMMON_M); + DPORT_CLEAR_PERI_REG_MASK(DPORT_CORE_RST_EN_REG,0); + } + + ref_counts++; + portEXIT_CRITICAL_SAFE(&periph_spinlock); +} +IRAM_ATTR void wifi_bt_common_module_disable(void) +{ + portENTER_CRITICAL_SAFE(&periph_spinlock); + ref_counts--; + if (ref_counts == 0) { + DPORT_CLEAR_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG,DPORT_WIFI_CLK_WIFI_BT_COMMON_M); + DPORT_SET_PERI_REG_MASK(DPORT_CORE_RST_EN_REG,0); + } + + portEXIT_CRITICAL_SAFE(&periph_spinlock); +} \ No newline at end of file diff --git a/components/driver/rtc_module.c b/components/driver/rtc_module.c index be428fc14..c5b515fc5 100644 --- a/components/driver/rtc_module.c +++ b/components/driver/rtc_module.c @@ -132,7 +132,7 @@ static const char TAG[] = "adc"; static inline void dac_output_set_enable(dac_channel_t channel, bool enable); static inline void adc1_hall_enable(bool enable); - +static inline void dac_rtc_sync_by_adc(bool enable); /*--------------------------------------------------------------- RTC IO @@ -1465,6 +1465,9 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten) RTC_MODULE_CHECK(atten < ADC_ATTEN_MAX, "ADC Atten Err", ESP_ERR_INVALID_ARG); adc_gpio_init(ADC_UNIT_1, channel); adc_set_atten(ADC_UNIT_1, channel, atten); + /* Workaround: Disable the synchronization operation function of ADC1 and DAC. + If enabled(default), ADC RTC controller sampling will cause the DAC channel output voltage. */ + dac_rtc_sync_by_adc(false); return ESP_OK; } @@ -1806,12 +1809,25 @@ static inline void dac_output_set_enable(dac_channel_t channel, bool enable) RTCIO.pad_dac[channel-DAC_CHANNEL_1].xpd_dac = enable; } +/** + * Enable/disable the synchronization operation function of ADC1 and DAC. + * + * @note If enabled(default), ADC RTC controller sampling will cause the DAC channel output voltage. + * + * @param enable Enable or disable adc and dac synchronization function. + */ +static inline void dac_rtc_sync_by_adc(bool enable) +{ + SENS.sar_meas_ctrl2.sar1_dac_xpd_fsm = enable; +} + esp_err_t dac_output_enable(dac_channel_t channel) { RTC_MODULE_CHECK((channel >= DAC_CHANNEL_1) && (channel < DAC_CHANNEL_MAX), DAC_ERR_STR_CHANNEL_ERROR, ESP_ERR_INVALID_ARG); dac_rtc_pad_init(channel); portENTER_CRITICAL(&rtc_spinlock); dac_output_set_enable(channel, true); + dac_rtc_sync_by_adc(false); portEXIT_CRITICAL(&rtc_spinlock); return ESP_OK; diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 61376c9b3..755f01951 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -494,12 +494,12 @@ Specify ``SPI_DEVICE_NO_DUMMY`` to ignore this checking. Then you can output dat if (dev_config->flags&SPI_DEVICE_CLK_AS_CS) { spihost[host]->hw->pin.master_ck_sel |= (1<hw->pin.master_ck_sel &= (1<hw->pin.master_ck_sel &= ~(1<flags&SPI_DEVICE_POSITIVE_CS) { spihost[host]->hw->pin.master_cs_pol |= (1<hw->pin.master_cs_pol &= (1<hw->pin.master_cs_pol &= ~(1<hw->ctrl2.mosi_delay_mode = 0; spihost[host]->hw->ctrl2.mosi_delay_num = 0; diff --git a/components/driver/test/test_gpio.c b/components/driver/test/test_gpio.c index 4b164da44..5c9b19929 100644 --- a/components/driver/test/test_gpio.c +++ b/components/driver/test/test_gpio.c @@ -417,7 +417,7 @@ TEST_CASE("GPIO io pull up/down function", "[gpio]") TEST_CASE("GPIO output and input mode test", "[gpio][test_env=UT_T1_GPIO]") { - //connect io18 and io5 + //connect io18 and io19 gpio_config_t output_io = init_io(GPIO_OUTPUT_IO); gpio_config_t input_io = init_io(GPIO_INPUT_IO); gpio_config(&output_io); @@ -456,18 +456,12 @@ TEST_CASE("GPIO output and input mode test", "[gpio][test_env=UT_T1_GPIO]") TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_INPUT_IO), 0, "direction GPIO_MODE_OUTPUT set error, it can't output"); // GPIO_MODE_INPUT_OUTPUT mode - // output test - level = gpio_get_level(GPIO_INPUT_IO); gpio_set_direction(GPIO_OUTPUT_IO, GPIO_MODE_INPUT_OUTPUT); gpio_set_direction(GPIO_INPUT_IO, GPIO_MODE_INPUT); - gpio_set_level(GPIO_OUTPUT_IO, !level); - TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_INPUT_IO), !level, "direction set error, it can't output"); - // input test - gpio_set_direction(GPIO_OUTPUT_IO, GPIO_MODE_OUTPUT); - gpio_set_direction(GPIO_INPUT_IO, GPIO_MODE_INPUT_OUTPUT); - level = gpio_get_level(GPIO_INPUT_IO); - gpio_set_level(GPIO_OUTPUT_IO, !level); - TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_INPUT_IO), !level, "direction set error, it can't output"); + gpio_set_level(GPIO_OUTPUT_IO, 1); + TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_OUTPUT_IO), 1, "direction set error, it can't output"); + gpio_set_level(GPIO_OUTPUT_IO, 0); + TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_OUTPUT_IO), 0, "direction set error, it can't output"); } TEST_CASE("GPIO repeate call service and isr has no memory leak test","[gpio][test_env=UT_T1_GPIO][timeout=90]") diff --git a/components/driver/test/test_spi_master.c b/components/driver/test/test_spi_master.c index 29da5b8c8..89d249660 100644 --- a/components/driver/test/test_spi_master.c +++ b/components/driver/test/test_spi_master.c @@ -997,7 +997,9 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%d", t_flight_sorted[i]); } +#ifndef CONFIG_SPIRAM_SUPPORT TEST_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_NO_POLLING, "%d us", t_flight_sorted[(TEST_TIMES+1)/2]); +#endif //acquire the bus to send polling transactions faster ret = spi_device_acquire_bus(spi, portMAX_DELAY); @@ -1012,7 +1014,9 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%d", t_flight_sorted[i]); } +#ifndef CONFIG_SPIRAM_SUPPORT TEST_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_POLLING, "%d us", t_flight_sorted[(TEST_TIMES+1)/2]); +#endif //release the bus spi_device_release_bus(spi); @@ -1030,7 +1034,9 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%d", t_flight_sorted[i]); } +#ifndef CONFIG_SPIRAM_SUPPORT TEST_PERFORMANCE_LESS_THAN( SPI_PER_TRANS_NO_POLLING_NO_DMA, "%d us", t_flight_sorted[(TEST_TIMES+1)/2]); +#endif //acquire the bus to send polling transactions faster ret = spi_device_acquire_bus(spi, portMAX_DELAY); @@ -1044,7 +1050,9 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%d", t_flight_sorted[i]); } +#ifndef CONFIG_SPIRAM_SUPPORT TEST_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_POLLING_NO_DMA, "%d us", t_flight_sorted[(TEST_TIMES+1)/2]); +#endif //release the bus spi_device_release_bus(spi); diff --git a/components/driver/test/test_uart.c b/components/driver/test/test_uart.c index db2146efd..fc7939265 100644 --- a/components/driver/test/test_uart.c +++ b/components/driver/test/test_uart.c @@ -374,5 +374,5 @@ static void rs485_master() * correctness of RS485 interface channel communication. It requires * RS485 bus driver hardware to be connected to boards. */ -TEST_CASE_MULTIPLE_DEVICES("RS485 half duplex uart multiple devices test.", "[driver_RS485][test_env=UT_T2_RS485]", rs485_master, rs485_slave); +TEST_CASE_MULTIPLE_DEVICES("RS485 half duplex uart multiple devices test.", "[driver_RS485][ignore][test_env=UT_T2_RS485]", rs485_master, rs485_slave); diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 0dcb91890..78914261e 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -6,6 +6,11 @@ menu "ESP32-specific" default "y" if IDF_TARGET="esp32" default "n" + config ESP32_ECO3_CACHE_LOCK_FIX + bool + default y + depends on !FREERTOS_UNICORE && SPIRAM_SUPPORT + choice ESP32_REV_MIN prompt "Minimum Supported ESP32 Revision" default ESP32_REV_MIN_0 @@ -21,6 +26,7 @@ menu "ESP32-specific" bool "Rev 2" config ESP32_REV_MIN_3 bool "Rev 3" + select INT_WDT if ESP32_ECO3_CACHE_LOCK_FIX endchoice config ESP32_REV_MIN diff --git a/components/esp32/Makefile.projbuild b/components/esp32/Makefile.projbuild index b99415538..00d5183f5 100644 --- a/components/esp32/Makefile.projbuild +++ b/components/esp32/Makefile.projbuild @@ -43,7 +43,7 @@ ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","") CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL endif ESP32_LINKER_SCRIPT_TEMPLATE := $(COMPONENT_PATH)/ld/esp32.project.ld.in -ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(abspath $(BUILD_DIR_BASE)/esp32) +ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(realpath $(BUILD_DIR_BASE)/esp32) # Target to generate linker script generator from fragments presented by each of # the components diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index 887402030..84a7d423a 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -387,6 +387,10 @@ void start_cpu0_default(void) esp_int_wdt_init(); //Initialize the interrupt watch dog for CPU0. esp_int_wdt_cpu_init(); +#else +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX + assert(!soc_has_cache_lock_bug() && "ESP32 Rev 3 + Dual Core + PSRAM requires INT WDT enabled in project config!"); +#endif #endif esp_cache_err_int_init(); esp_crosscore_int_init(); diff --git a/components/esp32/dport_panic_highint_hdl.S b/components/esp32/dport_panic_highint_hdl.S index 35412deba..5a206bba7 100644 --- a/components/esp32/dport_panic_highint_hdl.S +++ b/components/esp32/dport_panic_highint_hdl.S @@ -17,10 +17,12 @@ #include #include #include "freertos/xtensa_context.h" +#include "freertos/xtensa_rtos.h" #include "esp_panic.h" #include "sdkconfig.h" #include "soc/soc.h" #include "soc/dport_reg.h" +#include "soc/timer_group_reg.h" /* @@ -37,7 +39,23 @@ Interrupt , a high-priority interrupt, is used for several things: #define L4_INTR_A4_OFFSET 8 .data _l4_intr_stack: - .space L4_INTR_STACK_SIZE + .space L4_INTR_STACK_SIZE*portNUM_PROCESSORS /* This allocates stacks for each individual CPU. */ + +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_INT_WDT + .global _l4_intr_livelock_counter + .global _l4_intr_livelock_max + .align 16 +_l4_intr_livelock_counter: + .word 0 +_l4_intr_livelock_max: + .word 0 +_l4_intr_livelock_sync: + .word 0, 0 +_l4_intr_livelock_app: + .word 0 +_l4_intr_livelock_pro: + .word 0 +#endif .section .iram1,"ax" .global xt_highint4 @@ -52,8 +70,24 @@ xt_highint4: bnez a0, .handle_dport_access_int #endif // CONFIG_FREERTOS_UNICORE +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_INT_WDT + /* See if we're here for the tg1 watchdog interrupt */ + rsr a0, INTERRUPT + extui a0, a0, ETS_T1_WDT_INUM, 1 + beqz a0, 1f + + wsr a5, depc /* use DEPC as temp storage */ + movi a0, _l4_intr_livelock_counter + l32i a0, a0, 0 + movi a5, _l4_intr_livelock_max + l32i a5, a5, 0 + bltu a0, a5, .handle_livelock_int /* _l4_intr_livelock_counter < _l4_intr_livelock_max */ + + rsr a5, depc /* restore a5 */ +#endif + /* Allocate exception frame and save minimal context. */ - mov a0, sp +1: mov a0, sp addi sp, sp, -XT_STK_FRMSZ s32i a0, sp, XT_STK_A1 #if XCHAL_HAVE_WINDOWED @@ -129,6 +163,257 @@ xt_highint4: rfi 4 +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_INT_WDT + +/* +-------------------------------------------------------------------------------- + Macro intr_matrix_map - Attach an CPU interrupt to a hardware source. + + Input : "addr" - Interrupt map configuration base address + Input : "src" - Interrupt source. + Input : "inum" - Interrupt number. +-------------------------------------------------------------------------------- +*/ + .macro intr_matrix_map addr src inum + movi a2, \src + slli a2, a2, 2 + movi a3, \addr + add a3, a3, a2 + movi a2, \inum + s32i a2, a3, 0 + memw + .endm + +/* +-------------------------------------------------------------------------------- + Macro wdt_clr_intr_status - Clear the WDT interrupt status. + Macro wdt_feed - Feed the WDT. + + Input : "dev" - Beginning address of the peripheral registers +-------------------------------------------------------------------------------- +*/ + +#define TIMG1_REG_OFFSET(reg) ((reg) - REG_TIMG_BASE(1)) +#define TIMG1_WDTWPROTECT_OFFSET TIMG1_REG_OFFSET(TIMG_WDTWPROTECT_REG(1)) +#define TIMG1_INT_CLR_OFFSET TIMG1_REG_OFFSET(TIMG_INT_CLR_TIMERS_REG(1)) +#define TIMG1_WDT_STG0_HOLD_OFFSET TIMG1_REG_OFFSET(TIMG_WDTCONFIG2_REG(1)) +#define TIMG1_WDT_STG1_HOLD_OFFSET TIMG1_REG_OFFSET(TIMG_WDTCONFIG3_REG(1)) +#define TIMG1_WDT_FEED_OFFSET TIMG1_REG_OFFSET(TIMG_WDTFEED_REG(1)) + + .macro wdt_clr_intr_status dev + movi a2, \dev + movi a3, TIMG_WDT_WKEY_VALUE + s32i a3, a2, TIMG1_WDTWPROTECT_OFFSET /* disable write protect */ + memw + l32i a4, a2, TIMG1_INT_CLR_OFFSET + memw + movi a3, 4 + or a3, a4, a3 + s32i a3, a2, TIMG1_INT_CLR_OFFSET /* clear 1st stage timeout interrupt */ + memw + movi a3, 0 + s32i a3, a2, TIMG1_WDTWPROTECT_OFFSET /* enable write protect */ + memw + .endm + + .macro wdt_feed dev + movi a2, \dev + movi a3, TIMG_WDT_WKEY_VALUE + s32i a3, a2, TIMG1_WDTWPROTECT_OFFSET /* disable write protect */ + memw + movi a4, _l4_intr_livelock_max + l32i a4, a4, 0 + memw + addi a4, a4, 1 + movi a3, (CONFIG_INT_WDT_TIMEOUT_MS<<1) + quou a3, a3, a4 + s32i a3, a2, TIMG1_WDT_STG0_HOLD_OFFSET /* set timeout before interrupt */ + memw + movi a3, (CONFIG_INT_WDT_TIMEOUT_MS<<2) + s32i a3, a2, TIMG1_WDT_STG1_HOLD_OFFSET /* set timeout before system reset */ + memw + movi a3, 1 + s32i a3, a2, TIMG1_WDT_FEED_OFFSET /* feed wdt */ + memw + movi a3, 0 + s32i a3, a2, TIMG1_WDTWPROTECT_OFFSET /* enable write protect */ + memw + .endm + + .align 4 +.handle_livelock_int: + + getcoreid a5 + + /* Save A2, A3, A4 so we can use those registers */ + movi a0, L4_INTR_STACK_SIZE + mull a5, a5, a0 + movi a0, _l4_intr_stack + add a0, a0, a5 + s32i a2, a0, L4_INTR_A2_OFFSET + s32i a3, a0, L4_INTR_A3_OFFSET + s32i a4, a0, L4_INTR_A4_OFFSET + + /* Here, we can use a0, a2, a3, a4, a5 registers */ + getcoreid a5 + + rsil a0, CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL /* disable nested interrupt */ + + beqz a5, 1f + movi a2, _l4_intr_livelock_app + l32i a3, a2, 0 + addi a3, a3, 1 + s32i a3, a2, 0 + + /* Dual core synchronization, ensuring that both cores enter interrupts */ +1: movi a4, 0x1 + movi a2, _l4_intr_livelock_sync + addx4 a3, a5, a2 + s32i a4, a3, 0 + +1: movi a2, _l4_intr_livelock_sync + movi a3, 1 + addx4 a3, a3, a2 + l32i a2, a2, 0 + l32i a3, a3, 0 + and a2, a2, a3 + beqz a2, 1b + + beqz a5, 1f /* Pro cpu (Core 0) jump bypass */ + + movi a2, _l4_intr_livelock_app + l32i a2, a2, 0 + bnei a2, 2, 1f + movi a2, _l4_intr_livelock_counter /* _l4_intr_livelock_counter++ */ + l32i a3, a2, 0 + addi a3, a3, 1 + s32i a3, a2, 0 + + /* + The delay time can be calculated by the following formula: + T = ceil(0.25 + max(t1, t2)) us + + t1 = 80 / f1, t2 = (1 + 14/N) * 20 / f2 + + f1: PSRAM access frequency, unit: MHz. + f2: Flash access frequency, unit: MHz. + + When flash is slow/fast read, N = 1. + When flash is DOUT/DIO read, N = 2. + When flash is QOUT/QIO read, N = 4. + */ +1: rsr.ccount a2 +#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) +# if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M) + movi a3, 480 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 720 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 720 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 960 +# else + movi a3, 1200 +# endif +#elif defined(CONFIG_FLASHMODE_DIO) || defined(CONFIG_FLASHMODE_DOUT) +# if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M) + movi a3, 720 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 720 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 1200 +# elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M) + movi a3, 1680 +# else + movi a3, 2160 +# endif +#endif +2: rsr.ccount a4 /* delay_us(N) */ + sub a4, a4, a2 + bltu a4, a3, 2b + + beqz a5, 2f + movi a2, _l4_intr_livelock_app + l32i a2, a2, 0 + beqi a2, 2, 8f + j 3f + +2: movi a2, _l4_intr_livelock_pro + l32i a4, a2, 0 + addi a4, a4, 1 + s32i a4, a2, 0 + + movi a2, _l4_intr_livelock_sync + movi a3, 1 + addx4 a3, a3, a2 + l32i a2, a2, 0 + l32i a3, a3, 0 + and a2, a2, a3 + beqz a2, 5f + j 1b +5: bgei a4, 2, 4f + j 1b + + /* + Pro cpu (Core 0) jump bypass, continue waiting, App cpu (Core 1) + can execute to here, unmap itself tg1 1st stage timeout interrupt + then restore registers and exit highint4. + */ +3: intr_matrix_map DPORT_APP_MAC_INTR_MAP_REG, ETS_TG1_WDT_LEVEL_INTR_SOURCE, 16 + j 9f + + /* + Here, App cpu (Core 1) has exited isr, Pro cpu (Core 0) help the + App cpu map tg1 1st stage timeout interrupt clear tg1 interrupt. + */ +4: intr_matrix_map DPORT_APP_MAC_INTR_MAP_REG, ETS_TG1_WDT_LEVEL_INTR_SOURCE, ETS_T1_WDT_INUM + +1: movi a2, _l4_intr_livelock_sync + movi a4, 1 + addx4 a3, a4, a2 + l32i a2, a2, 0 + l32i a3, a3, 0 + and a2, a2, a3 + beqz a2, 1b /* Wait for App cpu to enter highint4 again */ + + wdt_clr_intr_status TIMERG1 + j 9f + + /* Feed watchdog */ +8: wdt_feed TIMERG1 + +9: wsr a0, PS /* restore iterrupt level */ + + movi a0, 0 + beqz a5, 1f + movi a2, _l4_intr_livelock_app + l32i a3, a2, 0 + bnei a3, 2, 1f + s32i a0, a2, 0 + +1: bnez a5, 2f + movi a2, _l4_intr_livelock_pro + s32i a0, a2, 0 +2: movi a2, _l4_intr_livelock_sync + addx4 a2, a5, a2 + s32i a0, a2, 0 + + /* Done. Restore registers and return. */ + movi a0, L4_INTR_STACK_SIZE + mull a5, a5, a0 + movi a0, _l4_intr_stack + add a0, a0, a5 + l32i a2, a0, L4_INTR_A2_OFFSET + l32i a3, a0, L4_INTR_A3_OFFSET + l32i a4, a0, L4_INTR_A4_OFFSET + rsync /* ensure register restored */ + + rsr a5, depc + + rsr a0, EXCSAVE_4 /* restore a0 */ + rfi 4 + +#endif #ifndef CONFIG_FREERTOS_UNICORE diff --git a/components/esp32/esp_adapter.c b/components/esp32/esp_adapter.c index ce1d1846a..28c7862de 100644 --- a/components/esp32/esp_adapter.c +++ b/components/esp32/esp_adapter.c @@ -177,7 +177,7 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg) static void * spin_lock_create_wrapper(void) { portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = malloc(sizeof(portMUX_TYPE)); + void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); if (mux) { memcpy(mux,&tmp,sizeof(portMUX_TYPE)); @@ -555,7 +555,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._task_get_max_priority = task_get_max_priority_wrapper, ._malloc = malloc, ._free = free, - ._get_free_heap_size = esp_get_free_heap_size, + ._get_free_heap_size = esp_get_free_internal_heap_size, ._rand = esp_random, ._dport_access_stall_other_cpu_start_wrap = esp_dport_access_stall_other_cpu_start_wrap, ._dport_access_stall_other_cpu_end_wrap = esp_dport_access_stall_other_cpu_end_wrap, diff --git a/components/esp32/esp_err_to_name.c b/components/esp32/esp_err_to_name.c index 635da0340..621454c92 100644 --- a/components/esp32/esp_err_to_name.c +++ b/components/esp32/esp_err_to_name.c @@ -442,6 +442,15 @@ static const esp_err_msg_t esp_err_msg_table[] = { # endif # ifdef ESP_ERR_MESH_VOTING ERR_TBL_IT(ESP_ERR_MESH_VOTING), /* 16406 0x4016 */ +# endif +# ifdef ESP_ERR_MESH_XMIT + ERR_TBL_IT(ESP_ERR_MESH_XMIT), /* 16407 0x4017 */ +# endif +# ifdef ESP_ERR_MESH_QUEUE_READ + ERR_TBL_IT(ESP_ERR_MESH_QUEUE_READ), /* 16408 0x4018 */ +# endif +# ifdef ESP_ERR_MESH_RECV_RELEASE + ERR_TBL_IT(ESP_ERR_MESH_RECV_RELEASE), /* 16410 0x401a */ # endif // components/tcpip_adapter/include/tcpip_adapter.h # ifdef ESP_ERR_TCPIP_ADAPTER_BASE diff --git a/components/esp32/include/esp_coexist.h b/components/esp32/include/esp_coexist.h index 7d31e8602..6def75c57 100644 --- a/components/esp32/include/esp_coexist.h +++ b/components/esp32/include/esp_coexist.h @@ -84,6 +84,20 @@ esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status); */ esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status); +/** + * @brief Enable BLE connection dynamic priority + * @attention If the parameter is true, BLE connection performance will be better but WiFi performance + * will be poorer. And vice versa. + * @param low_interval : true - Increase BLE connection priority to be higher than WiFi's when BLE + * connection interval is less or equal than 50 ms. The default value + * is false. + * false - not increace + * @param high_interval : true - Increase BLE connection priority to be higher than WiFi's when BLE + * connection interval is more than 50 ms. The default value is true. + * false - not increace + * @return : ESP_OK - success, other - failed + */ +esp_err_t esp_coex_ble_conn_dynamic_prio_enable(bool low_interval, bool high_interval); #ifdef __cplusplus } diff --git a/components/esp32/include/esp_idf_version.h b/components/esp32/include/esp_idf_version.h index 735abc78b..6b59e6b27 100644 --- a/components/esp32/include/esp_idf_version.h +++ b/components/esp32/include/esp_idf_version.h @@ -23,7 +23,7 @@ extern "C" { /** Minor version number (x.X.x) */ #define ESP_IDF_VERSION_MINOR 3 /** Patch version number (x.x.X) */ -#define ESP_IDF_VERSION_PATCH 2 +#define ESP_IDF_VERSION_PATCH 4 /** * Macro to convert IDF version number into an integer @@ -41,6 +41,8 @@ extern "C" { ESP_IDF_VERSION_MINOR, \ ESP_IDF_VERSION_PATCH) +#ifndef __ASSEMBLER__ + /** * Return full IDF version string, same as 'git describe' output. * @@ -53,6 +55,8 @@ extern "C" { */ const char* esp_get_idf_version(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_mesh.h b/components/esp32/include/esp_mesh.h index e52e541ff..e703ec828 100644 --- a/components/esp32/include/esp_mesh.h +++ b/components/esp32/include/esp_mesh.h @@ -124,6 +124,9 @@ extern "C" { #define ESP_ERR_MESH_DISCARD_DUPLICATE (ESP_ERR_MESH_BASE + 20) /**< discard the packet due to the duplicate sequence number */ #define ESP_ERR_MESH_DISCARD (ESP_ERR_MESH_BASE + 21) /**< discard the packet */ #define ESP_ERR_MESH_VOTING (ESP_ERR_MESH_BASE + 22) /**< vote in progress */ +#define ESP_ERR_MESH_XMIT (ESP_ERR_MESH_BASE + 23) /**< XMIT */ +#define ESP_ERR_MESH_QUEUE_READ (ESP_ERR_MESH_BASE + 24) /**< error in reading queue */ +#define ESP_ERR_MESH_RECV_RELEASE (ESP_ERR_MESH_BASE + 26) /**< release esp_mesh_recv_toDS */ /** * @brief Flags bitmap for esp_mesh_send() and esp_mesh_recv() @@ -203,6 +206,7 @@ typedef enum { MESH_ROOT, /**< the only sink of the mesh network. Has the ability to access external IP network */ MESH_NODE, /**< intermediate device. Has the ability to forward packets over the mesh network */ MESH_LEAF, /**< has no forwarding ability */ + MESH_STA, /**< connect to router with a standlone Wi-Fi station mode, no network expansion capability */ } mesh_type_t; /** @@ -735,6 +739,7 @@ esp_err_t esp_mesh_recv(mesh_addr_t *from, mesh_data_t *data, int timeout_ms, * - ESP_ERR_MESH_NOT_START * - ESP_ERR_MESH_TIMEOUT * - ESP_ERR_MESH_DISCARD + * - ESP_ERR_MESH_RECV_RELEASE */ esp_err_t esp_mesh_recv_toDS(mesh_addr_t *from, mesh_addr_t *to, mesh_data_t *data, int timeout_ms, int *flag, mesh_opt_t opt[], @@ -830,8 +835,10 @@ esp_err_t esp_mesh_get_id(mesh_addr_t *id); /** * @brief Designate device type over the mesh network + * - MESH_IDLE: designates a device as a self-organized node for a mesh network * - MESH_ROOT: designates the root node for a mesh network - * - MESH_LEAF: designates a device as a standalone Wi-Fi station + * - MESH_LEAF: designates a device as a standalone Wi-Fi station that connects to a parent + * - MESH_STA: designates a device as a standalone Wi-Fi station that connects to a router * * @param[in] type device type * diff --git a/components/esp32/include/esp_mesh_internal.h b/components/esp32/include/esp_mesh_internal.h index e061c4577..020354ab1 100644 --- a/components/esp32/include/esp_mesh_internal.h +++ b/components/esp32/include/esp_mesh_internal.h @@ -263,6 +263,16 @@ esp_err_t esp_mesh_set_announce_interval(int short_ms, int long_ms); */ esp_err_t esp_mesh_get_announce_interval(int *short_ms, int *long_ms); +/** + * @brief Enable mesh print scan result + * + * @param[in] enable enable or not + * + * @return + * - ESP_OK + */ +esp_err_t esp_mesh_print_scan_result(bool enable); + #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_system.h b/components/esp32/include/esp_system.h index 1a51999d3..1afbe1fdc 100644 --- a/components/esp32/include/esp_system.h +++ b/components/esp32/include/esp_system.h @@ -130,6 +130,16 @@ uint32_t system_get_time(void) __attribute__ ((deprecated)); */ uint32_t esp_get_free_heap_size(void); +/** + * @brief Get the size of available internal heap. + * + * Note that the returned value may be larger than the maximum contiguous block + * which can be allocated. + * + * @return Available internal heap size, in bytes. + */ +uint32_t esp_get_free_internal_heap_size(void); + /** @cond */ /** * @brief Get the size of available heap. @@ -322,6 +332,15 @@ typedef struct { */ void esp_chip_info(esp_chip_info_t* out_info); +/** + * @brief Cache lock bug exists or not + * + * @return + * - true : bug exists + * - false : bug not exists + */ +bool soc_has_cache_lock_bug(void); + #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index e82c05911..f920c57bc 100644 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -1111,6 +1111,39 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config); */ esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config); +/** + * @brief Set the inactive time of the ESP32 STA or AP + * + * @attention 1. For Station, If the station does not receive a beacon frame from the connected SoftAP during the inactive time, + * disconnect from SoftAP. Default 6s. + * @attention 2. For SoftAP, If the softAP doesn't receive any data from the connected STA during inactive time, + * the softAP will force deauth the STA. Default is 300s. + * @attention 3. The inactive time configuration is not stored into flash + * + * @param ifx interface to be configured. + * @param sec Inactive time. Unit seconds. + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start + * - ESP_ERR_WIFI_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10. + */ +esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec); + +/** + * @brief Get inactive time of specified interface + * + * @param ifx Interface to be configured. + * @param sec Inactive time. Unit seconds. + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_WIFI_ARG: invalid argument + */ +esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); + #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_wifi_types.h b/components/esp32/include/esp_wifi_types.h index 0ca206565..f7786f5a0 100644 --- a/components/esp32/include/esp_wifi_types.h +++ b/components/esp32/include/esp_wifi_types.h @@ -93,7 +93,7 @@ typedef enum { WIFI_REASON_ASSOC_FAIL = 203, WIFI_REASON_HANDSHAKE_TIMEOUT = 204, WIFI_REASON_CONNECTION_FAIL = 205, - WIFI_REASON_AUTH_CHANGED = 206, + WIFI_REASON_AP_TSF_RESET = 206, } wifi_err_reason_t; typedef enum { diff --git a/components/esp32/int_wdt.c b/components/esp32/int_wdt.c index efef92511..7d5f4c6f5 100644 --- a/components/esp32/int_wdt.c +++ b/components/esp32/int_wdt.c @@ -35,8 +35,17 @@ #if CONFIG_INT_WDT -#define WDT_INT_NUM 24 +#define WDT_INT_NUM ETS_T1_WDT_INUM +#if !defined(CONFIG_FREERTOS_UNICORE) && defined(CONFIG_SPIRAM_SUPPORT) +/* + * This parameter is indicates the response time of tg1 watchdog to + * identify the live lock, + */ +#define TG1_WDT_LIVELOCK_TIMEOUT_MS (20) + +extern uint32_t _l4_intr_livelock_counter, _l4_intr_livelock_max; +#endif //Take care: the tick hook can also be called before esp_int_wdt_init() is called. #if CONFIG_INT_WDT_CHECK_CPU1 @@ -50,7 +59,12 @@ static void IRAM_ATTR tick_hook(void) { //Only feed wdt if app cpu also ticked. if (int_wdt_app_cpu_ticked) { TIMERG1.wdt_wprotect=TIMG_WDT_WKEY_VALUE; +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX + _l4_intr_livelock_counter = 0; + TIMERG1.wdt_config2=CONFIG_INT_WDT_TIMEOUT_MS*2/(_l4_intr_livelock_max+1); //Set timeout before interrupt +#else TIMERG1.wdt_config2=CONFIG_INT_WDT_TIMEOUT_MS*2; //Set timeout before interrupt +#endif TIMERG1.wdt_config3=CONFIG_INT_WDT_TIMEOUT_MS*4; //Set timeout before reset TIMERG1.wdt_feed=1; TIMERG1.wdt_wprotect=0; @@ -92,9 +106,21 @@ void esp_int_wdt_init() { void esp_int_wdt_cpu_init() { + assert((CONFIG_INT_WDT_TIMEOUT_MS >= (portTICK_PERIOD_MS<<1)) && "Interrupt watchdog timeout needs to meet double SysTick period!"); esp_register_freertos_tick_hook_for_cpu(tick_hook, xPortGetCoreID()); ESP_INTR_DISABLE(WDT_INT_NUM); intr_matrix_set(xPortGetCoreID(), ETS_TG1_WDT_LEVEL_INTR_SOURCE, WDT_INT_NUM); +#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX + /* + * This is a workaround for issue 3.15 in "ESP32 ECO and Workarounds for Bugs" document. + */ + _l4_intr_livelock_max = 0; + if (soc_has_cache_lock_bug()) { + assert((portTICK_PERIOD_MS<<1) <= TG1_WDT_LIVELOCK_TIMEOUT_MS); + assert(CONFIG_INT_WDT_TIMEOUT_MS >= (TG1_WDT_LIVELOCK_TIMEOUT_MS*3)); + _l4_intr_livelock_max = CONFIG_INT_WDT_TIMEOUT_MS/TG1_WDT_LIVELOCK_TIMEOUT_MS - 1; + } +#endif //We do not register a handler for the interrupt because it is interrupt level 4 which //is not servicable from C. Instead, xtensa_vectors.S has a call to the panic handler for //this interrupt. diff --git a/components/esp32/ld/esp32.rom.ld b/components/esp32/ld/esp32.rom.ld index d493417f3..eefa8c5b4 100644 --- a/components/esp32/ld/esp32.rom.ld +++ b/components/esp32/ld/esp32.rom.ld @@ -122,6 +122,8 @@ PROVIDE ( hci_fc_env = 0x3ffb9340 ); PROVIDE ( jd_decomp = 0x400613e8 ); PROVIDE ( jd_prepare = 0x40060fa8 ); PROVIDE ( ke_env = 0x3ffb93cc ); +PROVIDE ( ke_handler_search = 0x4001a430 ); +PROVIDE ( ke_task_env = 0x3ffb81d4 ); PROVIDE ( lb_default_handler = 0x3ff982b8 ); PROVIDE ( lb_default_state_tab_p_get = 0x4001c198 ); PROVIDE ( lb_env = 0x3ffb9424 ); @@ -683,6 +685,7 @@ PROVIDE ( ld_acl_sniff_frm_cbk = 0x4003482c ); PROVIDE ( ld_inq_end = 0x4003ab48 ); PROVIDE ( ld_inq_sched = 0x4003aba4 ); PROVIDE ( ld_inq_frm_cbk = 0x4003ae4c ); +PROVIDE ( ld_pscan_frm_cbk = 0x4003ebe4 ); PROVIDE ( r_ld_acl_active_hop_types_get = 0x40036e10 ); PROVIDE ( r_ld_acl_afh_confirm = 0x40036d40 ); PROVIDE ( r_ld_acl_afh_prepare = 0x40036c84 ); @@ -1392,6 +1395,8 @@ PROVIDE ( g_rom_spiflash_chip = 0x3ffae270 ); PROVIDE ( hci_le_rd_rem_used_feats_cmd_handler = 0x400417b4 ); PROVIDE ( llcp_length_req_handler = 0x40043808 ); PROVIDE ( llcp_unknown_rsp_handler = 0x40043ba8 ); +PROVIDE ( llcp_channel_map_req_handler = 0x4004291c ); +PROVIDE ( llcp_con_up_req_handler = 0x400426f0 ); /* These functions are xtos-related (or call xtos-related functions) and do not play well diff --git a/components/esp32/lib b/components/esp32/lib index 9f4e045a1..1de41c183 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 9f4e045a1d4ce4f4d7ffc708c5ea8f2405ecf6ed +Subproject commit 1de41c1835923811ca9b3370bc88c54bd8536daa diff --git a/components/esp32/lib_printf.c b/components/esp32/lib_printf.c index a22cfb99e..4ad6106a5 100644 --- a/components/esp32/lib_printf.c +++ b/components/esp32/lib_printf.c @@ -137,3 +137,12 @@ int coexist_printf(const char* format, ...) va_end(arg); return res; } + +int mesh_printf(const char* format, ...) +{ + va_list arg; + va_start(arg, format); + int res = lib_printf("mesh", format, arg); + va_end(arg); + return res; +} diff --git a/components/esp32/panic.c b/components/esp32/panic.c index 7d3960cfb..00036e365 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -244,9 +244,9 @@ void panicHandler(XtExcFrame *frame) while (1); } - //The core which triggers the interrupt watchdog will delay 1 us, so the other core can save its frame. + //The core which triggers the interrupt watchdog will delay 500 us, so the other core can save its frame. if (frame->exccause == PANIC_RSN_INTWDT_CPU0 || frame->exccause == PANIC_RSN_INTWDT_CPU1) { - ets_delay_us(1); + ets_delay_us(500); } if (frame->exccause == PANIC_RSN_CACHEERR && esp_cache_err_get_cpuid() != core_id) { diff --git a/components/esp32/phy_init.c b/components/esp32/phy_init.c index 5968fef50..15bdff74b 100644 --- a/components/esp32/phy_init.c +++ b/components/esp32/phy_init.c @@ -52,12 +52,6 @@ static uint32_t s_module_phy_rf_init = 0; /* Whether modem sleep is turned on */ static volatile bool s_is_phy_rf_en = false; -/* Whether WiFi/BT common clock enabled reference */ -static volatile int32_t s_common_clock_enable_ref = 0; - -/* PHY spinlock mux */ -static portMUX_TYPE s_phy_spin_lock = portMUX_INITIALIZER_UNLOCKED; - /* Bit mask of modules needing to enter modem sleep mode */ static uint32_t s_modem_sleep_module_enter = 0; @@ -121,56 +115,16 @@ static inline void phy_update_wifi_mac_time(bool en_clock_stopped, int64_t now) } } -IRAM_ATTR static inline void phy_spin_lock(void) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(&s_phy_spin_lock); - } else { - portENTER_CRITICAL(&s_phy_spin_lock); - } -} - -IRAM_ATTR static inline void phy_spin_unlock(void) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(&s_phy_spin_lock); - } else { - portEXIT_CRITICAL(&s_phy_spin_lock); - } -} - IRAM_ATTR void esp_phy_common_clock_enable(void) { - phy_spin_lock(); - - if (s_common_clock_enable_ref == 0) { - // Enable WiFi/BT common clock - periph_module_enable(PERIPH_WIFI_BT_COMMON_MODULE); - } - - s_common_clock_enable_ref++; - phy_spin_unlock(); + wifi_bt_common_module_enable(); } IRAM_ATTR void esp_phy_common_clock_disable(void) { - phy_spin_lock(); - - if (s_common_clock_enable_ref > 0) { - s_common_clock_enable_ref --; - - if (s_common_clock_enable_ref == 0) { - // Disable WiFi/BT common clock - periph_module_disable(PERIPH_WIFI_BT_COMMON_MODULE); - } - } else { - abort(); - } - - phy_spin_unlock(); + wifi_bt_common_module_disable(); } - esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibration_mode_t mode, esp_phy_calibration_data_t* calibration_data, phy_rf_module_t module) { diff --git a/components/esp32/spiram_psram.c b/components/esp32/spiram_psram.c index abeb95a63..bb0ccd64d 100644 --- a/components/esp32/spiram_psram.c +++ b/components/esp32/spiram_psram.c @@ -398,11 +398,9 @@ static void psram_disable_qio_mode(psram_spi_num_t spi_num) psram_cmd_end(spi_num); } -//read psram id -static void psram_read_id(uint64_t* dev_id) +//read psram id, should issue `psram_disable_qio_mode` before calling this +static void psram_read_id(psram_spi_num_t spi_num, uint64_t* dev_id) { - psram_spi_num_t spi_num = PSRAM_SPI_1; - psram_disable_qio_mode(spi_num); uint32_t dummy_bits = 0 + extra_dummy; uint32_t psram_id[2] = {0}; psram_cmd_t ps_cmd; @@ -901,9 +899,20 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad bootloader_common_vddsdio_configure(); // GPIO related settings psram_gpio_config(&psram_io, mode); - psram_read_id(&s_psram_id); + + psram_spi_num_t spi_num = PSRAM_SPI_1; + psram_disable_qio_mode(spi_num); + psram_read_id(spi_num, &s_psram_id); if (!PSRAM_IS_VALID(s_psram_id)) { - return ESP_FAIL; + /* 16Mbit psram ID read error workaround: + * treat the first read id as a dummy one as the pre-condition, + * Send Read ID command again + */ + psram_read_id(spi_num, &s_psram_id); + if (!PSRAM_IS_VALID(s_psram_id)) { + ESP_EARLY_LOGE(TAG, "PSRAM ID read error: 0x%08x", (uint32_t)s_psram_id); + return ESP_FAIL; + } } if (psram_is_32mbit_ver0()) { diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index a673e4515..6bae2d43b 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -306,7 +306,7 @@ void IRAM_ATTR esp_restart_noos() // Reset timer/spi/uart DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, - DPORT_TIMERS_RST | DPORT_SPI01_RST | DPORT_UART_RST | DPORT_UART1_RST | DPORT_UART2_RST); + DPORT_TIMERS_RST | DPORT_SPI01_RST | DPORT_SPI2_RST | DPORT_SPI3_RST | DPORT_SPI_DMA_RST | DPORT_UART_RST | DPORT_UART1_RST | DPORT_UART2_RST); DPORT_REG_WRITE(DPORT_PERIP_RST_EN_REG, 0); // Set CPU back to XTAL source, no PLL, same as hard reset @@ -339,6 +339,11 @@ uint32_t esp_get_free_heap_size( void ) return heap_caps_get_free_size( MALLOC_CAP_DEFAULT ); } +uint32_t esp_get_free_internal_heap_size( void ) +{ + return heap_caps_get_free_size( MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL ); +} + uint32_t esp_get_minimum_free_heap_size( void ) { return heap_caps_get_minimum_free_size( MALLOC_CAP_DEFAULT ); @@ -380,3 +385,8 @@ void esp_chip_info(esp_chip_info_t* out_info) out_info->features |= CHIP_FEATURE_EMB_FLASH; } } + +inline bool soc_has_cache_lock_bug(void) +{ + return (esp_efuse_get_chip_ver() == 3); +} diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 25c0d5d87..72f8cdf53 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -854,7 +854,11 @@ int esp_http_client_read(esp_http_client_handle_t client, char *buffer, int len) } ESP_LOG_LEVEL(sev, TAG, "esp_transport_read returned:%d and errno:%d ", rlen, errno); } - return ridx; + if (rlen < 0 && ridx == 0) { + return ESP_FAIL; + } else { + return ridx; + } } res_buffer->output_ptr = buffer + ridx; http_parser_execute(client->parser, client->parser_settings, res_buffer->data, rlen); diff --git a/components/esp_http_server/src/httpd_main.c b/components/esp_http_server/src/httpd_main.c index e19ac9af5..e51cc7b85 100644 --- a/components/esp_http_server/src/httpd_main.c +++ b/components/esp_http_server/src/httpd_main.c @@ -67,6 +67,8 @@ static esp_err_t httpd_accept_conn(struct httpd_data *hd, int listen_fd) close(new_fd); return ESP_FAIL; } + httpd_sess_update_lru_counter(hd->hd_sd->handle, new_fd); + ESP_LOGD(TAG, LOG_FMT("complete")); return ESP_OK; } diff --git a/components/esp_https_ota/src/esp_https_ota.c b/components/esp_https_ota/src/esp_https_ota.c index 4bab1dcdb..98df98bbb 100644 --- a/components/esp_https_ota/src/esp_https_ota.c +++ b/components/esp_https_ota/src/esp_https_ota.c @@ -78,10 +78,7 @@ static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client * to clear the response buffer of http_client. */ int data_read = esp_http_client_read(http_client, upgrade_data_buf, DEFAULT_OTA_BUF_SIZE); - if (data_read < 0) { - ESP_LOGE(TAG, "Error: SSL data read error"); - return ESP_FAIL; - } else if (data_read == 0) { + if (data_read <= 0) { return ESP_OK; } } @@ -235,10 +232,10 @@ esp_err_t esp_https_ota_get_img_desc(esp_https_ota_handle_t https_ota_handle, es (handle->ota_upgrade_buf + bytes_read), data_read_size); /* - * As esp_http_client_read never returns negative error code, we rely on + * As esp_http_client_read doesn't return negative error code if select fails, we rely on * `errno` to check for underlying transport connectivity closure if any */ - if (errno == ENOTCONN || errno == ECONNRESET || errno == ECONNABORTED) { + if (errno == ENOTCONN || errno == ECONNRESET || errno == ECONNABORTED || data_read < 0) { ESP_LOGE(TAG, "Connection closed, errno = %d", errno); break; } @@ -294,7 +291,7 @@ esp_err_t esp_https_ota_perform(esp_https_ota_handle_t https_ota_handle) */ bool is_recv_complete = esp_https_ota_is_complete_data_received(https_ota_handle); /* - * As esp_http_client_read never returns negative error code, we rely on + * As esp_http_client_read doesn't return negative error code if select fails, we rely on * `errno` to check for underlying transport connectivity closure if any. * Incase the complete data has not been received but the server has sent * an ENOTCONN or ECONNRESET, failure is returned. We close with success @@ -309,6 +306,8 @@ esp_err_t esp_https_ota_perform(esp_https_ota_handle_t https_ota_handle) ESP_LOGI(TAG, "Connection closed"); } else if (data_read > 0) { return _ota_write(handle, (const void *)handle->ota_upgrade_buf, data_read); + } else { + return ESP_FAIL; } handle->state = ESP_HTTPS_OTA_SUCCESS; break; diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index 6b2833f42..d76b30008 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -78,6 +78,7 @@ typedef enum { struct esp_websocket_client { esp_event_loop_handle_t event_handle; + TaskHandle_t task_handle; esp_transport_list_handle_t transport_list; esp_transport_handle_t transport; websocket_config_storage_t *config; @@ -604,7 +605,7 @@ esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client) ESP_LOGE(TAG, "The client has started"); return ESP_FAIL; } - if (xTaskCreate(esp_websocket_client_task, "websocket_task", client->config->task_stack, client, client->config->task_prio, NULL) != pdTRUE) { + if (xTaskCreate(esp_websocket_client_task, "websocket_task", client->config->task_stack, client, client->config->task_prio, &client->task_handle) != pdTRUE) { ESP_LOGE(TAG, "Error create websocket task"); return ESP_FAIL; } @@ -621,6 +622,15 @@ esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client) ESP_LOGW(TAG, "Client was not started"); return ESP_FAIL; } + + /* A running client cannot be stopped from the websocket task/event handler */ + TaskHandle_t running_task = xTaskGetCurrentTaskHandle(); + if (running_task == client->task_handle) { + ESP_LOGE(TAG, "Client cannot be stopped from websocket task"); + return ESP_FAIL; + } + + client->run = false; xEventGroupWaitBits(client->status_bits, STOPPED_BIT, false, true, portMAX_DELAY); client->state = WEBSOCKET_STATE_UNKNOW; diff --git a/components/esp_websocket_client/include/esp_websocket_client.h b/components/esp_websocket_client/include/esp_websocket_client.h index db521c2d0..6a8bca2b9 100644 --- a/components/esp_websocket_client/include/esp_websocket_client.h +++ b/components/esp_websocket_client/include/esp_websocket_client.h @@ -125,6 +125,9 @@ esp_err_t esp_websocket_client_start(esp_websocket_client_handle_t client); /** * @brief Close the WebSocket connection * + * Notes: + * - Cannot be called from the websocket event handler + * * @param[in] client The client * * @return esp_err_t @@ -136,7 +139,10 @@ esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client); * This function must be the last function to call for an session. * It is the opposite of the esp_websocket_client_init function and must be called with the same handle as input that a esp_websocket_client_init call returned. * This might close all connections this handle has used. - * + * + * Notes: + * - Cannot be called from the websocket event handler + * * @param[in] client The client * * @return esp_err_t diff --git a/components/espcoredump/src/core_dump_common.c b/components/espcoredump/src/core_dump_common.c index 7e00c1b40..1ac358947 100644 --- a/components/espcoredump/src/core_dump_common.c +++ b/components/espcoredump/src/core_dump_common.c @@ -192,7 +192,13 @@ esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t *out_size) uint32_t *dw = (uint32_t *)core_data; *out_size = *dw; spi_flash_munmap(core_data_handle); - + if (*out_size == 0xFFFFFFFF) { + ESP_LOGD(TAG, "Blank core dump partition!"); + return ESP_ERR_INVALID_SIZE; + } else if ((*out_size < sizeof(uint32_t)) || (*out_size > core_part->size)) { + ESP_LOGE(TAG, "Incorrect size of core dump image: %d", *out_size); + return ESP_ERR_INVALID_SIZE; + } // remap full core dump with CRC err = esp_partition_mmap(core_part, 0, *out_size, SPI_FLASH_MMAP_DATA, &core_data, &core_data_handle); diff --git a/components/idf_test/integration_test/INIT_COND_MESH.yml b/components/idf_test/integration_test/INIT_COND_MESH.yml deleted file mode 100644 index 75b78740e..000000000 --- a/components/idf_test/integration_test/INIT_COND_MESH.yml +++ /dev/null @@ -1,228 +0,0 @@ -.MESH_INIT_COND: &MESH_INIT_COND - test script: InitCondMesh - restore post cmd set: - - '' - - - 'MSSC SSC[1-] ram' - - ['P SSC[1-] C +FREEHEAP:'] -# - - 'MSSC SSC[1-] mesh -Q -o 1' -# - ['P SSC[1-] C MESH_NETWORK'] - -.mesh_get_all_dut_mac: &mesh_get_all_dut_mac - LIST_MERGE: - - - 'MSSC SSC[1-] mac' - - ['R SSC[1-] A :\+STAMAC:(.+)\r\n'] - -.mesh_check_tree_num: &mesh_check_tree_num - LIST_MERGE: - - - 'MSSC SSC[1-] mesh -Q -o 2' - - ['P SSC[1-] T topo'] - - - 'MESHTREE' - - ['R PC_COM RE "MESHTREE:%%s"%%()'] - -.mesh_tree_stably: &mesh_tree_stably - LIST_MERGE: - - - 'SSC MNODE(0) mesh -Q -o 1 -t ' - - ['P MNODE(0) RE "MESH_NETWORK:1,%%s"%%()', 'P MNODE(0) C MESH_STABLE_CHECK:PASS'] - -.deinit_mesh: &deinit_mesh - LIST_MERGE: - - - 'MSSC SSC[1-] mesh -I -o 1' - - ['P SSC[1-] C +MESH:DEINITED'] - -.mesh_force_reboot: &mesh_force_reboot - LIST_MERGE: - - - 'MSSC SSC[1-] restore' - - ['P SSC[1-] C !!!ready!!!'] - -.mesh_config_all_duts: &mesh_config_all_duts - LIST_MERGE: - - - 'MSSC SSC[1-] meshset -M -o 0 -t -e -l 10' - - ['P SSC[1-] C +MESHSET:MAP_AUTH,OK'] - - - 'MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i ' - - ['P SSC[1-] C +MESHSET:CFG,OK'] - - - 'MSSC SSC[1-] meshset -L -o 0 -l ' - - ['P SSC[1-] C +MESHSET:MLAYER,OK'] - - - 'MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC[1-] C +MESHSET:SWITCH,OK'] - - - 'MSSC SSC[1-] meshset -K -o 0 -i ' - - ['P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK'] - - - 'MSSC SSC[1-] meshset -J -o 0 -t ' - - ['P SSC[1-] C +MESHSET:ASSOC,OK'] - -.mesh_set_same_ssid_softap: &mesh_set_same_ssid_softap - LIST_MERGE: - - - 'MSSC SSC[1-3] op -S -o 2' - - ['P SSC[1-3] C +MODE:OK'] - - - 'MSSC SSC[1-3] ap -S -s -p -t -n - [,,]' - - ['P SSC[1-3] C +SAP:OK'] - -initial condition: -- tag: MESH_DEINIT_STA - <<: *MESH_INIT_COND - initial condition detail: all DUTs with mesh not inited, station mode - check cmd set: - - '' - - - MSSC SSC[1-] mesh -Q - - - P SSC[1-] C MESH_STATE_NONE - - - MSSC SSC[1-] op -S -o 1 - - - P SSC[1-] C +MODE:OK - - *mesh_get_all_dut_mac - restore cmd set: - - '' - - - MSSC SSC[1-] mesh -I -o 1 - - - P SSC[1-] C +MESH_DEINITED - - - MSSC SSC[1-] op -S -o 1 - - - P SSC[1-] C +MODE:OK - - *mesh_get_all_dut_mac - force restore cmd set: - - '' -# - - MSSC SSC[1-] reboot - - - FREBOOT SSC[1-] - - - P SSC[1-] C !!!ready!!! - - *mesh_get_all_dut_mac -- tag: MESH_INIT1 - <<: *MESH_INIT_COND - initial condition detail: DUTs with mesh network already established, router.... - check cmd set: - - '' - - *mesh_get_all_dut_mac - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - MSSC SSC[1-] mesh -Q -o 3 - - - P SSC[1-] RE "MID,%%s"%%() - - P SSC[1-] RE "MROUTER,%%s"%%() - - P SSC[1-] RE "SWITCH_PARENT,%%s"%%() - - P SSC[1-] C NO_SPECIFIC_SETTINGS - restore cmd set: - - '' - - - MSSC SSC[1-] mesh -I -o 1 - - - P SSC[1-] C MESH_DEINITED - - - MSSC SSC[1-] op -S -o 1 - - - P SSC[1-] C +MODE:OK - - *mesh_get_all_dut_mac - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - *mesh_config_all_duts - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - force restore cmd set: - - '' - - - MSSC SSC[1-] reboot - - - P SSC[1-] C !!!ready!!! - - *mesh_get_all_dut_mac - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - *mesh_config_all_duts - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably -- tag: MESH_INIT_SWITCH - <<: *MESH_INIT_COND - initial condition detail: 3 duts in softAP mode with same ssid/password, all duts establish network - check cmd set: - - '' - - - SSC SSC[1-3] ap -Q - - - P SSC[1-3] RE "RE "APCONFIG:%%s"%%() - - - MSSC SSC[4-] mac - - - R SSC[4-] A :\+STAMAC:(.+)\r\n - - - VALUE -3 - - - R PC_COM L OK - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() - - - MSSC SSC[4-] mesh -Q -o 3 - - P SSC[4-] RE "MROUTER,%%s"%%() - - - DELAY 5 - - - P PC_COM C +DELAYDONE - - P SSC[4-] NC MESH_EVENT_DISCONNECTED - restore cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - MSSC SSC[1-] reboot - - - P SSC[1-] C !!!ready!!! - - *mesh_get_all_dut_mac - - *mesh_set_same_ssid_softap - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - - MSSC SSC[4-] meshset -M -o 0 -t -e -l 10 - - - P SSC[4-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[4-] meshset -G -o 0 -m -s -p -n -h 1 -t - -e -i - - - P SSC[4-] C +MESHSET:CFG,OK - - - MSSC SSC[4-] meshset -L -o 0 -l - - - P SSC[4-] C +MESHSET:MLAYER,OK - - - MSSC SSC[4-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[4-] C +MESHSET:SWITCH,OK - - - MSSC SSC[4-] meshset -K -o 0 -i - - - P SSC[4-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC[4-] NC MESH_EVENT_DISCONNECTED -- tag: MESH_NO_ROUTER - <<: *MESH_INIT_COND - initial condition detail: DUTs with mesh network already established, router.... - check cmd set: - - '' - - *mesh_get_all_dut_mac - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - MSSC SSC[1-] mesh -Q -o 3 - - - P SSC[1-] RE "MID,%%s"%%() - - P SSC[1-] C NO_ROUTER - restore cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - ASSERT - - - '' -- tag: MESH_STABLE - <<: *MESH_INIT_COND - initial condition detail: DUTs with mesh network already established and stable, never restore - check cmd set: - - '' - - *mesh_get_all_dut_mac - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE stable - - - P PC_COM RE "MESHTREE:%%s%20nodes"%%() - restore cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - ASSERT - - - '' diff --git a/components/idf_test/integration_test/INIT_COND_SSC.yml b/components/idf_test/integration_test/INIT_COND_SSC.yml deleted file mode 100644 index 746fa9e83..000000000 --- a/components/idf_test/integration_test/INIT_COND_SSC.yml +++ /dev/null @@ -1,3140 +0,0 @@ -.SSC_INIT_COND: &SSC_INIT_COND - test script: InitCondBase - restore post cmd set: - - '' - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSEALL - - - SSC SSC1 ram - - - 'R SSC1 C +FREEHEAP:' - -.dut1_start_wifi: &dut1_start_wifi - LIST_MERGE: - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE - -.dut_init_espnow: &dut_init_espnow - LIST_MERGE: - - - SSC SSC[1,2] espnow -D - - - 'R SSC[1,2] C +ESPNOW:' - - - SSC SSC[1,2] espnow -I - - - 'R SSC[1,2] C +ESPNOW:' - -initial condition: -- tag: APM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode and config SoftAP, enable DHCP server - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK -- tag: APM2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode, PC Wi-Fi NIC connected with SoftAP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 ap -L - - - R SSC1 RE "\+LSTA:.+,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK -- tag: APO1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode and config SoftAP, enable DHCP server - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK -- tag: APO2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode, PC Wi-Fi NIC connected with SoftAP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 ap -L - - - R SSC1 RE "\+LSTA:.+,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK -- tag: APSTA1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA+SoftAP mode, config SoftAP and enable DHCP server - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK -- tag: APSTA2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA+SoftAP mode, PC Wi-Fi NIC connected with SoftAP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,\d+,\d+,4,"%%(,) - - - SSC SSC1 ap -L - - - R SSC1 RE "\+LSTA:.+,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK -- tag: APWIFISTO - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode, stop Wi-Fi - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a init - - - R SSC1 c +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK -- tag: APM2_MDNS - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to SoftAP mode, PC Wi-Fi NIC connected with SoftAP, restart MDNS - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC1 ap -L - - - R SSC1 RE "\+LSTA:.+,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK -- tag: BLE_CONN2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE one 2 DUTs, GATT service 0xA000 started on DUT2, DUT1 connected with DUT2 - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC2 gatts -S -z load -p 0xA0 - - - R SSC2 C +GATTS:StartService,OK,A000 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC2 gatts -S -z load -p 0xA0 - - - R SSC2 C +GATTS:StartService,OK,A000 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN3 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 2 DUTs, GATT service 0xA002 started on DUT2, DUT1 connected with DUT2 - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN4 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE and create both GATTC and GATTS app on DUT1 and DUT2. DUT1 connected with DUT2. use GATT service A002. - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] gatts -S -z load -p 0xA2 - - - R SSC[1-2] C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV - - - SSC SSC[1-2] gattc -F -r - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] gatts -S -z load -p 0xA2 - - - R SSC[1-2] C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC[1-2] gattc -F -r - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN5 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 5 DUTs, DUT1 connected with DUT2-5 as master, DUT2-5 use GATT service 0xA002 - check cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - SSC SSC[1-5] reboot - - - R SSC[1-5] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[2-5] gatts -S -z load -p 0xA2 - - - P SSC[2-5] C +GATTS:StartService,OK,A002 - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[2-5] bleadv -D -z start - - - P SSC[2-5] C +BLEADV:Start,OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - '' - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC{%d} C +BLECONN:GapConnect,OK - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] bt -D -z init - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] bt -D -z enable - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[2-5] gatts -S -z load -p 0xA2 - - - P SSC[2-5] C +GATTS:StartService,OK,A002 - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[2-5] bleadv -D -z start - - - P SSC[2-5] C +BLEADV:Start,OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - '' - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC{%d} C +BLECONN:GapConnect,OK, - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN6 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 5 DUTs, DUT1 is slave, connected by DUT2-5, DUT1 use GATT service 0xA002 - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] bt -D -z init - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] bt -D -z enable - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC1 gatts -S -z load -p 0xA2 - - - R SSC1 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - LOOP 4 3 "[2,3,4,5]" "[2,3,4,5]" - - '' - - - SSC SSC1 bleadv -D -z start - - - P SSC1 C +BLEADV:Start,OK - - - SSC SSC[2-5] gattc -F -r - - - R SSC[2-5] C +GATTC:OK - - - SSC SSC{%d} bleconn -C -p 0x10 -a - - - R SSC{%d} RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC1 C +BLECONN:GapConnect,OK - force restore cmd set: - - '' - - - SSC SSC[1-5] reboot - - - R SSC[1-5] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC1 gatts -S -z load -p 0xA2 - - - R SSC1 C +GATTS:StartService,OK,A002 - - - SSC SSC[2-5] gattc -F -r - - - R SSC[2-5] C +GATTC:OK - - - LOOP 4 3 "[2,3,4,5]" "[2,3,4,5]" - - '' - - - SSC SSC1 bleadv -D -z start - - - P SSC1 C +BLEADV:Start,OK - - - SSC SSC[2-5] gattc -F -r - - - R SSC[2-5] C +GATTC:OK - - - SSC SSC{%d} bleconn -C -p 0x10 -a - - - R SSC{%d} RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC1 C +BLECONN:GapConnect,OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN7 - <<: *SSC_INIT_COND - initial condition detail: (SSC) BLE is enable on 5 DUTs, DUT1 connected with DUT2-3 as master, connected with DUT4-5 as slave, use service 0xA002 on GATTS - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] bt -D -z init - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] bt -D -z enable - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[1-3] gatts -S -z load -p 0xA2 - - - R SSC[1-3] C +GATTS:StartService,OK,A002 - - - LOOP 2 2 "[4,5]" "[4,5]" - - '' - - - SSC SSC1 bleadv -D -z start - - - P SSC1 C +BLEADV:Start,OK - - - SSC SSC{%d} bleconn -C -p 0x10 -a - - - R SSC{%d} RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC1 C +BLECONN:GapConnect,OK - - - SSC SSC[2-3] bleadv -D -z start - - - P SSC[2-3] C +BLEADV:Start,OK - - - LOOP 2 1 "[2,3]" "[2,3]" "[2,3]" - - '' - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC{%d} C +BLECONN:GapConnect,OK, - force restore cmd set: - - '' - - - SSC SSC[1-5] reboot - - - R SSC[1-5] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[1-3] gatts -S -z load -p 0xA2 - - - R SSC[1-3] C +GATTS:StartService,OK,A002 - - - LOOP 2 2 "[4,5]" "[4,5]" - - '' - - - SSC SSC1 bleadv -D -z start - - - P SSC1 C +BLEADV:Start,OK - - - SSC SSC{%d} bleconn -C -p 0x10 -a - - - R SSC{%d} RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC1 C +BLECONN:GapConnect,OK, - - - SSC SSC[2-3] bleadv -D -z start - - - P SSC[2-3] C +BLEADV:Start,OK - - - LOOP 2 1 "[2,3]" "[2,3]" "[2,3]" - - '' - - - SSC SSC1 bleconn -C -p 0x10 -a - - - R SSC1 RE "\+BLECONN:GapConnect,OK,0010,%%s"%%() - - P SSC{%d} C +BLECONN:GapConnect,OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_CONN_SMP - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 2 DUTs, DUT1 connected and paired with DUT2, DUT2 created GATT service 0xA000 - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC2 blesmp -S -z AuthReqMode -v 0x01 - - - P SSC2 C +BLESMP:OK - - - SSC SSC2 blesmp -S -z IOCAP -v 0x03 - - - P SSC2 C +BLESMP:OK - - - SSC SSC2 blesmp -S -z RspKey -v 0x03 - - - P SSC2 C +BLESMP:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - P SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - - - SSC SSC2 blesmp -E -r -z Enc - - - P SSC[1-2] C +BLESMP:AuthComplete,Success,0 - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC2 blesmp -S -z AuthReqMode -v 0x01 - - - P SSC2 C +BLESMP:OK - - - SSC SSC2 blesmp -S -z IOCAP -v 0x03 - - - P SSC2 C +BLESMP:OK - - - SSC SSC2 blesmp -S -z RspKey -v 0x03 - - - P SSC2 C +BLESMP:OK - - - SSC SSC1 bleconn -C -p 0x10 -a - - - P SSC1 C +BLECONN:GapConnect,OK - - P SSC2 C +BLECONN:GapConnect,OK - - - SSC SSC2 blesmp -E -r -z Enc - - - P SSC[1-2] C +BLESMP:AuthComplete,Success,0 - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_DEINIT1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT deinit BT host - check cmd set: - - '' - - - SSC SSC1 bt -Q - - - R SSC1 C +BT:status,DEINIT - restore cmd set: - - '' - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -Q - - - R SSC1 C +BT:status,DEINIT - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 bt -D -z stop - - - R SSC1 C +BT:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BTC_DEINIT1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT deinit BT controller - check cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - "SSC SSC1 btc -D -z disable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:OK"] - - - SSC SSC1 btc -Q - - - R SSC1 C +BTC:status,IDLE - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -Q - - - R SSC1 C +BT:status,DEINIT - restore cmd set: - - '' - - - "SSC SSC1 btc -D -z disable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:OK"] - - - SSC SSC1 btc -Q - - - R SSC1 C +BTC:status,IDLE - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -Q - - - R SSC1 C +BT:status,DEINIT - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 btc -D -z stop - - - R SSC1 C +BTC:OK - - - SSC SSC1 bt -D -z stop - - - R SSC1 C +BT:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on DUT - check cmd set: - - '' - - - SSC SSC1 bt -Q - - - R SSC1 C +BT:status,ENABLE - - - SSC SSC1 ble -R - - - 'R SSC1 C +BLE:' - - - SSC SSC1 bleconn -Q - - - R SSC1 C +BLECONN:ConnCount,0 - restore cmd set: - - '' - - - SSC SSC1 bt -D -z init - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z enable - - - 'R SSC1 C +BT:' - - - SSC SSC1 ble -R - - - 'R SSC1 C +BLE:' - - - SSC SSC1 bleconn -D -z all - - - 'R SSC1 C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 bt -D -z init - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z enable - - - 'R SSC1 C +BT:' - - - SSC SSC1 ble -R - - - 'R SSC1 C +BLE:' - restore post cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC1 sta -D - - [] - - - SSC SSC1 bleconn -D -z all - - - 'R SSC1 C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC1 gatts -S -z delete - - - 'R SSC1 C +GATTS:' - - - SSC SSC1 gattc -U -z all - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 2 DUTs, no active connection, DUT2 load service 0xA0 and start adv - check cmd set: - - '' - - - SSC SSC[1-2] bt -Q - - - R SSC[1-2] C +BT:status,ENABLE - restore cmd set: - - '' - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - restore post cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC2 gatts -S -z load -p 0xA0 - - - R SSC2 C +GATTS:StartService,OK,A000 - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT3 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 2 DUTs, no active connection, DUT2 load service 0xA002 and start adv - check cmd set: - - '' - - - SSC SSC[1-2] bt -Q - - - R SSC[1-2] C +BT:status,ENABLE - restore cmd set: - - '' - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - restore post cmd set: - - '' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT5 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 5 DUTs, no active connection - check cmd set: - - '' - - - SSC SSC[1-5] bt -Q - - - R SSC[1-5] C +BT:status,ENABLE - restore cmd set: - - '' - - - SSC SSC[1-5] bt -D -z init - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] bt -D -z enable - - - 'R SSC[1-5] C +BT:' - force restore cmd set: - - '' - - - SSC SSC[1-5] reboot - - - R SSC[1-5] C !!!ready!!! - - - SSC SSC[1-5] bt -D -z init - - - 'R SSC[1-5] C +BT:' - - - SSC SSC[1-5] bt -D -z enable - - - 'R SSC[1-5] C +BT:' - restore post cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - "SSC SSC[2-5] gatts -S -z load -p 0xA2" - - ["P SSC[2-5] C +GATTS:StartService,OK,A002"] - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT_SMP - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 2 DUTs, no active connection, create GATT service 0xA002 on DUT2, DUT2 start adv, DUT1 load default initiator param, DUT2 load default responder param - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC[1-2] blesmp -L -c [1,0] - - - R SSC[1-2] C +BLESMP:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) - restore post cmd set: - - '' - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-2] sta -D - - [] - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC2 gatts -S -z load -p 0xA2 - - - R SSC2 C +GATTS:StartService,OK,A002 - - - SSC SSC2 bleadv -L -c 0 -t 3 - - - R SSC2 C +BLEADV:SetAdv,OK - - - SSC SSC2 bleadv -D -z start - - - R SSC2 C +BLEADV:Start,OK - - - SSC SSC[1-2] blesmp -L -c [1,0] - - - R SSC[1-2] C +BLESMP:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: BLE_INIT_SMP5 - <<: *SSC_INIT_COND - initial condition detail: (SSC) enable BLE on 5 DUTs, no active connection, create GATT service 0xA000 on DUT2-5, DUT2-5 start adv, DUT1 load default initiator param, DUT2-5 load default responder param - check cmd set: - - '' - - - ASSERT - - - '' - restore cmd set: - - '' - - - ASSERT - - - '' - force restore cmd set: - - '' - - - SSC SSC[1-5] reboot - - - R SSC[1-5] C !!!ready!!! - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[2-5] gatts -S -z load -p 0xA2 - - - R SSC[2-5] C +GATTS:StartService,OK,A002 - - - SSC SSC[2-5] bleadv -L -c 0 -t 3 - - - R SSC[2-5] C +BLEADV:SetAdv,OK - - - SSC SSC[2-5] bleadv -D -z start - - - R SSC[2-5] C +BLEADV:Start,OK - - - SSC SSC[1-5] blesmp -L -c [1,0] - - - R SSC[1-5] C +BLESMP:OK - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) - restore post cmd set: - - '' - - - SSC SSC[1-5] ble -R - - - 'R SSC[1-5] C +BLE:' - - - SSC SSC[1-5] bleconn -D -z all - - - 'R SSC[1-5] C +BLECONN:' - - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Success - - - SSC SSC[1-5] gatts -S -z delete - - - 'R SSC[1-5] C +GATTS:' - - - SSC SSC[1-5] gattc -U -z all - - - R SSC[1-5] C +GATTC:OK - - - SSC SSC[1-5] bleadv -D -z stop - - - R SSC[1-5] C +BLEADV:Stop - - - SSC SSC[1-5] ble -S -z public - - - R SSC[1-5] C +BLE:OK - - - SSC SSC[2-5] gatts -S -z load -p 0xA2 - - - R SSC[2-5] C +GATTS:StartService,OK,A002 - - - SSC SSC[2-5] bleadv -L -c 0 -t 3 - - - R SSC[2-5] C +BLEADV:SetAdv,OK - - - SSC SSC[2-5] bleadv -D -z start - - - R SSC[2-5] C +BLEADV:Start,OK - - - SSC SSC1 blesmp -L -c 1 - - - R SSC1 C +BLESMP:OK - - - SSC SSC[2-5] blesmp -L -c 0 - - - R SSC[2-5] C +BLESMP:OK - # do wifi disconnect, to prevent wifi reconnect cause bad BLE performance - - - SSC SSC[1-5] sta -D - - [] - - - SSC SSC1 gattc -F -r - - - R SSC1 C +GATTC:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: NOW_STAM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT in sta mode and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' -- tag: NOW_STAM2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT in sta mode, join AP and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' -- tag: NOW_APM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 in AP mode and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,8,\d+,\d+,4,"%%(,) - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t -n 8 - - - R SSC1 C +SAP:OK - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t -n 8 - - - R SSC1 C +SAP:OK - - - SSC SSC1 espnow -D - - - 'R SSC1 C +ESPNOW:' -- tag: NOW_T2_STAM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) two DUTs in sta mode, set same channel and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +CURMODE:1 - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] channel -G - - - R SSC[1,2] C +CHANNEL:5 - - - SSC SSC[1,2] dhcp -Q -o 1 - - - R SSC[1,2] C +DHCP:STA,STARTED - - - SSC SSC[1,2] mac -Q -o 1 - - - R SSC[1,2] P - - *dut_init_espnow - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o 1 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] channel -S -c 5 - - - R SSC[1,2] C +CHANNEL:OK - - - SSC SSC[1,2] dhcp -S -o 1 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 1 -m - - - R SSC[1,2] C +MAC:STA,OK - - *dut_init_espnow - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o 1 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] channel -S -c 5 - - - R SSC[1,2] C +CHANNEL:OK - - - SSC SSC[1,2] dhcp -S -o 1 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 1 -m - - - R SSC[1,2] C +MAC:STA,OK - - *dut_init_espnow -- tag: NOW_T2_STAM2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) one DUT in sta mode, one DUT in softap mode, station joins softap and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:2 - - - SSC SSC2 ap -Q - - - R SSC2 RE "\+APCONFIG:%%s,%%s,8,\d+,\d+,4,"%%(,) - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC2 dhcp -Q -o 2 - - - R SSC2 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 2 - - - R SSC2 P - - *dut_init_espnow - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 2 - - - R SSC2 C +MODE:OK - - - SSC SSC[1,2] dhcp -S -o [1,2] - - - R SSC[1,2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 8 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - *dut_init_espnow - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] op -S -o [1,2] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1,2] dhcp -S -o [1,2] - - - R SSC[1,2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 8 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - *dut_init_espnow -- tag: NOW_T2_APM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) 2 DUTs in softap mode, set same channel and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +CURMODE:2 - - - SSC SSC[1,2] ap -Q - - - R SSC[1,2] RE "\+APCONFIG:%%s,%%s,2,\d+,\d+,4,"%%(,) - - - SSC SSC[1,2] dhcp -Q -o 2 - - - R SSC[1,2] C +DHCP:AP,STARTED - - - SSC SSC[1,2] mac -Q -o 2 - - - R SSC[1,2] P - - *dut_init_espnow - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o 2 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] dhcp -S -o 2 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 2 -m - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] ap -S -s -p -t -n 2 - - - R SSC[1,2] C +SAP:OK - - *dut_init_espnow - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o 2 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] dhcp -S -o 2 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 2 -m - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] ap -S -s -p -t -n 2 - - - R SSC[1,2] C +SAP:OK - - *dut_init_espnow -- tag: NOW_T2_STAAP1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) two DUTs in sta + ap mode, set same channel and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +CURMODE:3 - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] ap -Q - - - R SSC[1,2] RE "\+APCONFIG:%%s,%%s,8,\d+,\d+,4,"%%(,) - - - SSC SSC[1,2] dhcp -Q -o 1 - - - R SSC[1,2] C +DHCP:STA,STARTED - - - SSC SSC[1,2] dhcp -Q -o 2 - - - R SSC[1,2] C +DHCP:AP,STARTED - - - SSC SSC[1,2] mac -Q -o 1 - - - R SSC[1,2] P - - - SSC SSC[1,2] mac -Q -o 2 - - - R SSC[1,2] P - - *dut_init_espnow - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] dhcp -S -o 1 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] dhcp -S -o 2 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 1 -m - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] mac -S -o 2 -m - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] ap -S -s -p -t -n 8 - - - R SSC[1,2] C +SAP:OK - - *dut_init_espnow - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sta -D - - - 'R SSC[1,2] C +QAP:' - - - SSC SSC[1,2] dhcp -S -o 1 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] dhcp -S -o 2 - - - R SSC[1,2] C +DHCP - - - SSC SSC[1,2] mac -S -o 1 -m - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] mac -S -o 2 -m - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] ap -S -s -p -t -n 8 - - - R SSC[1,2] C +SAP:OK - - *dut_init_espnow -- tag: NOW_T2_STAAP2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) one DUT in softap mode, one DUT in sta + softap mode, station join softap and espnow is de-initialized - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +CURMODE:3 - - - SSC SSC2 ap -Q - - - R SSC2 RE "\+APCONFIG:%%s,%%s,8,\d+,\d+,4,"%%(,) - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC2 dhcp -Q -o 2 - - - R SSC2 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 2 - - - R SSC2 P - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - *dut_init_espnow - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 2 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 8 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - *dut_init_espnow - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 2 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 8 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - *dut_init_espnow -- tag: None - <<: *SSC_INIT_COND - initial condition detail: (SSC) do nothing - check cmd set: - - '' - - - DELAY 0.1 - - - dummy - restore cmd set: - - '' - - - DELAY 0.1 - - - dummy - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - restore post cmd set: - - '' - - - DELAY 0.1 - - - dummy -- tag: PAIR1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 and simple is de-inited - check cmd set: - - '' - - - SSC SSC1 sp -D - - - R SSC1 C +SP:OK - restore cmd set: - - '' - - - SSC SSC1 sp -D - - - R SSC1 C +SP:OK - force restore cmd set: - - '' - - - SSC SSC1 sp -D - - - R SSC1 C +SP:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: PAIR2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 in SoftAP mode, DUT2 in STA mode, two DUTs deinit simple pair - and init simple pair - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +MODE:[2,1] - - - SSC SSC[1,2] mac -Q -o 3 - - - R SSC[1,2] P P - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] mac -S -m -o 2 - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] mac -S -m -o 1 - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] op -S -o [2,1] - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o 3 - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] mac -S -m -o 2 - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] mac -S -m -o 1 - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] op -S -o [2,1] - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: PAIR3 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 and DUT2 set to STA+SoftAP mode, two DUTs deinit simple pair - and init simple pair - check cmd set: - - '' - - - SSC SSC[1,2] op -Q - - - R SSC[1,2] C +MODE:[3,3] - - - SSC SSC[1,2] mac -Q -o 3 - - - R SSC[1,2] P P - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - restore cmd set: - - '' - - - SSC SSC[1,2] op -S -o [3,3] - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] mac -S -m -o 2 - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] mac -S -m -o 1 - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - force restore cmd set: - - '' - - - SSC SSC[1,2] reboot - - - R SSC[1,2] C !!!ready!!! - - - SSC SSC[1,2] op -S -o [3,3] - - - R SSC[1,2] C +MODE:OK - - - SSC SSC[1,2] mac -S -m -o 2 - - - R SSC[1,2] C +MAC:AP,OK - - - SSC SSC[1,2] mac -S -m -o 1 - - - R SSC[1,2] C +MAC:STA,OK - - - SSC SSC[1,2] sp -D - - - R SSC[1,2] C +SP:OK - - - SSC SSC[1,2] sp -I - - - R SSC[1,2] C +SP:OK - restore post cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: STAAP1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA+SoftAP mode, disconnected from AP, enable DHCP client - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK -- tag: STAAP2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA+SoftAP mode, connected with AP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() -- tag: STAM1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA mode, disconnected from AP, enable DHCP client - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK -- tag: STAM2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA mode, connected with AP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() -- tag: STAM2_MDNS - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA mode, connected with AP, restart MDNS - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 mdns -T - - - R SSC1 C +MDNS:OK - - - SSC SSC1 mdns -I - - - R SSC1 C +MDNS:OK -- tag: STAO1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA mode, disconnected from AP, enable DHCP client - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK -- tag: STAO2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT set to STA mode, connected with AP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() -- tag: T1_ETH - <<: *SSC_INIT_COND - initial condition detail: (SSC) ethernet is enabled and got IP from AP - check cmd set: - - '' - - - SSC SSC1 eth -N - - - R SSC1 C +ETHNET:OK - - - SSC SSC1 eth -E - - - R SSC1 C +ETHNET:IP - - - SSC SSC1 ip -I - - - R SSC1 C +ETHIP:192.168 - restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 eth -N - - - R SSC1 C +ETHNET:OK - - - SSC SSC1 eth -E - - - R SSC1 C +ETHNET:IP - - - SSC SSC1 ip -I - - - R SSC1 C +ETHIP:192.168 - force restore cmd set: - - '' - - - SSC SSC1 restore - - - R SSC1 C !!!ready!!! - - - SSC SSC1 eth -N - - - R SSC1 C +ETHNET:OK - - - SSC SSC1 eth -E - - - R SSC1 C +ETHNET:IP - - - SSC SSC1 ip -I - - - R SSC1 C +ETHIP:192.168 -- tag: T2O_1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to SoftAP mode, DUT2 set to STA mode, enable DHCP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:1 - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC2 reboot - - - R SSC2 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK -- tag: T2_1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to SoftAP mode, DUT2 set to STA mode, enable DHCP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:1 - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC2 reboot - - - R SSC2 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK -- tag: T2_2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 and DUT2 set to STA+SoftAP mode, enable DHCP - check cmd set: - - '' - - *dut1_start_wifi - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:3 - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 3 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC2 reboot - - - R SSC2 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 3 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK -- tag: T2_3 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to STA+SoftAP mode, DUT2 set to STA+SoftAP mode - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:3 - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - restore cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 3 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC2 reboot - - - R SSC2 C !!!ready!!! - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC2 op -S -o 3 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC2 dhcp -S -o 1 - - - R SSC2 C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK -- tag: T2_MDNS - <<: *SSC_INIT_COND - initial condition detail: (SSC) Both DUT set to STA mode, connected with AP, restart MDNS - check cmd set: - - '' - - - SSC SSC[1-2] op -Q - - - R SSC[1-2] C+CURMODE:1 - - - SSC SSC[1-2] sta -Q - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] dhcp -Q -o 1 - - - R SSC[1-2] C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-2] op -S -o [1,1] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o 1 - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC[1-2] sta -C -s -p - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] op -S -o 1 - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o 1 - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC[1-2] sta -C -s -p - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK -- tag: T2_MDNS_MODE1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to STA mode, DUT2 set to SoftAP mode, DUT1 connected with DUT2, restart MDNS - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C+CURMODE:1 - - - SSC SSC2 op -Q - - - R SSC2 C+CURMODE:2 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 ap -Q - - - R SSC2 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC2 dhcp -Q -o 2 - - - R SSC2 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 2 - - - R SSC2 P - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-2] op -S -o [1,2] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o [1,2] - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 7 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] op -S -o [1,2] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o [1,2] - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC2 ap -S -s -p -t -n 7 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK -- tag: T2_MDNS_MODE2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to SoftAP mode, DUT2 set to STA mode, DUT1 connected with DUT2, restart MDNS - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C+CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C+CURMODE:1 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC2 sta -Q - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-2] op -S -o [2,1] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o [2,1] - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] op -S -o [2,1] - - - R SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] dhcp -S -o [2,1] - - - R SSC[1-2] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-2] mdns -T - - - R SSC[1-2] C +MDNS:OK - - - SSC SSC[1-2] mdns -I - - - R SSC[1-2] C +MDNS:OK -- tag: T3_1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to STA+SoftAP mode, DUT2 and DUT3 set to STA mode - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC[2-3] op -Q - - - R SSC[2-3] C +CURMODE:1 - - - SSC SSC[1-3] sta -D - - - 'R SSC[1-3] C +QAP:' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP - - - SSC SSC[2-3] dhcp -Q -o 1 - - - R SSC[2-3] C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 1 - - - R SSC3 P - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o [3,1,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] sta -D - - - 'R SSC[1-3] C +QAP:' - - - SSC SSC[1-3] dhcp -S -o [2,1,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o [3,1,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] sta -D - - - 'R SSC[1-3] C +QAP:' - - - SSC SSC[1-3] dhcp -S -o [2,1,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK -- tag: T3_2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to SoftAP mode, DUT2 as STA mode - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:1 - - - SSC SSC3 op -Q - - - R SSC3 C +CURMODE:2 - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC3 dhcp -Q -o 2 - - - R SSC3 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 2 - - - R SSC3 P - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o [2,1,2] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC[1-3] dhcp -S -o [2,1,2] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 2 -m - - - R SSC3 C +MAC:AP,OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o [2,1,2] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC2 sta -D - - - 'R SSC2 C +QAP:' - - - SSC SSC2 soc -T - - - '' - - - SSC SSC[1-3] dhcp -S -o [2,1,2] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 2 -m - - - R SSC3 C +MAC:AP,OK -- tag: T3_3 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 set to SoftAp mode, DUT2-3 set to STA mode - check cmd set: - - '' - - - SSC SSC[1,2,3] op -Q - - - R SSC[1,2,3] C +CURMODE:[2,1,1] - - - SSC SSC[2,3] sta -D - - - 'R SSC[2,3] C +QAP:' - restore cmd set: - - '' - - - SSC SSC[1,2,3] op -S -o [2,1,1] - - - R SSC[1,2,3] C +MODE:OK - - - SSC SSC[2,3] sta -D - - - 'R SSC[2,3] C +QAP:' - force restore cmd set: - - '' - - - SSC SSC[1,2,3] reboot - - - R SSC[1,2,3] C !!!ready!!! - - - SSC SSC[1,2,3] op -S -o [2,1,1] - - - R SSC[1,2,3] C +MODE:OK - - - SSC SSC[2,3] sta -D - - - 'R SSC[2,3] C +QAP:' -- tag: T3_MDNS - <<: *SSC_INIT_COND - initial condition detail: (SSC) All 3 DUTs set to STA mode, connected with AP, restart MDNS - check cmd set: - - '' - - - SSC SSC[1-3] op -Q - - - R SSC[1-3] C +CURMODE:1 - - - SSC SSC[1-3] sta -Q - - - R SSC[1-3] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] dhcp -Q -o 1 - - - R SSC[1-3] C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 1 - - - R SSC3 P - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o 1 - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o 1 - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC[1-3] sta -C -s -p - - - R SSC[1-3] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o 1 - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o 1 - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC[1-3] sta -C -s -p - - - R SSC[1-3] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK -- tag: T3_MDNS_MODE1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 and DUT2 set to STA mode, DUT3 set to SoftAP mode, DUT1 and DUT2 connected with DUT3, restart MDNS on all DUTs - check cmd set: - - '' - - - SSC SSC[1-2] op -Q - - - R SSC[1-2] C +CURMODE:1 - - - SSC SSC3 op -Q - - - R SSC3 C +CURMODE:2 - - - SSC SSC[1-2] sta -Q - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 ap -Q - - - R SSC3 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC[1-2] dhcp -Q -o 1 - - - R SSC[1-2] C +DHCP:STA,STARTED - - - SSC SSC3 dhcp -Q -o 2 - - - R SSC3 C +DHCP:AP,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 2 - - - R SSC3 P - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o [1,1,2] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [1,1,2] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 2 -m - - - R SSC3 C +MAC:AP,OK - - - SSC SSC3 ap -S -s -p -t -n 7 - - - R SSC3 C +SAP:OK - - - SSC SSC[1-2] sta -C -s -p - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o [1,1,2] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [1,1,2] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 2 -m - - - R SSC3 C +MAC:AP,OK - - - SSC SSC3 ap -S -s -p -t -n 7 - - - R SSC3 C +SAP:OK - - - SSC SSC[1-2] sta -C -s -p - - - R SSC[1-2] RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK -- tag: T3_MDNS_MODE2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1 and DUT3 set to STA mode, DUT2 set to SoftAP mode, DUT1 and DUT3 connected with DUT2, restart MDNS on all DUTs - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:1 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:2 - - - SSC SSC3 op -Q - - - R SSC3 C +CURMODE:1 - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 ap -Q - - - R SSC2 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC3 sta -Q - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED - - - SSC SSC2 dhcp -Q -o 2 - - - R SSC2 C +DHCP:AP,STARTED - - - SSC SSC3 dhcp -Q -o 1 - - - R SSC3 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 1 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 2 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 1 - - - R SSC3 P - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o [1,2,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [1,2,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC2 ap -S -s -p -t -n 7 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 sta -C -s -p - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o [1,2,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [1,2,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC2 mac -S -o 2 -m - - - R SSC2 C +MAC:AP,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC2 ap -S -s -p -t -n 7 - - - R SSC2 C +SAP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 sta -C -s -p - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK -- tag: T3_MDNS_MODE3 - <<: *SSC_INIT_COND - initial condition detail: softap + sta + sta mode, sta join softap, DHCP on, mdns stop - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:2 - - - SSC SSC2 op -Q - - - R SSC2 C +CURMODE:1 - - - SSC SSC3 op -Q - - - R SSC3 C +CURMODE:1 - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,7,\d+,\d+,4,"%%(,) - - - SSC SSC2 sta -Q - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 sta -Q - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 C +DHCP:AP,STARTED - - - SSC SSC2 dhcp -Q -o 1 - - - R SSC2 C +DHCP:STA,STARTED - - - SSC SSC3 dhcp -Q -o 1 - - - R SSC3 C +DHCP:STA,STARTED - - - SSC SSC1 mac -Q -o 2 - - - R SSC1 P - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 P - - - SSC SSC3 mac -Q -o 1 - - - R SSC3 P - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o [2,1,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [2,1,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 sta -C -s -p - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o [2,1,1] - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] dhcp -S -o [2,1,1] - - - R SSC[1-3] C +DHCP - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - - - SSC SSC3 mac -S -o 1 -m - - - R SSC3 C +MAC:STA,OK - - - SSC SSC1 ap -S -s -p -t -n 7 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC3 sta -C -s -p - - - R SSC3 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC[1-3] mdns -T - - - R SSC[1-3] C +MDNS:OK - - - SSC SSC[1-3] mdns -I - - - R SSC[1-3] C +MDNS:OK -- tag: T3_PHY1 - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT1-2 set to STA+SoftAP mode, DUT3 set to STA mode. All interface of DUT2-3 set to 11n ht40. Set DUT1-2 SoftAP config. - check cmd set: - - '' - - - SSC SSC[1-3] op -Q - - - R SSC[1-3] C +CURMODE:3 - - - SSC SSC[1-3] phy -Q -o 3 - - - R SSC[1-3] C STA,n,40 C AP,n,40 - restore cmd set: - - '' - - - SSC SSC[1-3] op -S -o 3 - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] phy -S -o 3 -m n -b 40 - - - R SSC[1-3] C +PHY:OK - force restore cmd set: - - '' - - - SSC SSC[1-3] reboot - - - R SSC[1-3] C !!!ready!!! - - - SSC SSC[1-3] op -S -o 3 - - - R SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] phy -S -o 3 -m n -b 40 - - - R SSC[1-3] C +PHY:OK - restore post cmd set: - - '' - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSEALL - - - SSC SSC1 sta -R -r 1 - - - R SSC1 C OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) -- tag: WIFIBTSTOP - <<: *SSC_INIT_COND - initial condition detail: (SSC) deinit Wi-Fi and BT host/controller - check cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +CURMODE:3 - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:OK - - - SSC SSC1 btc -D -z stop - - - 'R SSC1 C +BTC:' - - - SSC SSC1 bt -D -z stop - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' - restore cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:OK - - - SSC SSC1 btc -D -z stop - - - 'R SSC1 C +BTC:' - - - SSC SSC1 bt -D -z stop - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:OK - - - SSC SSC1 btc -D -z stop - - - 'R SSC1 C +BTC:' - - - SSC SSC1 bt -D -z stop - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z disable - - - 'R SSC1 C +BT:' - - - SSC SSC1 bt -D -z deinit - - - 'R SSC1 C +BT:' -- tag: WIFISTO - <<: *SSC_INIT_COND - initial condition detail: (SSC) DUT in STA mode, stop Wi-Fi - check cmd set: - - '' - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - restore cmd set: - - '' - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - force restore cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK -- tag: BLE_INIT_REBOOT2 - <<: *SSC_INIT_COND - initial condition detail: (SSC) reboot and enable BLE on DUT1 and DUT2 - check cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - restore cmd set: - - '' - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - force restore cmd set: - - '' - - - SSC SSC[1-2] reboot - - - R SSC[1-2] C !!!ready!!! - - - SSC SSC[1-2] bt -D -z init - - - 'R SSC[1-2] C +BT:' - - - SSC SSC[1-2] bt -D -z enable - - - 'R SSC[1-2] C +BT:' - restore post cmd set: - - '' - - - SSC SSC[1-2] ble -R - - - 'R SSC[1-2] C +BLE:' - - - SSC SSC[1-2] bleconn -D -z all - - - 'R SSC[1-2] C +BLECONN:' - - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Success - - - SSC SSC[1-2] gatts -S -z delete - - - 'R SSC[1-2] C +GATTS:' - - - SSC SSC[1-2] gattc -U -z all - - - R SSC[1-2] C +GATTC:OK - - - SSC SSC[1-2] bleadv -D -z stop - - - R SSC[1-2] C +BLEADV:Stop - - - SSC SSC[1-2] ble -S -z public - - - R SSC[1-2] C +BLE:OK - - - SSC SSC1 ram - - - R SSC1 A :(\d+) diff --git a/components/idf_test/integration_test/KnownIssues b/components/idf_test/integration_test/KnownIssues index d54237bc3..28c540b2f 100644 --- a/components/idf_test/integration_test/KnownIssues +++ b/components/idf_test/integration_test/KnownIssues @@ -1,76 +1,25 @@ -# NOT SUPPORT - -# ICMP send Ping not supported -TCPIP_ICMP_0101 -TCPIP_ICMP_0101_01 - -# Bug or not stable cases - -# Wifi scan issue -WIFI_SCAN_0303 -WIFI_SCAN_0303_01 -WIFI_CONN_0302 -WIFI_CONN_0302_01 -WIFI_MODE_0102 -WIFI_MODE_0103 -WIFI_ADDR_0102 -WIFI_ADDR_0102_01 - -# IGMP -TCPIP_IGMP_0201 -TCPIP_IGMP_0201_01 -TCPIP_IGMP_0202 -TCPIP_IGMP_0202_01 -TCPIP_IGMP_0204 -TCPIP_IGMP_0204_01 - -# TCP -TCPIP_TCP_0401_01_02 - -# UDP -TCPIP_UDP_0103 -TCPIP_UDP_0103_01 -TCPIP_UDP_0103_02 -TCPIP_UDP_0103_01_02 - -# BLE - # BT heap size issue -BTSTK_MISC_0301 - -# SMP -BTSTK_SMP_05001 -BTSTK_SMP_05002 -BTSTK_SMP_05003 -BTSTK_SMP_06004 - -# multi connect -BTSTK_GAP_10001 -BTSTK_GAP_10002 -BTSTK_GAP_10003 -BTSTK_GAP_10004 -BTSTK_GAP_11001 -BTSTK_GAP_11002 -BTSTK_GAP_12001 -BTSTK_GAP_12002 -BTSTK_GATT_30001 -BTSTK_GATT_30002 -BTSTK_GATT_30003 -BTSTK_GATT_31001 -BTSTK_GATT_31002 -BTSTK_GATT_31003 -BTSTK_GATT_32001 -BTSTK_GATT_32002 -BTSTK_GATT_32003 -BTSTK_GATT_32004 -BTSTK_GATT_33001 -BTSTK_GATT_33002 -BTSTK_GATT_33003 -BTSTK_GATT_34001 -BTSTK_GATT_34002 -BTSTK_GATT_34003 +ESP32.BTSTK_MISC_0301 # GATT read multiple -BTSTK_GATT_27002 -BTSTK_GATT_27003 +ESP32.BTSTK_GATT_27002 +ESP32.BTSTK_GATT_27003 + +# CI +ESP32.BLUEDROID_GAP_05002 +ESP32.BLUEDROID_GAP_05003 +ESP32.TCPIP_UDP_0102_01_02 +ESP32.TCPIP_UDP_0102_02 +ESP32.TCPIP_UDP_0301_01_02 +ESP32.TCPIP_UDP_0301_02 +ESP32.TCPIP_UDP_0302_01_02 +ESP32.TCPIP_UDP_0302_02 +ESP32.TCPIP_UDP_0102_01_02 +ESP32.TCPIP_UDP_0102_02 +ESP32.TCPIP_UDP_0303_01_02 +ESP32.TCPIP_UDP_0303_02 +ESP32.TCPIP_UDP_0304_01_02 +ESP32.TCPIP_UDP_0304_02 +ESP32.TCPIP_UDP_0305_01_02 +ESP32.TCPIP_UDP_0305_02 \ No newline at end of file diff --git a/components/idf_test/integration_test/TC_IT_BLUEDROID_GAP.yml b/components/idf_test/integration_test/TC_IT_BLUEDROID_GAP.yml deleted file mode 100644 index 8a378df62..000000000 --- a/components/idf_test/integration_test/TC_IT_BLUEDROID_GAP.yml +++ /dev/null @@ -1,1213 +0,0 @@ -.GAP_CASE: &GAP_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_INIT2 - test environment: SSC_T2_5 - execution time: 0 - module: BLUEDROID - sub module: GAP - version: v1 (2016-12-31) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.set_default_ble_name: &set_default_ble_name - LIST_MERGE: - - - "SSC SSC1 ble -S -z name -n " - - ["R SSC1 C +BLE:OK"] - -.open_capture_nic: &open_capture_nic - LIST_MERGE: - - - "NIC BLENIC START bt+capture" - - ['R PC_COM C +NIC_START:OK'] - -.dut1_stop_adv: &dut1_stop_adv - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - -.dut1_start_adv: &dut1_start_adv - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - -.dut1_connect_to_dut2: &dut1_connect_to_dut2 - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - -.set_default_adv_data: &set_default_adv_data - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - -.dut2_stop_adv: &dut2_stop_adv - LIST_MERGE: - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:"] - -test cases: -- ID: BLUEDROID_GAP_01003 - <<: *GAP_CASE - test point 2: BLE GAP param device name test - summary: ble set long device name for BLUEDROID - steps: | - 1. DUT1 set 32 byte device name A - 2. stop advertising - 3. config scan response and start advertising - 4. DUT2 do active scan - 5. DUT1 set 33 bytes device name - 6. stop advertising - 7. config scan response and start advertising - 8. DUT2 do active scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. DUT1 mac in scan result (device name is too long) - 5. failed - 6. succeed - 7. succeed - 8. DUT1 mac in scan result (device name is too long) - cmd set: - - "" - - - "SSC SSC1 ble -S -z name -n " - - ["R SSC1 C +BLE:OK"] - - *set_default_adv_data - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 3 -c 0 -s 1" - - ["R SSC2 P C Complete"] - - - "SSC SSC1 ble -S -z name -n 123456789012345678901234567890123" - - ["R SSC1 C +BLE:ERROR"] - - *set_default_adv_data - - - "SSC SSC2 blescan -D -z start -t 3 -c 0 -s 1" - - ["R SSC2 P C Complete"] -- ID: BLUEDROID_GAP_03003 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set adv parameter own address type for BLUEDROID - steps: | - 1. DUT1 stop advertise - 2. DUT1 start adv with own address type public - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with own address type random, rpa_public, rpa_random - 5. repeat step 1-3 with channel map not valid - expected result: | - 1. succeed - 2. succeed - 3. get ADV_IND with DUT1 BT MAC - 4. get ADV_IND with DUT1 BT MAC - 5. can not get ADV_IND with DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - cmd set: - - "" - - *set_default_ble_name - - - "SSC SSC1 bleadv -L -c 0 -t 3 -n 1" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *open_capture_nic - - - LOOP 4 3 "[0,2,1,3]" "['PDU','PDU','NPDU','NPDU']" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -D -z start -t 0 -o {%d}" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC {%s} (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.data_0.NameComplete=)(HCIEvent.address_0=)' -- ID: BLUEDROID_GAP_03006 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set paramters for SCAN_IND for BLUEDROID - steps: | - 1. DUT1 stop advertise - 2. DUT1 set incorrect adv interval for SCAN_IND - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with correct adv interval - expected result: | - 1. succeed - 2. succeed - 3. can not get SCAN_IND with DUT1 BT MAC - 4. get SCAN_IND with DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - cmd set: - - "" - - *set_default_ble_name - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *open_capture_nic - - *dut1_stop_adv - - - LOOP 2 2 "['0x20-0x40','0xA0-0xB0']" "['PDU','PDU']" - - [""] - - - "SSC SSC1 bleadv -D -z start -t 2 -i {%s}" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC {%s} (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_IND")(HCIEvent.address_0=)' -- ID: BLUEDROID_GAP_03007 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set paramters for NONCONN_IND for BLUEDROID - steps: | - 1. DUT1 stop advertise - 2. DUT1 set incorrect adv interval for NONCONN_IND - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with correct adv interval - expected result: | - 1. succeed - 2. succeed - 3. can not get SCAN_IND with DUT1 BT MAC - 4. get SCAN_IND with DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - cmd set: - - "" - - *set_default_ble_name - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *open_capture_nic - - *dut1_stop_adv - - - LOOP 2 2 "['0x20-0x40','0xA0-0xB0']" "['PDU','PDU']" - - [""] - - - "SSC SSC1 bleadv -D -z start -t 3 -i {%s}" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC {%s} (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="NONCONN_IND")(HCIEvent.address_0=)' -- ID: BLUEDROID_GAP_06001 - <<: *GAP_CASE - test point 2: BLE GAP connect / disconnect - summary: ble connect as "client" and "server" for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT1 connect to DUT2 as "client" - 2. DUT1 disconnected with DUT2 - 3. DUT1 start gatt server app - 4. DUT1 connect to DUT2 as "server" - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - cmd set: - - "" - - *dut1_connect_to_dut2 - - - "SSC SSC1 bleconn -D -p 0x10" - - ['R SSC1 C +BLE:CLOSE,OK'] - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ['R SSC1 C +GATTS:LoadProfile,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC1 bleconn -C -p 0xA0 -a -z server" - - ['R SSC1 C +BLECONN:GapConnect'] -- ID: BLUEDROID_GAP_06002 - <<: *GAP_CASE - test point 2: BLE GAP connect / disconnect - summary: ble disconnect as "client" and "server" for BLUEDROID - steps: | - 1. DUT1 connect to DUT2 as "client" - 2. DUT1 disconnected with DUT2 as "client" - 3. DUT1 start gatt server app - 4. DUT1 connect to DUT2 as client - 5. DUT1 disconnect with DUT2 as "server" - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - *dut1_connect_to_dut2 - - - "SSC SSC1 bleconn -D -p 0x10" - - ['R SSC1 C +BLE:CLOSE,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ['R SSC1 C +GATTS:LoadProfile,OK'] - - *dut1_connect_to_dut2 - - - "SSC SSC1 bleconn -D -p 0x10" - - ['R SSC1 C +BLE:CLOSE,OK'] -- ID: BLUEDROID_GAP_06003 - <<: *GAP_CASE - allow fail: 1/2 - test point 2: BLE GAP connect / disconnect - summary: ble connect/disconnect to same connection multiple times for BLUEDROID - steps: | - 1. DUT1 connect to DUT2 as "client" - 2. DUT1 start gatt server app - 3. DUT1 connect to DUT2 as "client" again - 4. DUT1 connect to DUT2 as "server" - 5. DUT1 disconnected with DUT2 as "client" - 6. DUT1 disconnected with DUT2 as "server" - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - cmd set: - - "" - - *dut1_connect_to_dut2 - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ['R SSC1 C +GATTS:LoadProfile,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLE:GattcOpen,OK'] - - - "SSC SSC1 bleconn -C -p 0xA0 -a -z server" - - ['R SSC1 C +BLE:GattsOpen,OK,00A0'] - - - "SSC SSC1 bleconn -D -p 0x10" - - ['R SSC1 C +BLE:CLOSE,OK'] - - - "SSC SSC1 bleconn -D -p 0xA0 -z server" - - ['R SSC1 C +BLE:GattsClose,OK'] -- ID: BLUEDROID_GAP_06004 - <<: *GAP_CASE - test point 2: BLE GAP connect / disconnect - summary: ble connect to invalid address for BLUEDROID - allow fail: 2/3 - steps: | - 1. DUT1 connect to invalid address - 2. DUT1 connect to DUT2 - expected result: | - 1. failed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a 24:0a:c4:04:26:50" - - ['R SSC1 C +BLECONN:OK'] - - - DELAY 30 - - ['R SSC1 C +BLE:GattcOpen,ERROR'] - - *dut1_connect_to_dut2 -- ID: BLUEDROID_GAP_06005 - <<: *GAP_CASE - test point 2: BLE GAP connect / disconnect - summary: ble connect/disconnect event to active app for BLUEDROID - steps: | - 1. DUT1 create gatts app - 2. DUT1 connect to DUT2 as "client" - 3. DUT1 do disconnect as "server" - expected result: | - 1. succeed - 2. succeed, DUT1 and DUT2 gatts get connect event - 3. DUT1 and DUT2 gatts get disconnect event - cmd set: - - "" - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ['R SSC1 C +GATTS:LoadProfile,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect', 'P SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC1 bleconn -D -p 0xA0 -z server" - - ['P SSC1 C +BLE:GattsClose'] -- ID: BLUEDROID_GAP_07001 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters by master for BLUEDROID - steps: | - 1. update connect parameters by master - expected result: | - 1. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["32"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07002 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters by slave for BLUEDROID - steps: | - 1. update connect parameters by slave - expected result: | - 1. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["32"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07003 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect parameters(timeout<(1+latency)*2*MAX_interval*1.25) for BLUEDROID - steps: | - 1. update invalid connect parameters(timeout<(1+latency)*2*MAX_interval*1.25) - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["7-90"] - - [''] - - - latency=["1"] - - [''] - - - supervision_timeout=["41"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07004 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connnect parameters and interval within allowed range for BLUEDROID - steps: | - 1. DUT1 update connection parametres and interval is 6-128 - 2. DUT1 update connection parametres and interval is 33-3200 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC1"] - - [''] - - - interval=["6-128","33-3200"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["50","1000"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07005 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters interval and interval out of allowed range for BLUEDROID - steps: | - 1. DUT1 update invalid interval and interval is 16-3201 - 2. DUT1 update invalid interval and interval is 5-64 - expected result: | - 1. fail - 2. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC1"] - - [''] - - - interval=["16-3201","5-64"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["32","32"] - - [''] - - - expect_result=["ERROR","ERROR"] - - [''] -- ID: BLUEDROID_GAP_07006 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters latency and latency within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 for BLUEDROID - steps: | - 1. DUT1 update connect parameters latency and latency within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["8"] - - [''] - - - supervision_timeout=["32"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07007 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters latency and latency = 501 - steps: | - 1. DUT1 uupdate connect parameters latency and latency = 501 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["6-8"] - - [''] - - - latency=["501"] - - [''] - - - supervision_timeout=["1003"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07008 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters latency and latency = 500 for BLUEDROID - steps: | - 1. DUT1 update connect parameters latency and latency = 500 - expected result: | - 1. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["6-8"] - - [''] - - - latency=["500"] - - [''] - - - supervision_timeout=["1003"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07009 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 for BLUEDROID - steps: | - 1. DUT1 update connect parameters timeout and timeout within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["12"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07010 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 9 for BLUEDROID - steps: | - 1. DUT1 update connect parameters timeout and timeout = 9 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["9"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07011 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout within allowed range for BLUEDROID - steps: | - 1. DUT1 update timeout = 10 - 2. DUT1 update timeout = 3200 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC1"] - - [''] - - - interval=["8-10","8-10"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["10","3200"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07012 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 3201 for BLUEDROID - steps: | - 1. DUT1 update timeout = 3201 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["3201"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07013 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect parameters before configure connect param event back for BLUEDROID - steps: | - 1. DUT1 update valid interval - 2. DUT1 update valid interval - expected result: | - 1. - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "" - - - "SSC SSC1 bleconn -S -z ConnParam -a " - - [''] - - - "SSC SSC1 bleconn -S -z ConnParam -a -t 0x40" - - ['R SSC1 C pending'] -- ID: BLUEDROID_GAP_07014 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect param and unpdate valid connect params by master for BLUEDROID - steps: | - 1. DUT1 update invalid connect parameters - 2. DUT2 update valid connect - expected result: | - 1. fail - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC1"] - - [''] - - - interval=["32-64","32-64"] - - [''] - - - latency=["9","0"] - - [''] - - - supervision_timeout=["32","32"] - - [''] - - - expect_result=["ERROR","OK"] - - [''] -- ID: BLUEDROID_GAP_07015 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect parameters twice for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT1 update valid connect parameters - 2. DUT1 update valid connect parameters - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC1"] - - [''] - - - interval=["7-80","10-100"] - - [''] - - - latency=["1","0"] - - [''] - - - supervision_timeout=["41","30"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07016 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect parameters(timeout<(1+latency)*2*MAX_interval*1.25) by slave for BLUEDROID - steps: | - 1. DUT2 update valid connect parameters(timeout<(1+latency)*2*MAX_interval*1.25) by slave - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["7-90"] - - [''] - - - latency=["1"] - - [''] - - - supervision_timeout=["41"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07017 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connnect parameters interval within allowed range by slave for BLUEDROID - steps: | - 1. DUT2 update interval 6-128 - 2. DUT2 update interval 21-3200 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC2"] - - [''] - - - interval=["6-128","21-3200"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["50","1000"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07018 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connnect parameters interval out of allowed range by slave for BLUEDROID - steps: | - 1. DUT2 update invalid interval 10-3201 - 2. DUT2 update invalid interval 5-64 - expected result: | - 1. fail - 2. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC2"] - - [''] - - - interval=["10-3201","5-64"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["32","32"] - - [''] - - - expect_result=["ERROR","ERROR"] - - [''] -- ID: BLUEDROID_GAP_07019 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connnect parameters and latency within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 by slave for BLUEDROID - steps: | - 1. DUT2 update connnect parameters and latency within allowed range and timeout<(1+latency)*2*MAX_interval*1.25 by slave - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["8"] - - [''] - - - supervision_timeout=["32"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07020 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters latency and latency out of allowed range by slave for BLUEDROID - steps: | - 1. DUT2 update invalid latency = 501 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["6-8"] - - [''] - - - latency=["501"] - - [''] - - - supervision_timeout=["1003"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07021 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect parameters and latency = 500 by slave for BLUEDROID - steps: | - 1. DUT2 update latency = 500 - expected result: | - 1. success - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["6-8"] - - [''] - - - latency=["500"] - - [''] - - - supervision_timeout=["1003"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07022 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 9 by slave for BLUEDROID - steps: | - 1. DUT2 update connect parameters timeout and timeout = 9 - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["9"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07023 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 10 by slave for BLUEDROID - steps: | - 1. DUT2 update connect parameters timeout and timeout = 10 by slave - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["10"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07024 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 3200 by slave for BLUEDROID - steps: | - 1. DUT2 update connect parameters timeout and timeout = 3200 by slave - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["3200"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_07025 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters timeout and timeout = 3201 by slave for BLUEDROID - steps: | - 1. DUT2 update connect parameters timeout and timeout = 3201 by slave - expected result: | - 1. fail - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2"] - - [''] - - - interval=["8-10"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["3201"] - - [''] - - - expect_result=["ERROR"] - - [''] -- ID: BLUEDROID_GAP_07026 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect parameters before configure connect param event back by slave for BLUEDROID - steps: | - 1. DUT2 update valid interval - 2. DUT2 update valid interval - expected result: | - 1. - 2. pending - initial condition: BLE_CONN2 - cmd set: - - "" - - - "SSC SSC2 bleconn -S -z ConnParam -a " - - [''] - - - "SSC SSC2 bleconn -S -z ConnParam -a -t 0x40" - - ['R SSC2 C pending'] -- ID: BLUEDROID_GAP_07027 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect param and update valid connect params by slave for BLUEDROID - steps: | - 1. DUT2 update invalid connect - 2. DUT2 update valid connect - expected result: | - 1. fail - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC2"] - - [''] - - - interval=["32-64","32-64"] - - [''] - - - latency=["0","0"] - - [''] - - - supervision_timeout=["9","21"] - - [''] - - - expect_result=["ERROR","OK"] - - [''] -- ID: BLUEDROID_GAP_07028 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect parameters twice by slave for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT2 update valid interval - 2. DUT2 update valid interval - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC2"] - - [''] - - - interval=["7-80","10-100"] - - [''] - - - latency=["1","0"] - - [''] - - - supervision_timeout=["41","30"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07029 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect param by master and update valid connect params by slave for BLUEDROID - steps: | - 1. DUT1 update invalid connect - 2. DUT2 update valid connect - expected result: | - 1. fail - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC2"] - - [''] - - - interval=["32-64","32-64"] - - [''] - - - latency=["9","0"] - - [''] - - - supervision_timeout=["32","32"] - - [''] - - - expect_result=["ERROR","OK"] - - [''] -- ID: BLUEDROID_GAP_07030 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect param by master and update valid connect params by slave for BLUEDROID - steps: | - 1. DUT1 update valid interval - 2. DUT2 update valid interval - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1","SSC2"] - - [''] - - - interval=["7-80","10-100"] - - [''] - - - latency=["1","0"] - - [''] - - - supervision_timeout=["41","30"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07031 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update invalid connect param by slave and update valid connect params by master for BLUEDROID - steps: | - 1. DUT1 update invalid connect - 2. DUT2 update valid connect - expected result: | - 1. fail - 2. success - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC1"] - - [''] - - - interval=["32-64","32-64"] - - [''] - - - latency=["9","0"] - - [''] - - - supervision_timeout=["32","32"] - - [''] - - - expect_result=["ERROR","OK"] - - [''] -- ID: BLUEDROID_GAP_07032 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update valid connect param by slave and update valid connect params by master for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT2 update valid interval - 2. DUT1 update valid interval - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN2 - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC2","SSC1"] - - [''] - - - interval=["7-80","10-100"] - - [''] - - - latency=["1","0"] - - [''] - - - supervision_timeout=["41","30"] - - [''] - - - expect_result=["OK","OK"] - - [''] -- ID: BLUEDROID_GAP_07033 - <<: *GAP_CASE - test point 2: BLE GAP update connect parameters - summary: update connect parameters by master after pairing for BLUEDROID - steps: | - 1. DUT1 update connection parameters - expected result: | - 1. succeed - initial condition: BLE_CONN_SMP - cmd set: - - "BLEFunction/ConnParamUpdate" - - - dut = ["SSC1"] - - [''] - - - interval=["32-64"] - - [''] - - - latency=["0"] - - [''] - - - supervision_timeout=["32"] - - [''] - - - expect_result=["OK"] - - [''] -- ID: BLUEDROID_GAP_09001 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: process scan data txp, manufacturer data, interval range, appearence, flag - steps: | - 1. DUT1 set raw adv data tx power, manufacturer data, interval range, apperaence, flag - 2. DUT1 start adv - 3. DUT2 do active scan with extended scan data - expected result: | - 1. succeed - 2. succeed - 3. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -R -t 1 -r 0x020AEB06FF1112131415051220004000021901020106" - - ["R SSC1 C +BLEADV:OK"] - - *dut1_start_adv - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x1112131415"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,txp,0xEB"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,intrange,0x20004000"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,app,0x01"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,flag,0x06"%%()' - - 'R SSC2 C Complete' -- ID: BLUEDROID_GAP_09004 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: process combined adv data and scan response data - steps: | - 1. DUT1 set raw adv data manufacturer data - 2. DUT1 set scan response data tx power, interval range, apperaence, flag - 2. DUT1 start adv - 3. DUT2 do active scan with extended scan data 19 - expected result: | - 1. succeed - 2. succeed - 3. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -R -t 1 -r 0x15FF1011121314151617181910111213141516171819" - - ["R SSC1 C +BLEADV:OK"] - - - "SSC SSC1 bleadv -R -t 2 -r 0x020AEB051220004000021901020106" - - ["R SSC1 C +BLEADV:OK"] - - *dut1_start_adv - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x1011121314151617181910111213141516171819"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,txp,0xEB"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,intrange,0x20004000"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,app,0x01"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,flag,0x06"%%()' - - 'R SSC2 C Complete' -- ID: BLUEDROID_GAP_09007 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included adv interval - steps: | - 1. DUT1 stop advertise and set short device name - 2. DUT1 set max interval 0x40 min interval 0x20 for adv data and scan response - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertising - 6. DUT1 set max interval 0x400 min interval 0x200 for adv data and scan response - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - *set_default_ble_name - - - "SSC SSC1 bleadv -L -c 0 -i 0x20-0x40 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,intrange,0x20004000"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -i 0x200-0x400 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,intrange,0x00020004"%%()' - - 'R SSC2 C Complete' -- ID: BLUEDROID_GAP_13001 - <<: *GAP_CASE - test point 2: BLE GAP param packet data length test - summary: gattc set packet data length at valid length (27-251) for BLUEDROID - steps: | - 1. DUT1 connect DUT2 - 2. DUT1 set packet data length - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - - LOOP 3 1 "[27,200,251]" "[27,200,251]" - - - "SSC SSC1 ble -S -z pktLen -a -l {%d}" - - ["R SSC1 C +BLECONN:UpdatePktLen,OK,{%d}"] -- ID: BLUEDROID_GAP_13002 - <<: *GAP_CASE - test point 2: BLE GAP param packet data length test - summary: gattc set packet data length at invalid length for BLUEDROID - steps: | - 1. DUT1 connect DUT2 - 2. DUT1 set packet data length - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - - LOOP 2 1 "[26,252]" "[27,251]" - - - "SSC SSC1 ble -S -z pktLen -a -l {%d}" - - ["R SSC1 C +BLECONN:UpdatePktLen,OK,{%d}"] -- ID: BLUEDROID_GAP_13003 - <<: *GAP_CASE - test point 2: BLE GAP param packet data length test - summary: gatts set packet data length at valid length (27-251) for BLUEDROID - steps: | - 1. DUT1 connect DUT2 - 2. DUT1 set packet data length - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - - LOOP 3 1 "[27,200,251]" "[27,200,251]" - - - "SSC SSC2 ble -S -z pktLen -a -l {%d}" - - ["R SSC2 C +BLECONN:UpdatePktLen,OK,{%d}"] -- ID: BLUEDROID_GAP_13004 - <<: *GAP_CASE - test point 2: BLE GAP param packet data length test - summary: gatts set packet data length at invalid length for BLUEDROID - steps: | - 1. DUT1 connect DUT2 - 2. DUT1 set packet data length - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - - LOOP 2 1 "[26,252]" "[27,251]" - - - "SSC SSC2 ble -S -z pktLen -a -l {%d}" - - ["R SSC2 C +BLECONN:UpdatePktLen,OK,{%d}"] -- ID: BLUEDROID_GAP_40001 - <<: *GAP_CASE - auto test: 'No' - test point 2: test if BLE work after switch off some sub modules - summary: GAP only test for BLUEDROID - steps: | - 1. download GAP only SSC bin on both DUT - 2. DUT1 set ascii device name - 3. stop advertising - 4. config scan response and start advertising - 5. DUT2 do active scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. device name in scan result - initial condition: None - version: v1 (2017-05-19) - cmd set: - - "" - - - "SSC SSC[1-2] reboot" - - ['R SSC[1-2] C !!!ready!!!'] - - - "SSC SSC[1-2] ble -R" - - ["R SSC[1-2] C +BLE:OK"] - - *set_default_ble_name - - *set_default_adv_data - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 3 -c 0" - - ["R SSC2 P "] - diff --git a/components/idf_test/integration_test/TC_IT_BLUEDROID_GATT.yml b/components/idf_test/integration_test/TC_IT_BLUEDROID_GATT.yml deleted file mode 100644 index 8e7e75d14..000000000 --- a/components/idf_test/integration_test/TC_IT_BLUEDROID_GATT.yml +++ /dev/null @@ -1,1209 +0,0 @@ -.GATT_CASE: &GATT_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_CONN2 - test environment: SSC_T2_5 - execution time: 0 - module: BLUEDROID - sub module: GATT - version: v1 (2016-12-31) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.primary_service_discovery: &primary_service_discovery - LIST_MERGE: - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - -.included_service_connection: &included_primary_service_connection - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA0" - - ["R SSC2 C +GATTS:AddIncludedService,OK"] - - - "SSC SSC2 gatts -S -z add -p 0xA1" - - ["R SSC2 C +GATTS:StartService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.included_second_service_connection: &included_second_service_connection - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA4" - - ["R SSC2 C +GATTS:StartService,OK,A004"] - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - "SSC SSC1 gatts -S -z add -p 0xA1" - - ["R SSC1 C +GATTS:StartService,OK,A001"] - - - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA4" - - ["R SSC2 C +GATTS:AddIncludedService,OK"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.table_include_table_service: &table_include_table_service - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA5 -i 0xA2" - - ["R SSC2 C +GATTS:StartService,OK,A005"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.table_include_service: &table_include_service - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA5 -i 0xA0" - - ["R SSC2 C +GATTS:StartService,OK,A005"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.register_notify_c107: ®ister_notify_c107 - LIST_MERGE: - - - "SSC SSC1 gattc -N -z register -s 0xA000 -c 0xC107 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A000,C107"] - -.register_indicate_c108: ®ister_indicate_c108 - LIST_MERGE: - - - "SSC SSC1 gattc -N -z register -s 0xA000 -c 0xC108 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A000,C108"] - -.stop_adv: &stop_adv - LIST_MERGE: - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:Stop"] - -test cases: -- ID: BLUEDROID_GATT_01001 - <<: *GATT_CASE - test point 2: BLE GATT server create service - summary: create service, add char and descriptor and start service for BLUEDOID - steps: | - 1. create preset service 0xA000 - expected result: | - 1. succeed - initial condition: BLE_INIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ["R SSC1 C +GATTS:StartService,OK,A000"] -- ID: BLUEDROID_GATT_01002 - <<: *GATT_CASE - test point 2: BLE GATT server create service - summary: create service and include another service for BLUEDROID - steps: | - 1. create preset service 0xA000 - 2. create preset service 0xA001 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_INIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 gatts -S -z load -p 0xA0" - - ["R SSC1 C +GATTS:StartService,OK,A000"] - - - "SSC SSC1 gatts -S -z load -p 0xA1" - - ["R SSC1 C +GATTS:CreateService,OK,A001"] - - - "SSC SSC1 gatts -S -z add -p 0xA1" - - ["R SSC1 C +GATTS:StartService,OK,A001"] -- ID: BLUEDROID_GATT_20001 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client discover manual primary service for BLUEDOID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. found service 0xA000 and 0xA001 - initial condition: BLE_INIT2 - cmd set: - - "" - - *included_primary_service_connection - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A000 C +GATTC:DiscoverService,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] -- ID: BLUEDROID_GATT_20002 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client get manual included service for BLUEDOID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - 5. DUT1 get included service 0xA000 from service 0xA001 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. get included service 0xA000 from service 0xA001 - initial condition: BLE_INIT2 - cmd set: - - "" - - *included_primary_service_connection - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A000 A :GATTC:DiscoverService,A001,(\\d+-\\d+)"] - - - "SSC SSC1 gattc -D -z includedService -p 0x10 -s 0xA001 -i 0xA000 -q -k 1" - - ["R SSC1 C +GATTC:IncludedService,0010,A001,A000"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] -- ID: BLUEDROID_GATT_20003 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client discover table primary service (table service include table service) for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA002 - 2. DUT2 create preset service 0xA005 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. found service 0xA002 and 0xA005 - initial condition: BLE_INIT3 - cmd set: - - "" - - *table_include_table_service - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A002 C +GATTC:DiscoverService,A005"] -- ID: BLUEDROID_GATT_20004 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client get table included service for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA002 - 2. DUT2 create preset service 0xA005 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - 5. DUT1 get included service 0xA002 from service 0xA005 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. get included service 0xA002 from service 0xA005 - initial condition: BLE_INIT3 - cmd set: - - "" - - *table_include_table_service - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A002 A :GATTC:DiscoverService,A005,(\\d+-\\d+)"] - - - "SSC SSC1 gattc -D -z includedService -p 0x10 -s 0xA005 -i 0xA002 -q -k 1" - - ["R SSC1 C +GATTC:IncludedService,0010,A005,A002"] -- ID: BLUEDROID_GATT_20005 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client discover table primary service (table service include manual service) for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA005 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. found service 0xA000 and 0xA005 - initial condition: BLE_INIT2 - cmd set: - - "" - - *table_include_service - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A000 C +GATTC:DiscoverService,A005"] -- ID: BLUEDROID_GATT_20006 - <<: *GATT_CASE - test point 2: BLE GATT client service / char discovery - summary: GATT client get table included manual service for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA005 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - 5. DUT1 get included service 0xA000 from service 0xA005 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. get included service 0xA000 from service 0xA005 - initial condition: BLE_INIT2 - cmd set: - - "" - - *table_include_service - - - "SSC SSC1 gattc -D -z primaryService -p 0x10" - - ["R SSC1 C +GATTC:DiscoverService,A000 A :GATTC:DiscoverService,A005,(\\d+-\\d+)"] - - - "SSC SSC1 gattc -D -z includedService -p 0x10 -s 0xA005 -i 0xA000 -q -k 1" - - ["R SSC1 C +GATTC:IncludedService,0010,A005,A000"] -- ID: BLUEDROID_GATT_21001 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read short char for BLUEDROID - steps: | - 1. DUT1 do discover - 2. GATT client read 1 byte short char - expected result: | - 1. succeed - 2. read succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC100 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,1", "R SSC1 C +GATTC:Read,OK,0010,A000,C100"] -- ID: BLUEDROID_GATT_21002 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read long char for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 GATT client read 256 bytes long char - expected result: | - 1. succeed - 2. read succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC101 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C101,256", "R SSC1 C +GATTC:Read,OK,0010,A000,C101"] -- ID: BLUEDROID_GATT_21003 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read short descriptor for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client read short descriptor - expected result: | - 1. succeed - 2. read succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C107,2902,2", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A000,C107,2902"] -- ID: BLUEDROID_GATT_21004 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read long descriptor for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client read long descriptor - expected result: | - 1. succeed - 2. read succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC100 -d 0x2901 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,2901,2", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A000,C100,2901"] -- ID: BLUEDROID_GATT_21005 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read short char of an included service for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do discover - 5. GATT client read 1 byte short char - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - initial condition: BLE_INIT2 - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC100 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,1", "R SSC1 C +GATTC:Read,OK,0010,A000,C100"] -- ID: BLUEDROID_GATT_21006 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read short descriptor or an included service for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do discover - 5. GATT client read 1 byte short descriptor - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - initial condition: BLE_INIT2 - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C107,2902,2", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A000,C107,2902"] -- ID: BLUEDROID_GATT_22001 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write with response to a short char with response for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client write with response to short char with response - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC102 -p 0x10 -v 0x01" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C102", "R SSC1 C +GATTC:Write,OK,0010,A000,C102"] -- ID: BLUEDROID_GATT_22002 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write without response to a short char without response for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client write without response to short char without response - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC103 -p 0x10 -v 0x01 -w 1" - - - "P SSC1 C +GATTC:WriteOnce,0010,A000,C103" - - "P SSC2 C +GATTS:Write,OK,A000,C103" - - "P SSC1 C +GATTC:Write,OK,0010,A000,C103" -- ID: BLUEDROID_GATT_22003 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do execute for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do execute - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA000 -c 0xC110 -p 0x10 -l 256" - - ["P SSC1 C +GATTC:Write,OK,0010,A000,C110"] -- ID: BLUEDROID_GATT_22004 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do cancel for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do cancel - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA000 -c 0xC110 -p 0x10 -l 256 -e 0" - - ["P SSC1 C +GATTC:Write,OK,0010,A000,C110"] - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC110 -p 0x10 -l 256 -e 0" - - ["P SSC1 C +GATTC:Write,OK,0010,A000,C110"] -- ID: BLUEDROID_GATT_22005 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to a short descriptor for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client write to short descriptor - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] -- ID: BLUEDROID_GATT_22006 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to long descriptor and execute for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client write to long descriptor and execute - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA000 -c 0xC100 -d 0x2901 -p 0x10 -l 256" - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C100,2901"] -- ID: BLUEDROID_GATT_22007 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to long descriptor using write API for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. GATT client write to long descriptor and execute - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC100 -d 0x2901 -p 0x10 -l 256" - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C100,2901"] -- ID: BLUEDROID_GATT_22008 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to an included char for BLUEDROID - allow fail: 1/2 - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do discover - 5. GATT client write with response to short char with response - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - initial condition: BLE_INIT2 - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC102 -p 0x10 -v 0x01" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C102", "R SSC1 C +GATTC:Write,OK,0010,A000,C102"] -- ID: BLUEDROID_GATT_22009 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to an included descriptor for BLUEDROID - steps: | - 1. DUT2 create preset service 0xA000 - 2. DUT2 create preset service 0xA001 - 3. DUT1 connect to DUT2 - 4. DUT1 do discover - 5. GATT client write to short descriptor - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - initial condition: BLE_INIT2 - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] -- ID: BLUEDROID_GATT_23001 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client register/unregister notify for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on notification char - 3. DUT1 register notify on indication char - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - *primary_service_discovery - - *register_notify_c107 - - *register_indicate_c108 - - - "SSC SSC1 gattc -N -z unregister -s 0xA000 -c 0xC107 -p 0x10 -r " - - ["R SSC1 C +GATTC:UnRegNotify,OK,0010,A000,C107"] - - - "SSC SSC1 gattc -N -z unregister -s 0xA000 -c 0xC108 -p 0x10 -r " - - ["R SSC1 C +GATTC:UnRegNotify,OK,0010,A000,C108"] -- ID: BLUEDROID_GATT_23002 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive notify for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on notification char and write to CCC - 3. DUT2 do notify - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv notify - cmd set: - - "" - - *primary_service_discovery - - *register_notify_c107 - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - - "SSC SSC2 gatts -N -c 0xC107 -p 0xA0 -v 0x01 -r " - - ["R SSC1 C +GATTC:Notification,0010,A000,C107,1"] -- ID: BLUEDROID_GATT_23003 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive indication for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on inidcation char and write to CCC - 3. DUT2 do indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv indication - cmd set: - - "" - - *primary_service_discovery - - *register_indicate_c108 - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC108 -d 0x2902 -p 0x10 -v 0x0002" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C108,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C108,2902"] - - - "SSC SSC2 gatts -I -c 0xC108 -p 0xA0 -v 0x01 -r " - - ["R SSC1 C +GATTC:Indication,0010,A000,C108,1"] -- ID: BLUEDROID_GATT_23004 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client can't receive notification/indication without write to CCC (manual service) for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on notify and inidcation char - 3. DUT2 do notify and indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 can recv notify and indication (this is aganist Spec, but a reasonable behavior in bluedroid) - cmd set: - - "" - - *primary_service_discovery - - *register_notify_c107 - - *register_indicate_c108 - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0000" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - - "SSC SSC2 gatts -N -c 0xC107 -p 0xA0 -v 0x01 -r " - - ["P SSC1 C +GATTC:Notification,0010,A000,C107,1"] - - - "SSC SSC2 gatts -I -c 0xC108 -p 0xA0 -v 0x01 -r " - - ["P SSC1 C +GATTC:Indication,0010,A000,C108,1"] -- ID: BLUEDROID_GATT_24001 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid read - summary: GATT client read to a char without read property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 read to a char without read property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC103 -p 0x10" - - ["P SSC1 C +GATTC:Read,ERROR"] -- ID: BLUEDROID_GATT_24002 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid read - summary: GATT client read to a descriptor without read property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 read to a descriptor without read property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC102 -d 0x2901 -p 0x10" - - ["P SSC1 C +GATTC:Read,ERROR"] -- ID: BLUEDROID_GATT_25001 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write with response to a char without write property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 write with response to a char without write property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC100 -p 0x10 -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_25002 - <<: *GATT_CASE - test point 1: basic function - test point 2: BLE GATT client do invalid write - summary: GATT client write without response to a char without write property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 write without response to a char without write property - expected result: | - 1. succeed - 2. succeed (write without response always succeed) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC100 -p 0x10 -l 1 -w 1" - - ["R SSC1 C +GATTC:Write,OK"] -- ID: BLUEDROID_GATT_25003 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write to a descriptor without write property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 write to a descriptor without write property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC101 -d 0x2901 -p 0x10 -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_25004 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client prepare write to a char without write property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 prepare write to a char without write property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA000 -c 0xC100 -p 0x10 -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_25005 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client prepare write to a descriptor without write property for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 prepare write to a descriptor without write property - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA000 -c 0xC101 -d 0x2901 -p 0x10 -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_25006 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write with response to a char not send response for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 write with response to a char not send response - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC103 -p 0x10 -v 0x01" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_25007 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write without response to a char will send response for BLUEDROID - steps: | - 1. DUT1 do service discovery - 2. DUT1 write without response to a char will send response - expected result: | - 1. succeed - 2. succeed (write without response always succeed) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC102 -p 0x10 -v 0x01 -w 1" - - ["P SSC1 C +GATTC:WriteOnce"] -- ID: BLUEDROID_GATT_25013 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write with response to a char created by table not send response - steps: | - 1. DUT1 do service discovery - 2. DUT1 write with response to auto reply char created by table not send response - 3. DUT1 write with response to app reply char created by table not send response - expected result: | - 1. succeed - 2. succeed(BLE Spec do not define the behavior of this case. IDF implementation will return success when GATTC write with response and recv response from remote side) - 3. failed - initial condition: BLE_CONN3 - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC303 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:Write,OK,0010,A002,C303"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC313 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BLUEDROID_GATT_26001 - <<: *GATT_CASE - test point 2: BLE GATT client set mtu - summary: GATT client config different mtu size for BLUEDOID - steps: | - 1. set mtu size 22 - 2. set mtu size 23 - 3. set mtu size 517 - 4. set mtu size 518 - expected result: | - 1. failed - 2. succeed - 3. succeed - 4. failed - cmd set: - - "" - - - "SSC SSC1 bleconn -D -z all" - - ["P SSC1 C +BLECONN:GapDisconnect,OK", "P SSC2 C +BLECONN:GapDisconnect,OK"] - - - "SSC SSC1 gattc -S -m 22 " - - ["R SSC1 C +GATTC:ERROR"] - - - "SSC SSC1 gattc -S -m 23" - - ["R SSC1 C +GATTC:OK"] - - - "SSC SSC1 gattc -S -m 517" - - ["R SSC1 C +GATTC:OK"] - - - "SSC SSC1 gattc -S -m 518" - - ["R SSC1 C +GATTC:ERROR"] -- ID: BLUEDROID_GATT_26002 - <<: *GATT_CASE - test point 2: BLE GATT server set mtu - summary: GATT server config different mtu size for BLUEDOID - steps: | - 1. set mtu size 22 - 2. set mtu size 23 - 3. set mtu size 517 - 4. set mtu size 518 - expected result: | - 1. failed - 2. succeed - 3. succeed - 4. failed - cmd set: - - "" - - - "SSC SSC1 bleconn -D -z all" - - ["P SSC1 C +BLECONN:GapDisconnect,OK", "P SSC2 C +BLECONN:GapDisconnect,OK"] - - - "SSC SSC2 gatts -C -m 22" - - ["R SSC2 C +GATTS:ERROR"] - - - "SSC SSC2 gatts -C -m 23" - - ["R SSC2 C +GATTS:OK"] - - - "SSC SSC2 gatts -C -m 517" - - ["R SSC2 C +GATTS:OK"] - - - "SSC SSC2 gatts -C -m 518" - - ["R SSC2 C +GATTS:ERROR"] -- ID: BLUEDROID_GATT_26004 - <<: *GATT_CASE - test point 2: BLE GATT client config mtu - summary: GATT read write on mtu size 261 - allow fail: 1/2 - steps: | - 1. config mtu size 261 - 2. do read - 3. do write - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -D -p 0x10" - - ["P SSC1 C +BLECONN:GapDisconnect,OK", "P SSC2 C +BLECONN:GapDisconnect,OK"] - - - "SSC SSC1 gattc -S -m 261" - - ["R SSC1 C +GATTC:OK"] - - - "SSC SSC2 gatts -C -m 261" - - ["R SSC2 C +GATTS:OK"] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC1 gattc -C" - - ["R SSC1 C +GATTC:OK","P SSC[1-2] C ConfigMTU,OK,261"] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -p 0x10 -s 0xA000 -c 0xC101" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C101,256"] - - - "SSC SSC1 gattc -W -z char -p 0x10 -s 0xA000 -c 0xC109 -l 256" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C109"] - - - "SSC SSC1 gattc -W -z longChar -p 0x10 -s 0xA000 -c 0xC110 -l 512" - - ["R SSC1 C +GATTC:Write,OK,0010,A000,C110", "P SSC2 C +GATTS:ReliableWrite,OK"] -- ID: BLUEDROID_GATT_26005 - <<: *GATT_CASE - test point 2: BLE GATT client config mtu - summary: GATT read write on mtu size 517 for BLUEDOID - allow fail: 1/2 - steps: | - 1. config mtu size 517 - 2. do read - 3. do write - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -D -z all" - - ["P SSC1 C +BLECONN:GapDisconnect,OK", "P SSC2 C +BLECONN:GapDisconnect,OK"] - - - "SSC SSC1 gattc -S -m 517" - - ["R SSC1 C +GATTC:OK"] - - - "SSC SSC2 gatts -C -m 517" - - ["R SSC2 C +GATTS:OK"] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 gattc -C -r " - - ["P SSC1 C +GATTC:OK", "P SSC[1-2] C ConfigMTU,OK,517"] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -p 0x10 -s 0xA000 -c 0xC101" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C101,256"] - - - "SSC SSC1 gattc -W -z char -p 0x10 -s 0xA000 -c 0xC109 -l 256" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C109"] - - - "SSC SSC1 gattc -W -z char -p 0x10 -s 0xA000 -c 0xC109 -l 512" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C109"] -- ID: BLUEDROID_GATT_27001 - <<: *GATT_CASE - test point 2: BLE GATT read multiple - summary: GATT client read 2 char and 11 char of same service for BLUEDROID - steps: | - 1. DUT1 do discover - 2. GATT client read 2 char - 3. GATT client read 11 char - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z multiple -u #0xC100##0xC101# -s 0xA000 -r " - - ['R SSC1 C +GATTC:ReadOnce,22', 'R SSC1 C +GATTC:ReadMultiple,OK'] - - - "SSC SSC1 gattc -R -z multiple -u #0xC100##0xC101##0xC107##0xC108##0xC109##0xC110##0xC100##0xC101##0xC107##0xC108##0xC109# -s 0xA000" - - ['R SSC1 C +GATTC:Read,ERROR'] -- ID: BLUEDROID_GATT_27002 - <<: *GATT_CASE - test point 2: BLE GATT read multiple - summary: GATT client read char and descriptor for BLUEDROID - steps: | - 1. DUT1 do discover - 2. GATT client read all char and descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z multiple -u 0xA00xC100#0xA00xC101#0xA00xC1000x29010xA00xC1070x2902 -r " - - ['R SSC1 C +GATTC:ReadOnce', 'R SSC1 C +GATTC:ReadMultiple,OK'] -- ID: BLUEDROID_GATT_27003 - <<: *GATT_CASE - test point 2: BLE GATT read multiple - summary: GATT client read char and descriptor of table create service for BLUEDROID - steps: | - 1. DUT1 do discover - 2. GATT client read all char and descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA2" - - ['R SSC2 C +GATTS:StartService,OK,A002'] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z multiple -u 0xA20xC300#0xA20xC301#0xA20xC310#0xA20xC311# -r " - - ['R SSC1 C +GATTC:ReadOnce', 'R SSC1 C +GATTC:ReadMultiple,OK'] -- ID: BLUEDROID_GATT_27004 - <<: *GATT_CASE - test point 2: BLE GATT read multiple - summary: GATT client read char and descriptor of included service and table service for BLUEDROID - initial condition: BLE_INIT2 - steps: | - 1. DUT2 load service included service and table service - 2. DUT1 search service - 3. GATT client read all char and descriptor of different services - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC2 gatts -S -z load -p 0xA2" - - ['R SSC2 C +GATTS:StartService,OK,A002'] - - *included_primary_service_connection - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z multiple -u 0xA10xC200#0xA00xC100#0xA00xC101#0xA20xC300#0xA20xC301#" - - ['R SSC1 C +GATTC:ReadOnce', 'R SSC1 C +GATTC:ReadMultiple,OK'] -- ID: BLUEDROID_GATT_30004 - <<: *GATT_CASE - test point 2: BLE GATT multi connection service discovery test - summary: do primary service discovery when master and slave both create GATTC and GATTS for BLUEDOID - steps: | - 1. DUT1 do primary service discovery for DUT2 - 2. DUT2 do primary service discovery for DUT1 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN4 - cmd set: - - "" - - - "SSC SSC2 bleconn -C -p 0x10 -a " - - ["R SSC2 C +BLE:GattcOpen,OK"] - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC2 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC2 C +GATTC:Discover,OK"] -- ID: BLUEDROID_GATT_31004 - <<: *GATT_CASE - test point 2: BLE GATT multi connection read test - summary: do read when master and slave both create GATTC and GATTS for BLUEDOID - steps: | - 1. DUT1 do primary service discovery for DUT2 - 2. DUT2 do primary service discovery for DUT1 - 3. DUT1 do read on DUT2 - 4. DUT2 do read on DUT1 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_CONN4 - cmd set: - - "" - - - "SSC SSC2 bleconn -C -p 0x10 -a " - - ["R SSC2 C +BLE:GattcOpen,OK"] - - - "SSC SSC[1-2] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Discover,OK"] - - - "SSC SSC[1-2] gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:ReadOnce,0010,A002,C300,1"] - - - "SSC SSC[1-2] gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:ReadOnce,0010,A002,C301,256"] -- ID: BLUEDROID_GATT_32004 - <<: *GATT_CASE - test point 2: BLE GATT multi connection write test - summary: do write when master and slave both create GATTC and GATTS for BLUEDOID - steps: | - 1. DUT1 do primary service discovery for DUT2 - 2. DUT2 do primary service discovery for DUT1 - 3. DUT1 do write on DUT2 - 4. DUT2 do write on DUT1 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_CONN4 - cmd set: - - "" - - - "SSC SSC2 bleconn -C -p 0x10 -a " - - ["R SSC2 C +BLE:GattcOpen,OK"] - - - "SSC SSC[1-2] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Discover,OK"] - - - "SSC SSC[1-2] -W -z char -s 0xA002 -c 0xC302 -l 1 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC[1-2] -W -z char -s 0xA002 -c 0xC304 -l 256 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Write,OK,0010,A002,C304"] -- ID: BLUEDROID_GATT_33004 - <<: *GATT_CASE - test point 2: BLE GATT multi connection notify test - summary: do notify when master and slave both create GATTC and GATTS for BLUEDOID - steps: | - 1. DUT1 do primary service discovery for DUT2 - 2. DUT2 do primary service discovery for DUT1 - 3. DUT[1-2] do register notify - 4. DUT1 and DUT2 send notify to each other - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. receive notification - initial condition: BLE_CONN4 - cmd set: - - "" - - - "SSC SSC2 bleconn -C -p 0x10 -a " - - ["R SSC2 C +BLE:GattcOpen,OK"] - - - "SSC SSC[1-2] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Discover,OK"] - - - "SSC SSC[1-2] gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:RegNotify,OK,0010,A002,C305"] - - - "SSC SSC[1-2] gatts -N -c 0xC305 -l 1 -p 0xA2 -r " - - ['P SSC[1,2] RE "\+GATTC:Notification,0010,A002,C305,1,%%s"%%()'] -- ID: BLUEDROID_GATT_34004 - <<: *GATT_CASE - test point 2: BLE GATT multi connection indicate test - summary: do indicate when master and slave both create GATTC and GATTS for BLUEDOID - steps: | - 1. DUT1 do primary service discovery for DUT2 - 2. DUT2 do primary service discovery for DUT1 - 3. DUT[1-2] do register indication - 4. DUT1 and DUT2 send notify to each other - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. receive indication - initial condition: BLE_CONN4 - cmd set: - - "" - - - "SSC SSC2 bleconn -C -p 0x10 -a " - - ["R SSC2 C +BLE:GattcOpen,OK"] - - - "SSC SSC[1-2] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:Discover,OK"] - - - "SSC SSC[1-2] gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC[1-2] C +GATTC:RegNotify,OK,0010,A002,C306"] - - - "SSC SSC[1-2] gatts -I -c 0xC306 -l 1 -p 0xA2 -r " - - ['P SSC[1,2] RE "\+GATTC:Indication,0010,A002,C306,1,%%s"%%()'] -- ID: BLUEDROID_GATT_40001 - <<: *GATT_CASE - auto test: 'No' - test point 2: test if BLE work after switch off some sub modules - summary: GATTC only and GATTS only test for BLUEDROID - steps: | - 1. download GATTC only bin to DUT1 and GATTS only bin to DUT2 - 2. DUT2 start adv, enable service 0xA000, DUT1 connect to DUT2 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - 5. DUT1 do read - 6. DUT1 do read descriptor - 7. DUT1 do write - 8. DUT1 do write descriptor - 9. DUT1 register for notify and indication - 10. DUT2 do notify - 11. DUT2 do indicate - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - 9. succeed - 10. succeed - 11. succeed - initial condition: None - execution time: 5 - CI ready: 'No' - cmd set: - - "" - - - SSC SSC[1-2] reboot - - ['R SSC[1-2] C !!!ready!!!'] - - - SSC SSC[1-2] ble -R - - ['R SSC[1-2] C +BLE:OK'] - - - SSC SSC2 bleadv -D -z start - - ['R SSC2 C +BLEADV:OK'] - - - SSC SSC2 gatts -S -z load -p 0xA0 - - ['R SSC2 C +GATTS:StartService,OK,A000'] - - - SSC SSC1 bleconn -C -p 0x10 -a - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC100 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,1", "R SSC1 C +GATTC:Read,OK,0010,A000,C100"] - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC102 -p 0x10 -v 0x01" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C102", "R SSC1 C +GATTC:Write,OK,0010,A000,C102"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC100 -d 0x2901 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,2901,256", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A000,C100,2901"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - *register_notify_c107 - - *register_indicate_c108 - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0300 -n 1" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - - "SSC SSC2 gatts -N -c 0xC107 -p 0xA0 -v 0x01" - - ["P SSC2 C +GATTS:Done,Notify,A000,C107", "P SSC1 C +GATTC:Notification,0010,A000,C107,1"] - - - "SSC SSC2 gatts -I -c 0xC108 -p 0xA0 -v 0x01" - - ["P SSC2 C +GATTS:Done,Indicate,A000,C108", "P SSC1 C +GATTC:Indication,0010,A000,C108,1"] -- ID: BLUEDROID_GATT_40002 - <<: *GATT_CASE - auto test: 'No' - test point 2: test if BLE work after switch off some sub modules - summary: GATTC_SMP only and GATTS_SMP only test for BLUEDROID - steps: | - 1. download GATTC_SMP bin to DUT1 and GATTS_SMP bin to DUT2 - 2. DUT2 start adv, start service 0xA000, DUT1 connect to DUT2 - 3. DUT1 connect to DUT2 - 4. DUT1 do primary service discovery - 5. DUT1 do read - 6. DUT1 do read descriptor - 7. DUT1 do write - 8. DUT1 do write descriptor - 9. DUT1 register for notify and indication - 10. DUT2 do notify - 11. DUT2 do indicate - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - 9. succeed - 10. succeed - 11. succeed - initial condition: None - execution time: 5 - CI ready: 'No' - cmd set: - - "" - - - SSC SSC[1-2] reboot - - ['R SSC[1-2] C !!!ready!!!'] - - - SSC SSC[1-2] ble -R - - ['R SSC[1-2] C +BLE:OK'] - - - SSC SSC2 bleadv -D -z start - - ['R SSC2 C +BLEADV:OK'] - - - SSC SSC2 gatts -S -z load -p 0xA0 - - ['R SSC2 C +GATTS:StartService,OK,A000'] - - - SSC SSC1 bleconn -C -p 0x10 -a - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect'] - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA000 -c 0xC100 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,1", "R SSC1 C +GATTC:Read,OK,0010,A000,C100"] - - - "SSC SSC1 gattc -W -z char -s 0xA000 -c 0xC102 -p 0x10 -v 0x01" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C102", "R SSC1 C +GATTC:Write,OK,0010,A000,C102"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA000 -c 0xC100 -d 0x2901 -p 0x10" - - ["R SSC1 C +GATTC:ReadOnce,0010,A000,C100,2901,256", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A000,C100,2901"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - *register_notify_c107 - - *register_indicate_c108 - - - "SSC SSC1 gattc -W -z descriptor -s 0xA000 -c 0xC107 -d 0x2902 -p 0x10 -v 0x0300 -n 1" - - ["R SSC1 C +GATTC:WriteOnce,0010,A000,C107,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A000,C107,2902"] - - - "SSC SSC2 gatts -N -c 0xC107 -p 0xA0 -v 0x01" - - ["P SSC2 C +GATTS:Done,Notify,A000,C107", "P SSC1 C +GATTC:Notification,0010,A000,C107,1"] - - - "SSC SSC2 gatts -I -c 0xC108 -p 0xA0 -v 0x01" - - ["P SSC2 C +GATTS:Done,Indicate,A000,C108", "P SSC1 C +GATTC:Indication,0010,A000,C108,1"] \ No newline at end of file diff --git a/components/idf_test/integration_test/TC_IT_BLUEDROID_SMP.yml b/components/idf_test/integration_test/TC_IT_BLUEDROID_SMP.yml deleted file mode 100644 index 2bca97e2d..000000000 --- a/components/idf_test/integration_test/TC_IT_BLUEDROID_SMP.yml +++ /dev/null @@ -1,606 +0,0 @@ -.SMP_CASE: &SMP_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_INIT_SMP - test environment: SSC_T2_5 - execution time: 0 - module: BLUEDROID - sub module: SMP - version: v1 (2017-05-26) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.just_work_pair: &just_work_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.slave_passkey_entry_pair: &slave_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.master_passkey_entry_pair: &master_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:PassKeyReq', 'P SSC2 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC1 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.both_side_passkey_entry_pair: &both_side_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1,2] C +BLESMP:PassKeyReq'] - - - "SSC SSC[1,2] blesmp -K -r -a 1 -k 123456" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.numberic_comparision_pair: &numberic_comparision_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1-2] blesmp -C -r -a 1" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.check_connection: &check_connection - LIST_MERGE: - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - -.disconnect: &disconnect - LIST_MERGE: - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['P SSC2 C +BLEADV:OK'] - -.connect: &connect - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - -.config_just_work: &config_just_work - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_master_passkey_entry: &config_master_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - -.config_slave_passkey_entry: &config_slave_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_both_side_passkey_entry: &config_both_side_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_numberic_comparision: &config_numberic_comparision - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_bond_device: &config_bond_device - LIST_MERGE: - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - -test cases: -- ID: BLUEDROID_SMP_04001 - <<: *SMP_CASE - test point 2: BLE SMP key test - summary: BLE SMP set key size less than required for BLUEDROID - allow fail: 1/2 - steps: | - 1. set key size 7 - 2. set key size 6 - 3. do just work pair - expected result: | - 1. succeed - 2. LTK size is 7 - 3. succeed - cmd set: - - "" - - *config_numberic_comparision - - - "SSC SSC1 blesmp -S -z KeySize -v 0x07" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z KeySize -v 0x06" - - ['P SSC1 C +BLESMP:OK'] - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1-2] blesmp -C -r -a 1" - - ['P SSC[1-2] C +BLESMP:Key,LocalLTK,16 C +BLESMP:AuthComplete,Success,0'] -- ID: BLUEDROID_SMP_04002 - <<: *SMP_CASE - test point 2: BLE SMP key test - summary: BLE SMP set key size greater than required for BLUEDROID - allow fail: 1/2 - steps: | - 1. set key size 16 - 2. set key size 17 - 3. do just work pair - expected result: | - 1. succeed - 2. LTK size is 17 - 3. succeed - cmd set: - - "" - - *config_numberic_comparision - - - "SSC SSC1 blesmp -S -z KeySize -v 0x10" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z KeySize -v 0x11" - - ['P SSC1 C +BLESMP:OK'] - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1-2] blesmp -C -r -a 1" - - ['P SSC[1-2] C +BLESMP:Key,LocalLTK,16 C +BLESMP:AuthComplete,Success,0'] -- ID: BLUEDROID_SMP_05001 - <<: *SMP_CASE - test point 2: BLE SMP unsuccessful pair reply test - summary: BLE SMP unsuccessful passkey entry test for BLUEDROID - steps: | - 1. enter passkey entry phase - 2. entry incorrect passkey and accept - 3. enter passkey entry phase - 4. entry correct passkey and reject - 5. enter passkey entry phase - 6. send numberic comparision accept - 7. enter passkey entry phase - 8. send numberic comparision reject - expected result: | - 1. succeed - 2. pair failed - 3. succeed - 4. pair failed - 5. succeed - 6. pair failed - 7. succeed - 8. pair failed - cmd set: - - "" - - *config_slave_passkey_entry - - - LOOP 2 5 "[1,0]" "['000001','']" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 blesmp -K -r -a {%d} -k {%s}" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect - - - LOOP 2 5 "[1,0]" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC[1-2] blesmp -C -r -a {%d}" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect -- ID: BLUEDROID_SMP_05002 - <<: *SMP_CASE - test point 2: BLE SMP unsuccessful pair reply test - summary: BLE SMP unsuccessful numberic comparision test for BLUEDROID - steps: | - 1. enter numberic comparision phase - 2. entry passkey and accept - 3. enter numberic comparision phase - 4. send numberic comparision reject - expected result: | - 1. succeed - 2. pair failed - 3. succeed - 4. pair failed - cmd set: - - "" - - *config_numberic_comparision - - - LOOP 2 6 "[1,0]" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC2 blesmp -K -r -a {%d} -k 000001" - - [] - - - DELAY 10 - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect - - - LOOP 2 5 "[1,0]" "[0,1]" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1,2] blesmp -C -r -a [{%d},{%d}]" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect -- ID: BLUEDROID_SMP_06001 - <<: *SMP_CASE - test environment: SSC_T1_4 - initial condition: BLE_DEINIT1 - test point 2: BLE SMP use API in abnormal state - summary: BLE SMP use API when BLE not initialized, not enabled or not registered callback for BLUEDROID - steps: | - 1. set security parameter - 2. send security response - 3. send passkey reply - 4. send confirm reply - 5. init BLE - 6. set security parameter - 7. send security response - 8. send passkey reply - 9. send confirm reply - 10. init BLE - 11. set security parameter - 12. send security response - 13. send passkey reply - 14. send confirm reply - expected result: | - 1. failed - 2. failed - 3. failed - 4. failed - 5. succeed - 6. failed - 7. failed - 8. failed - 9. failed - 10. succeed - 11. failed - 12. failed - 13. failed - 14. failed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP:ERROR'] - - - "SSC SSC1 blesmp -R -a 1 -r " - - ['P SSC1 C +BLESMP:ERROR'] - - - "SSC SSC1 blesmp -K -r -a 1 -k 123456" - - ['P SSC1 C +BLESMP:ERROR'] - - - "SSC SSC1 blesmp -C -r -a 1" - - ['P SSC1 C +BLESMP:ERROR'] - - - SSC SSC1 bt -D -z init - - ['R SSC1 C +BT:'] - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -R -a 1 -r " - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -K -r -a 1 -k 123456" - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -C -r -a 1" - - ['P SSC1 C +BLESMP'] - - - SSC SSC1 bt -D -z enable - - ['R SSC1 C +BT:'] - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -R -a 1 -r " - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -K -r -a 1 -k 123456" - - ['P SSC1 C +BLESMP'] - - - "SSC SSC1 blesmp -C -r -a 1" - - ['P SSC1 C +BLESMP'] -- ID: BLUEDROID_SMP_07002 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP just work pairing and reboot for BLUEDROID - steps: | - 1. DUT1 and DUT2 SMP with just work pair - 2. DUT1 reboot - 3. DUT1 connect to DUT2 - 4. DUT2 send auth request - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. failed - cmd set: - - "" - - *config_just_work - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 reboot" - - ['P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC1 ble -R" - - ['R SSC1 C +BLE:'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - *slave_passkey_entry_pair -- ID: BLUEDROID_SMP_07005 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP initiator with master passkey entry and reconnect for BLUEDROID - steps: | - 1. DUT1 and DUT2 SMP with master passkey entry - 2. DUT1 disconnect - 3. DUT1 connect to DUT2 - 4. DUT2 send auth request - expected result: | - 1. succeed - 2. succeed - 3. connect succeed - 4. succeed - cmd set: - - "" - - *config_master_passkey_entry - - *master_passkey_entry_pair - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] -- ID: BLUEDROID_SMP_07006 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP initiator with master passkey entry and reboot for BLUEDROID - steps: | - 1. DUT1 and DUT2 SMP bond with lagecy pairing - 2. DUT1 reboot - 3. DUT1 connect to DUT2 - 4. DUT2 send auth requst - expected result: | - 1. succeed - 2. succeed - 3. connect succeed - 4. fail - cmd set: - - "" - - *config_master_passkey_entry - - *master_passkey_entry_pair - - - "SSC SSC1 reboot" - - ['P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC1 ble -R" - - ['R SSC1 C +BLE:'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - *numberic_comparision_pair -- ID: BLUEDROID_SMP_07007 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP initiator numberic comparision and reconnect for BLUEDROID - steps: | - 1. DUT1 and DUT2 SMP with numberic comparision - 2. DUT1 disconnect - 3. DUT1 connect to DUT2 - 4. DUT2 send auth requst - expected result: | - 1. succeed - 2. succeed - 3. connect succeed - 4. succeed - cmd set: - - "" - - *config_numberic_comparision - - *numberic_comparision_pair - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] -- ID: BLUEDROID_SMP_07008 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP initiator numberic comparision and reboot for BLUEDROID - steps: | - 1. DUT1 and DUT2 SMP with numberic comparision - 2. DUT1 disconnect - 3. DUT1 and DUT2 reboot - 4. DUT2 send auth requst - expected result: | - 1. succeed - 2. succeed - 3. connect succeed - 4. failed - cmd set: - - "" - - *config_numberic_comparision - - *numberic_comparision_pair - - - "SSC SSC1 reboot" - - ['P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC1 ble -R" - - ['R SSC1 C +BLE:'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - *numberic_comparision_pair -- ID: BLUEDROID_SMP_08001 - <<: *SMP_CASE - test point 2: BLE SMP bond item management test - summary: BLE SMP get bond list and number without bond device for BLUEDROID - steps: | - 1. DUT1 get bond list - 2. DUT1 get bond number - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -B -z getlist -n 1" - - ['P SSC1 C +BLESMP:GetBondList,OK,0'] - - - "SSC SSC1 blesmp -B -z getnum" - - ['P SSC1 C +BLESMP:GetBondNum,0'] -- ID: BLUEDROID_SMP_08002 - <<: *SMP_CASE - test point 2: BLE SMP bond item management test - summary: BLE SMP remove bond after connected - steps: | - 1. DUT2 set AuthReqMode and RspKey - 2. pairing - 3. remove bond - expected result: | - 1. Succeed - 2. Succeed - 3. Succeed - cmd set: - - "" - - *config_bond_device - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:Start,OK'] - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:AuthComplete,Success,0','P SSC2 C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 blesmp -B -z getnum" - - ['P SSC1 C +BLESMP:GetBondNum,1'] - - - "SSC SSC1 blesmp -B -z remove -r " - - ['P SSC1 RE "\+BLESMP:RemoveBond,Success,%%s"%%()'] -- ID: BLUEDROID_SMP_08003 - <<: *SMP_CASE - test point 2: BLE SMP bond item management test - summary: BLE SMP get bond list and number when pairing and after reboot for BLUEDROID - steps: | - 1. all slaves set AuthReqMode and RspKey - 2. do pairing - 3. master and slave get bond list and num - 4. reboot - 5. master and slave get bond list and num - 6. slave remove bond device - expected result: | - 1. Succeed - 2. Succeed - 3. Succeed - 4. succeed - 5. succeed - 6. succeed - test environment: SSC_T5_1 - initial condition: BLE_INIT_SMP5 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC[2-5] C +BLESMP:OK'] - - - "SSC SSC[2-5] blesmp -S -z IOCAP -v 0x03" - - ['P SSC[2-5] C +BLESMP:OK'] - - - "SSC SSC[2-5] blesmp -S -z RspKey -v 0x03" - - ['P SSC[2-5] C +BLESMP:OK'] - - - LOOP 4 4 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC{%d} bleadv -D -z start" - - ['R SSC{%d} C +BLEADV:Start,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC{%d} C +BLECONN:GapConnect'] - - - "SSC SSC{%d} blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:SecReq'] - - - "SSC SSC1 blesmp -R -a 1 -r " - - ['P SSC1 C +BLESMP:AuthComplete,Success,0','P SSC{%d} C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 blesmp -B -z getlist -n 4" - - ['P SSC1 C +BLESMP:GetBondList,OK,4'] - - - "SSC SSC1 blesmp -B -z getnum" - - ['P SSC1 C +BLESMP:GetBondNum,4'] - - - "SSC SSC2 blesmp -B -z getnum" - - ['P SSC2 C +BLESMP:GetBondNum,1'] - - - "SSC SSC[1-2] reboot" - - ['R SSC[1-2] C !!!ready!!!'] - - - "SSC SSC[1-2] ble -R" - - ["R SSC[1-2] C +BLE:OK"] - - - "SSC SSC1 blesmp -B -z getnum" - - ['P SSC1 C +BLESMP:GetBondNum,4'] - - - "SSC SSC2 blesmp -B -z getnum" - - ['P SSC2 C +BLESMP:GetBondNum,1'] - - - "SSC SSC2 blesmp -B -z remove -r " - - ['P SSC2 RE "\+BLESMP:RemoveBond,Success,%%s"%%()'] -- ID: BLUEDROID_SMP_08004 - <<: *SMP_CASE - test point 2: BLE SMP bond item management test - summary: BLE SMP remove bond which not bond for BLUEDROID - steps: | - 1. DUT1 remove bond - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 blesmp -B -z remove -r " - - ['P SSC1 C +BLESMP:RemoveBond,Fail'] -- ID: BLUEDROID_SMP_08005 - <<: *SMP_CASE - test point 2: BLE SMP remove bond - summary: BLE SMP bond 15/16 devices and get list - steps: | - 1. DUT2 set AuthReqMode and RspKey - 2. DUT2 set static random address - 3. DUT1 and DUT2 do pairing - 4. loop step 2 and step3 16 times - 5. get bond list and bond num - 6. DUT2 set static random address - 7. DUT1 and DUT2 do pairing - 8. get bond list and bond num - expected result: | - 1. Succeed - 2. Succeed - 3. Succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x03" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z RspKey -v 0x03" - - ['P SSC[1-2] C +BLESMP:OK'] - - - LOOP 15 7 "range(0,15)" "range(0,15)" "range(0,15)" - - "" - - - "SSC SSC2 bleadv -D -z stop" - - ['R SSC2 C +BLEADV:Stop,OK'] - - - "SSC SSC2 ble -S -z randAddr -a c0:9b:0e:36:6d:7{%x} -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 bleadv -D -z start -o 1" - - ['R SSC2 C +BLEADV:Start,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a c0:9b:0e:36:6d:7{%x} -r 1" - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:SecReq'] - - - "SSC SSC1 blesmp -R -a 1 -r c0:9b:0e:36:6d:7{%x}" - - ['P SSC1 C +BLESMP:AuthComplete,Success,0','P SSC2 C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLE:CLOSE', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC1 blesmp -B -z getlist -n 16" - - ['P SSC1 C +BLESMP:GetBondList,OK,15'] - - - "SSC SSC2 ble -S -z randAddr -a c1:0a:d3:25:7a:cf -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 bleadv -D -z stop" - - ['R SSC2 C +BLEADV:Stop,OK'] - - - "SSC SSC2 bleadv -D -z start -o 1" - - ['R SSC2 C +BLEADV:Start,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a c1:0a:d3:25:7a:cf -r 1" - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:SecReq'] - - - "SSC SSC1 blesmp -R -a 1 -r c1:0a:d3:25:7a:cf" - - ['P SSC1 C +BLESMP:AuthComplete,Success,0','P SSC2 C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 blesmp -B -z getlist -n 16" - - ['P SSC1 C +BLESMP:GetBondList,OK,15'] diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml b/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml deleted file mode 100644 index 544bc53fd..000000000 --- a/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml +++ /dev/null @@ -1,2083 +0,0 @@ -.GAP_CASE: &GAP_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_INIT3 - test environment: SSC_T2_5 - execution time: 0 - module: BT Stack - sub module: GAP - version: v1 (2016-12-31) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.dut1_stop_adv: &dut1_stop_adv - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - -.dut2_stop_adv: &dut2_stop_adv - LIST_MERGE: - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:"] - -.dut1_start_adv: &dut1_start_adv - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - -.set_default_ble_name: &set_default_ble_name - LIST_MERGE: - - - "SSC SSC1 ble -S -z name -n " - - ["R SSC1 C +BLE:OK"] - -.set_default_adv_data: &set_default_adv_data - LIST_MERGE: - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - -.open_capture_nic: &open_capture_nic - LIST_MERGE: - - - "NIC BLENIC START bt+capture" - - ['R PC_COM C +NIC_START:OK'] - -.dut1_connect_to_dut2: &dut1_connect_to_dut2 - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - -test cases: -- ID: BTSTK_GAP_01001 - <<: *GAP_CASE - test point 2: BLE GAP param device name test - summary: ble set ascii device name - steps: | - 1. DUT1 set ascii device name - 2. stop advertising - 3. config scan response and start advertising - 4. DUT2 do active scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. device name in scan result - cmd set: - - "" - - *set_default_ble_name - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - - - "SSC SSC1 bleadv -L -c 0 -t 3 -n 1" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 3 -c 0" - - ["R SSC2 P "] -- ID: BTSTK_GAP_01002 - <<: *GAP_CASE - test point 2: BLE GAP param device name test - summary: ble set non-ascii device name - steps: | - 1. DUT1 set non-ascii device name - 2. stop advertising - 3. config scan response and start advertising - 4. DUT2 do active scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. device name in scan result - cmd set: - - "" - - - "SSC SSC1 ble -S -z name -n " - - ["R SSC1 C +BLE:OK"] - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - - - "SSC SSC1 bleadv -L -c 0 -t 3 -n 1" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 3 -c 0" - - ["R SSC2 P "] -- ID: BTSTK_GAP_02001 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response include name - steps: | - 1. DUT1 stop advertise and set short device name - 2. DUT1 set include device name for adv data and scan response - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - 5. DUT1 stop advertising - 6. DUT1 set not include device name for adv data and scan response - 7. DUT1 start advertising - 8. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get complete device name in ADV_IND and SCAN_RSP - 5. succeed - 6. succeed - 7. succeed - 8. do not have complete device name in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - *set_default_ble_name - - - "SSC SSC1 bleadv -L -c 0 -n 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.NameComplete=)' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.NameComplete=)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(!HCIEvent.data_0.NameComplete)' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(!HCIEvent.data_0.NameComplete)' -- ID: BTSTK_GAP_02002 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response include Tx power - steps: | - 1. DUT1 set include Tx power for adv data and scan response - 2. DUT1 start advertising - 3. PC do active scan and capture advertising report - 4. DUT1 stop advertising - 5. DUT1 set not include Tx power for adv data and scan response - 6. DUT1 start advertising - 7. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. get Tx power in ADV_IND and SCAN_RSP - 4. succeed - 5. succeed - 6. succeed - 7. do not have Tx power in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -x 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.TxPower="")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.TxPower="")' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -x 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(!HCIEvent.data_0.TxPower)' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(!HCIEvent.data_0.TxPower)' -- ID: BTSTK_GAP_02004 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response appearance - steps: | - 1. DUT1 stop advertise - 2. DUT1 set appearance to 0 for adv data and scan response - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - 5. DUT1 stop advertising - 6. DUT1 set appearance to 1 for adv data and scan response - 7. DUT1 start advertising - 8. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. do not have appearance in ADV_IND and SCAN_RSP - 5. succeed - 6. succeed - 7. succeed - 8. get appearance 1 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -a 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(!HCIEvent.data_0.Appearance)' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(!HCIEvent.data_0.Appearance)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -a 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.Appearance="0x01")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.Appearance="0x01")' -- ID: BTSTK_GAP_02005 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response manufacturer data - steps: | - 1. DUT1 stop advertise - 2. DUT1 set manufacturer to 0x12345678 for adv data and scan response - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get manufacturer data 0x12345678 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' -- ID: BTSTK_GAP_02006 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response manufacturer length not equal to real lenght - steps: | - 1. DUT1 stop advertise - 2. DUT1 set manufacturer 0x12345678 and length 3 for adv data and scan response - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - 5. DUT1 stop advertise - 6. DUT1 set manufacturer 0x12345678 and length 10 for adv data and scan response - 7. DUT1 start advertising - 8. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get manufacturer data 0x12345678 in ADV_IND and SCAN_RSP - 5. succeed - 6. succeed - 7. succeed - 8. get manufacturer data 0x12345678 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3 -l 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3 -l 10" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ManufacturerSpecificData="0x12345678")' -- ID: BTSTK_GAP_02007 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response service data - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response service data 0x1234123456 and not include device name - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get ServiceData16BitUUID 0x1234123456 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -d 0x1234123456 -t 3 -p -f 0 -x 0" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' -- ID: BTSTK_GAP_02008 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response service data and set length not equal to real length - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response service data 0x1234123456 and service data length 3 - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - 5. DUT1 stop advertise - 6. DUT1 set advertising data and scan response service data 0x1234123456 and service data length 10 - 7. DUT1 start advertising - 8. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get ServiceData16BitUUID 0x1234123456 in ADV_IND and SCAN_RSP - 5. succeed - 6. succeed - 7. succeed - 8. get ServiceData16BitUUID 0x1234123456 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -d 0x1234123456 -t 3 -l 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -d 0x1234123456 -t 3 -l 10" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.ServiceData16BitUUID="1234123456")' -- ID: BTSTK_GAP_02009 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response service uuid list - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get Complete16BitServiceUUID 0xABCD Complete32BitServiceUUID 0xABCDDCBA - and Complete128BitServiceUUID 0x12349B5F8000008000100000ABCD0000 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' -- ID: BTSTK_GAP_02010 - <<: *GAP_CASE - test point 2: BLE GAP config advertising data - summary: ble set advertising data / scan response service uuid list and uuid length not equal to real length - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 and service uuid len 32 - 3. DUT1 start advertising - 4. PC do active scan and capture advertising report - 5. DUT1 stop advertise - 6. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 and service uuid len 64 - 7. DUT1 start advertising - 8. PC do active scan and capture advertising report - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get Complete16BitServiceUUID 0xABCD Complete32BitServiceUUID 0xABCDDCBA - and Complete128BitServiceUUID 0x12349B5F8000008000100000ABCD0000 in ADV_IND and SCAN_RSP - 5. succeed - 6. succeed - 7. succeed - 8. get Complete16BitServiceUUID 0xABCD Complete32BitServiceUUID 0xABCDDCBA - and Complete128BitServiceUUID 0x12349B5F8000008000100000ABCD0000 in ADV_IND and SCAN_RSP - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - version: v2 (2016-03-01) - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3 -l 32" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3 -l 64" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - *open_capture_nic - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="SCAN_RSP")(HCIEvent.address_0=)(HCIEvent.data_0.Complete16BitServiceUUID="ABCD")(HCIEvent.data_0.Complete32BitServiceUUID="ABCDDCBA")(HCIEvent.data_0.Complete128BitServiceUUID="12349B5F8000008000100000ABCD0000")' -- ID: BTSTK_GAP_03001 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set adv parameter adv_type - steps: | - 1. DUT1 stop advertise - 2. DUT1 start adv with adv_type ADV_IND - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with adv_type ADV_TYPE_DIRECT_IND_HIGH - 5. repeat step 1-3 with adv_type ADV_TYPE_SCAN_IND - 6. repeat step 1-3 with adv_type ADV_TYPE_NONCONN_IND - 7. repeat step 1-3 with adv_type ADV_TYPE_DIRECT_IND_LOW - expected result: | - 1. succeed - 2. succeed - 3. get ADV_IND with DUT1 BT MAC - 4. get ADV_DIRECT_IND with DUT1 BT MAC - 5. get ADV_SCAN_IND with DUT1 BT MAC - 6. get ADV_NONCONN_IND with DUT1 BT MAC - 7. can not get ADV_DIRECT_IND with DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - *open_capture_nic - - *dut1_stop_adv - - - "SSC SSC1 bleadv -D -z start -t 0" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -D -z start -t 1 -y 0 -b " - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_DIRECT_IND")(HCIEvent.address_0=)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -i 0x00B0-0x0200 -t 3" - - ["R SSC1 C +BLEADV:OK"] - - - "SSC SSC1 bleadv -D -z start -t 2 -i 0x00B0-0x0200" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_SCAN_IND")(HCIEvent.address_0=)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -D -z start -t 3 -i 0x00B0-0x0200" - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_NONCONN_IND")(HCIEvent.address_0=)' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -i 0x0640-0x0780 -t 3" - - ["R SSC1 C +BLEADV:OK"] - - - "SSC SSC1 bleadv -D -z start -t 4 -i 0x0640-0x0780 -y 0 -b " - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 3 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.address_0!=)' -- ID: BTSTK_GAP_03002 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set adv parameter channel map - steps: | - 1. DUT1 stop advertise - 2. DUT1 start adv on channel 37 - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with channel map 38, 39, all - 4. repeat step 1-3 with channel map not valid - expected result: | - 1. succeed - 2. succeed - 3. get ADV_IND with DUT1 BT MAC - 4. get ADV_IND with DUT1 BT MAC - 5. can not get ADV_IND with DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - allow fail: 1/2 - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - *open_capture_nic - - - LOOP 7 3 "[1,2,3,4,5,6,7]" "['PDU','PDU','PDU','PDU','PDU','PDU','PDU']" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -D -z start -t 0 -h {%d}" - - ["R SSC1 C +BLEADV:Start,OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC {%s} (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.event_type_0="ADV_IND")(HCIEvent.address_0=)' - - - "SSC SSC1 bleadv -D -z start -t 0 -h 8" - - ["R SSC1 C +BLEADV:Start,ERROR"] -- ID: BTSTK_GAP_03004 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set adv parameter peer address and peer address type - steps: | - 1. DUT1 stop advertise - 2. DUT1 start adv with adv type DIRECT_IND_HIGH, peer address type public and peer address as - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with adv type DIRECT_IND_HIGH, peer address type random and peer address as - expected result: | - 1. succeed - 2. succeed - 3. get ADV_IND with DUT1 name DUT1 BT MAC - 4. get ADV_IND with DUT1 name and DUT1 BT MAC - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - allow fail: 2/3 - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - *open_capture_nic - - *dut1_stop_adv - - - LOOP 2 2 "[0,1]" "['=','!=']" - - [""] - - - "SSC SSC1 bleadv -D -z start -t 1 -y {%d} -b " - - ["R SSC1 C +BLEADV:OK"] - - - "HCITOOL 2 -i lescan" - - - 'P PC_COM C +HCITOOL:OK' - - 'P BLENIC PDU (HCIEvent.le_sub_event_code="LEAdvReport")(HCIEvent.address_0{%s})' -- ID: BTSTK_GAP_03005 - <<: *GAP_CASE - CI ready: "No" - test point 2: BLE GAP set advertise param - summary: ble set adv parameter adv interval - steps: | - 1. DUT1 stop advertise - 2. DUT1 start adv with adv interval 0x20-0x20 on channel 1 - 3. PC do active scan and capture advertising report - 4. repeat step 1-3 with adv interval 0x40-0x40, 0x60-0x60 - expected result: | - 1. succeed - 2. succeed - 3. calculate adv intervals, within the interval range in adv param - 4. calculate adv intervals, within the interval range in adv param - initial condition: BLE_INIT1 - test environment: SSC_T1_3 - CI ready: 'No' - cmd set: - - "BLEFunction/AdvInterval" - - - interval_list = ["0x0020-0x0020", "0x0040-0x0040", "0x0060-0x0060"] - - [''] - - - deviation = 0.3 - - [''] -- ID: BTSTK_GAP_03008 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble adv with random address and RPA_PUBLIC - initial condition: BLE_INIT_SMP - steps: | - 1. DUT2 set random address - 2. DUT2 adv with RPA_PUBLIC - 3. DUT1 start scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0 -t 3 -n 1" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:Stop,OK"] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -D -z start -t 0 -o 2" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 NP C InquiryComplete"] -- ID: BTSTK_GAP_03009 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: ble set adv owner address type as RPA_PUBLIC - initial condition: BLE_INIT_SMP - steps: | - 1. DUT2 set owner address type as RPA_PUBLIC and start adv - 2. DUT1 scan - 3. exchange IRK and pairing - 4. DUT2 set privacy - 5. DUT2 set owner address type as RPA_PUBLIC and start adv - 6. DUT1 scan - 7. DUT1 connect to DUT2 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - cmd set: - - "" - - - "SSC SSC2 ble -S -z name -n " - - ["R SSC2 C +BLE:OK"] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z RspKey -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z InitKey -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC2 bleadv -L -c 0 -n 1" - - ["R SSC2 C +BLEADV:SetAdv,OK"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:"] - - - "SSC SSC2 bleadv -D -z start -o 2" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 P C Complete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK", "R SSC2 C +BLECONN:GapConnect,OK"] -- ID: BTSTK_GAP_03010 - <<: *GAP_CASE - CI ready: "No" # can't restore to use public address after set to use private address - test point 2: BLE GAP set advertise param - summary: ble adv with privacy address and RPA_RANDOM - initial condition: BLE_INIT_SMP - steps: | - 1. DUT2 set random address - 2. DUT2 adv with RPA_RANDOM - 3. DUT1 start scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:Stop,OK"] - - *set_default_ble_name - - - "SSC SSC2 ble -S -z randAddr -a -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -L -c 0 -n 1" - - ["R SSC2 C +BLEADV:SetAdv,OK"] - - - "SSC SSC2 bleadv -D -z start -t 0 -o 3" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 NP C Complete"] -- ID: BTSTK_GAP_03011 - <<: *GAP_CASE - CI ready: "No" # can't restore to use public address after set to use private address - test point 2: BLE GAP set advertise param - summary: ble set adv owner address type as RPA_RANDOM - initial condition: BLE_INIT_SMP - steps: | - 1. DUT2 set owner address type as RPA_RANDOM and start adv - 2. DUT2 set static random address - 3. DUT2 set owner address type as RPA_RANDOM and start adv - 4. DUT1 start scan - 5. exchange IRK and do pairing - 6. DUT2 set privacy - 7. DUT2 set owner address type as RPA_RANDOM and start adv - 8. DUT1 scan - 9. DUT1 connect to DUT2 - expected result: | - 1. failed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z RspKey -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 ble -S -z randAddr -a -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:"] - - - "SSC SSC2 bleadv -D -z start -o 3" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 P C Complete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK", "R SSC2 C +BLECONN:GapConnect,OK"] -- ID: BTSTK_GAP_03012 - <<: *GAP_CASE - test point 2: BLE GAP set advertise param - summary: set ble adv peer_address_type as RPA_PUBLIC and RPA_RANDOM - initial condition: BLE_INIT_SMP - steps: | - 1. DUT1 set peer address and peer address type RPA_PUBLIC - 2. DUT1 set peer address and peer address type RPA_RANDOM - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleadv -D -z stop" - - ["R SSC1 C +BLEADV:"] - - - "SSC SSC1 bleadv -D -z start -b -y 2" - - ["R SSC1 C +BLEADV:Start,ERROR"] - - - "SSC SSC1 bleadv -D -z start -b -y 3" - - ["R SSC1 C +BLEADV:Start,ERROR"] -- ID: BTSTK_GAP_04001 - <<: *GAP_CASE - test point 2: BLE GAP set scan param - summary: ble set scan type - steps: | - 1. stop advertise and set short device name - 2. DUT1 set adv data with manufacturer data A - 3. DUT1 set scan response data with manufacturer data B - 4. DUT2 do passive scan - 5. DUT2 do active scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. get manufacturer data A - 5. get manufacturer data B - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -R -t 1 -r 0x15FF1011121314151617181910111213141516171819" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - - "SSC SSC1 bleadv -R -t 2 -r 0x020AEB" - - ["R SSC1 C +BLEADV:SetScanRes,OK"] - - *dut1_start_adv - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 3 -e 2 -c 0 -s 0" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x1011121314151617181910111213141516171819"%%()' - - 'R SSC2 NRE "\+BTSCANEXT:%%s,txp,0xEB"%%() C Complete' - - - "SSC SSC2 blescan -D -z stop" - - ['R SSC2 C +BLESCAN'] - - - "SSC SSC2 blescan -D -z start -t 3 -e 1 -c 0 -s 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x1011121314151617181910111213141516171819"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,txp,0xEB"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_04002 - <<: *GAP_CASE - test point 2: BLE GAP set scan param - summary: ble set scan own address type (not test if own address work as expected) - steps: | - 1. DUT1 start advertising - 2. DUT2 set own addr type (public, random, rpa_public, rpa_random) - 3. DUT2 do active scan - 4. DUT2 set invalid own addr type - expected result: | - 1. succeed - 2. succeed - 3. able to scan DUT1 - 4. error - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetScanRes,OK"] - - *dut1_start_adv - - *dut2_stop_adv - - - "SSC SSC2 blescan -D -z start -t 1 -c 0 -s 1 -o 0" - - ['R SSC2 P C Complete'] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 blescan -D -z start -t 1 -c 0 -s 1 -o 2" - - ['R SSC2 P C Complete'] - - - "SSC SSC2 ble -S -z randAddr -a -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 blescan -D -z start -t 1 -c 0 -s 1 -o 1" - - ['R SSC2 P C Complete'] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 blescan -D -z start -t 1 -c 0 -s 1 -o 3" - - ['R SSC2 P C Complete'] -- ID: BTSTK_GAP_04003 - <<: *GAP_CASE - test point 2: BLE GAP set scan param - summary: ble set scan interval (will not test if scan interval work as expected) - steps: | - 1. DUT2 start advertising - 2. DUT1 set scan interval 0x0004 - 3. DUT1 set scan interval 0x4000 - 4. DUT1 set invalid scan interval - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. error - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 blescan -D -z start -c 0 -s 1 -i 0x0004 -w 0x0004" - - ["R SSC1 C +BLESCAN:Start,OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,OK"] - - - "SSC SSC1 blescan -D -z start -c 0 -s 1 -i 0x4000 -w 0x4000" - - ["R SSC1 C +BLESCAN:Start,OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,OK"] - - - "SSC SSC1 blescan -D -z start -c 0 -s 1 -i 0x0003 -w 0x0003" - - ["R SSC1 C +BLESCAN:Start,ERROR"] - - - "SSC SSC1 blescan -D -z start -c 0 -s 1 -i 0x4001 -w 0x4001" - - ["R SSC1 C +BLESCAN:Start,ERROR"] -- ID: BTSTK_GAP_04004 - <<: *GAP_CASE - test point 2: BLE GAP set scan param - summary: ble set scan window (will not test if scan window work as excepted) - steps: | - 1. DUT2 set scan interval 0x0004 - 2. DUT2 set scan interval 0x4000 - 3. DUT2 set scan interval 0x0003 - 4. DUT2 set scan interval 0x4001 - expected result: | - 1. succeed - 2. succeed - 3. fail - 4. fail - initial condition: BLE_INIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 blescan -D -z start -c 0 -w 0x0004 -i 0x0004" - - ["R SSC1 C +BLESCAN:Start,OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,OK"] - - - "SSC SSC1 blescan -D -z start -c 0 -w 0x4000 -i 0x4000" - - ["R SSC1 C +BLESCAN:Start,OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,OK"] - - - "SSC SSC1 blescan -D -z start -c 0 -w 0x0003 -i 0x0003" - - ["R SSC1 C +BLESCAN:Start,ERROR"] - - - "SSC SSC1 blescan -D -z start -c 0 -w 0x4001 - 0x4001" - - ["R SSC1 C +BLESCAN:Start,ERROR"] -- ID: BTSTK_GAP_05001 - <<: *GAP_CASE - test point 2: BLE GAP start stop adv / scan - summary: stop and start adv in wrong state - steps: | - 1. DUT1 stop adv - 2. DUT1 stop adv - 3. DUT2 do passive scan - 4. DUT1 start adv - 5. DUT1 start adv - 6. DUT2 do passive scan - expected result: | - 1. succeed - 2. succeed - 3. DUT1 not in scan result - 4. succeed - 5. succeed - 6. DUT1 in scan result - cmd set: - - "" - - *dut1_stop_adv - - *dut1_stop_adv - - - "SSC SSC2 blescan -D -z start -t 1 -c 0" - - ["R SSC2 NP C Complete"] - - *dut1_start_adv - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start"] - - - "SSC SSC2 blescan -D -z start -t 1 -c 0" - - ["R SSC2 P C Complete"] -- ID: BTSTK_GAP_05002 - <<: *GAP_CASE - test point 2: BLE GAP start stop adv / scan - summary: cancel scan when scanning or not scanning - steps: | - 1. DUT1 start scanning for 3 seconds - 2. DUT1 stop scanning - 3. DUT1 stop scanning - expected result: | - 1. succeed - 2. succeed - 3. failed - initial condition: BLE_INIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 blescan -D -z start -t 3 -c 0" - - ["R SSC1 C +BLESCAN:OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:Stop,ERROR"] -- ID: BTSTK_GAP_08001 - <<: *GAP_CASE - test point 2: BLE GAP operation without init/enable BT or register callback - summary: do adv, scan, set name when BT is deinit - steps: | - 1. DUT1 do adv - 2. DUT1 do set name - expected result: | - 1. fail - 2. fail - initial condition: BLE_DEINIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 ble -S -z name -n abcde" - - ["R SSC1 C +BLE"] -- ID: BTSTK_GAP_08002 - <<: *GAP_CASE - test point 2: BLE GAP operation without init/enable BT or register callback - summary: do adv, scan, set name, conn when BT is disable - steps: | - 1. DUT1 do init - 2. DUT1 do adv - 3. DUT2 do set name - expected result: | - 1. succeed - 2. fail - 3. fail - initial condition: BLE_DEINIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bleadv -L -c 0" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 ble -S -z name -n abcde" - - ["R SSC1 C +BLE"] -- ID: BTSTK_GAP_08003 - <<: *GAP_CASE - test point 2: BLE GAP operation without init/enable BT or register callback - summary: do adv, scan, set name, conn when BT is enable but no callback registered - steps: | - 1. DUT1 do init and enable - 2. DUT1 do adv - 3. DUT2 do set name - expected result: | - 1. succeed - 2. fail - 3. fail - initial condition: BLE_DEINIT1 - test environment: SSC_T1_4 - cmd set: - - "" - - - "SSC SSC1 bt -D -z start" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bleadv -L -c 0" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV"] - - - "SSC SSC1 ble -S -z name -n abcde" - - ["R SSC1 C +BLE"] -- ID: BTSTK_GAP_09002 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: process scan data service UUIDs - steps: | - 1. DUT1 set raw adv 16 bit Complete UUID list - 2. DUT1 start adv - 3. DUT2 do active scan with extended scan data - 4. repeat step 1-3 with 16 bit incomplete UUID, 32 bit complete/incomplete UUID, 128 bit complete/incomplete UUID - expected result: | - 1. succeed - 2. succeed - 3. scan with the correct adv data - 4. scan with the correct adv data - cmd set: - - "" - - *dut2_stop_adv - - - LOOP 4 4 "['0302ABCD','0303ABCD','0504ABCDABCD','0505ABCDABCD',]" "['insrv16,0xABCD','srv16,0xABCD','insrv32,0xABCDABCD','srv32,0xABCDABCD']" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -R -t 1 -r 0x{%s}" - - ["R SSC1 C +BLEADV:OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,{%s}"%%()' - - 'R SSC2 C Complete' - - - LOOP 2 4 "['1106ABCDABCDABCDABCDABCDABCDABCDABCD','1107ABCDABCDABCDABCDABCDABCDABCDABCD']" "['insrv128,0xABCDABCDABCDABCDABCDABCDABCDABCD','srv128,0xABCDABCDABCDABCDABCDABCDABCDABCD']" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -R -t 1 -r 0x{%s}" - - ["R SSC1 C +BLEADV:OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,{%s}"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09003 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: process scan data service data - steps: | - 1. DUT1 set raw adv 16 bit service data - 2. DUT1 start adv - 3. DUT2 do active scan with extended scan data - 4. repeat step 1-3 with 32 bit service data, 128 bit service data - expected result: | - 1. succeed - 2. succeed - 3. scan with the correct adv data - 4. scan with the correct adv data - cmd set: - - "" - - *dut2_stop_adv - - - LOOP 3 4 "['0416ABCDEF','0620ABCDABCDEF','1221ABCDABCDABCDABCDABCDABCDABCDABCDEF',]" "['srvdata16,0xABCDEF','srvdata32,0xABCDABCDEF','srvdata128,0xABCDABCDABCDABCDABCDABCDABCDABCDEF']" - - - "SSC SSC1 bleadv -R -t 1 -r 0x{%s}" - - ["R SSC1 C +BLEADV:OK"] - - *dut1_stop_adv - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,{%s}"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09005 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included device name - steps: | - 1. DUT1 stop advertise and set short device name abcde - 2. DUT1 set include device name for adv data and scan response - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertising - 6. DUT1 set not include device name for adv data and scan response - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 ble -S -z name -n abcde" - - ["R SSC1 C +BLE"] - - - "SSC SSC1 bleadv -L -c 0 -n 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCAN:INQ,%%s,abcde"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCAN:INQ,%%s,NULL"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09006 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included Tx power - steps: | - 1. DUT1 stop advertise and set short device name - 2. DUT1 set include Tx power for adv data and scan response - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertising - 6. DUT1 set not include Tx power for adv data and scan response - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -x 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,txp,0x03"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -x 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'R SSC2 NRE "\+BTSCANEXT:%%s,txp,0x03"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09008 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included appearance - steps: | - 1. DUT1 stop advertise and set short device name - 2. DUT1 set appearance to 0 for adv data and scan response - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertising - 6. DUT1 set appearance to 1 for adv data and scan response - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -a 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 NRE "\+BTSCANEXT:%%s,app,0x0100"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -a 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,app,0x0100"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09009 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included manufacturer data - steps: | - 1. DUT1 stop advertise and set short device name - 2. DUT1 set manufacturer to 0x12345678 for adv data and scan response - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x12345678"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09010 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included service data - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response service data 0x1234123456 and not include device name - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -d 0x1234123456 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srvdata16,0x1234123456"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09011 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: proccess scan data included service uuid list - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1 -c 0 -d 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv16,0xABCD"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv32,0xABCDDCBA"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv128,0x12349B5F8000008000100000ABCD0000"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09012 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: adv include name and not set device name - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response include name - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. failed - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 1 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - - "SSC SSC1 bleadv -D -z start" - - ["R SSC1 C +BLEADV:Start,OK"] - - - "SSC SSC2 blescan -D -z start -c 0" - - - 'P SSC2 RE "\+BTSCAN:INQ,%%s"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09013 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: adv manufacturer_len not equal to real len - steps: | - 1. DUT1 stop adv - 2. DUT1 set manufacturer len shorter then real len - 3. DUT1 start adv - 4. DUT2 start scan - 5. DUT1 stop adv - 6. DUT1 set manufacturer len longer then real len - 7. DUT1 start adv - 8. DUT2 start scan - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3 -l 6" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x12345678"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -m 0x12345678 -t 3 -l 10" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,man,0x12345678"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09014 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: set adv service data length not equal to real length - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response service data 0x1234123456 and set service data length 4 - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertise - 6. DUT1 set advertising data and scan response service data 0x1234123456 and set service data length 10 - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -d 0x1234123456 -t 3 -l 4" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srvdata16,0x1234123456"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -d 0x1234123456 -t 3 -l 10" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srvdata16,0x1234123456"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_09015 - <<: *GAP_CASE - test point 2: BLE GAP processing scan data - summary: set service uuid length not equal to real length - steps: | - 1. DUT1 stop advertise - 2. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 and set service uuid length 32 - 3. DUT1 start advertising - 4. DUT2 start scan and processing scan data - 5. DUT1 stop advertise - 6. DUT1 set advertising data and scan response not include name, service uuid list 0xABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 and set service uuid length 64 - 7. DUT1 start advertising - 8. DUT2 start scan and processing scan data - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. scan with the correct adv data - 5. succeed - 6. succeed - 7. succeed - 8. scan with the correct adv data - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3 -l 32" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv16,0xABCD"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv32,0xABCDDCBA"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv128,0x12349B5F8000008000100000ABCD0000"%%()' - - 'R SSC2 C Complete' - - *dut1_stop_adv - - - "SSC SSC1 bleadv -L -c 0 -n 0 -x 0 -i 0x00-0x00 -s ABCD,ABCDDCBA,12349B5F8000008000100000ABCD0000 -t 3 -l 64" - - ["R SSC1 C +BLEADV:SetAdv,OK"] - - *dut1_start_adv - - - "SSC SSC2 blescan -D -z start -t 1 -e 1" - - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv16,0xABCD"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv32,0xABCDDCBA"%%()' - - 'P SSC2 RE "\+BTSCANEXT:%%s,srv128,0x12349B5F8000008000100000ABCD0000"%%()' - - 'R SSC2 C Complete' -- ID: BTSTK_GAP_10001 - <<: *GAP_CASE - test point 2: BLE GAP master multi connection test - summary: master connect to 3 slaves with different app and master do disconnect - steps: | - 1. DUT2-DUT4 starts adv - 2. DUT1 connect to DUT2 - DUT4 - 3. DUT1 disconnect with DUT2 - DUT4 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-4] bleadv -D -z start" - - ["P SSC[2-4] C +BLEADV:Start,OK"] - - - LOOP 3 1 "[0,1,2]" "[2,3,4]" "[2,3,4]" - - "" - - - "SSC SSC1 bleconn -C -p 0x1{%d} -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC{%d} C +BLECONN:GapConnect,OK'] - - - LOOP 3 1 "[2,1,0]" "[4,3,2]" "[4,3,2]" - - "" - - - "SSC SSC1 bleconn -D -z client -p 0x1{%d} -a " - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC{%d} C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_10002 - <<: *GAP_CASE - test point 2: BLE GAP master multi connection test - summary: master connect to 3 slaves with different app and slave do disconnect - steps: | - 1. DUT2-DUT4 starts adv - 2. DUT1 connect to DUT2 - DUT4 - 3. DUT1 disconnect with DUT2 - DUT4 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-4] bleadv -D -z start" - - ["P SSC[2-4] C +BLEADV:Start,OK"] - - - LOOP 3 1 "[0,1,2]" "[2,3,4]" "[2,3,4]" - - "" - - - "SSC SSC1 bleconn -C -p 0x1{%d} -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC{%d} C +BLECONN:GapConnect,OK'] - - - LOOP 3 1 "[2,3,4]" "[2,3,4]" - - "" - - - "SSC SSC{%d} bleconn -D -z server -p 0xA0 -r " - - ['P SSC1 C +BLECONN:GapDisconnect,OK,001[0-2]', 'P SSC{%d} C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_10003 - <<: *GAP_CASE - test point 2: BLE GAP master multi connection test - summary: master connect to 4 slaves with same app and master do disconnect - steps: | - 1. DUT2-DUT4 starts adv - 2. DUT1 connect to DUT2 - DUT5 - 3. DUT1 disconnect with DUT2 - DUT5 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] bleadv -D -z start" - - ["P SSC[2-5] C +BLEADV:Start,OK"] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC{%d} C +BLECONN:GapConnect,OK'] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleconn -D -z client -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC{%d} C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_10004 - <<: *GAP_CASE - test point 2: BLE GAP master multi connection test - summary: master connect to 4 slaves with same app and slave do disconnect - steps: | - 1. DUT2-DUT4 starts adv - 2. DUT1 connect to DUT2 - DUT5 - 3. DUT1 disconnect with DUT2 - DUT5 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] bleadv -D -z start" - - ["P SSC[2-5] C +BLEADV:Start,OK"] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC{%d} C +BLECONN:GapConnect,OK'] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC{%d} bleconn -D -z server -p 0xA2 -a " - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC{%d} C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_11001 - <<: *GAP_CASE - test point 2: BLE GAP slave multi connection test - summary: slave connected by 4 master and master do disconnect - steps: | - 1. DUT2-DUT5 starts adv - 2. DUT1 connect to DUT2 - DUT5 - 3. DUT1 disconnect with DUT2 - DUT5 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 gatts -S -z load -p 0xA2" - - ['R SSC1 C +GATTS:StartService,OK,A002'] - - - LOOP 4 2 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleadv -D -z start" - - ["P SSC1 C +BLEADV:Start,OK"] - - - "SSC SSC{%d} bleconn -C -p 0x10 -a " - - ['R SSC{%d} C +BLECONN:GapConnect,OK,0010', 'R SSC1 C +BLECONN:GapConnect,OK'] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - - "SSC SSC{%d} bleconn -D -z client -p 0x10 -a " - - ['P SSC{%d} C +BLECONN:GapDisconnect,OK', 'P SSC1 C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_11002 - <<: *GAP_CASE - test point 2: BLE GAP slave multi connection test - summary: slave connected by 4 master and slave do disconnect - steps: | - 1. DUT2-DUT5 starts adv - 2. DUT1 connect to DUT2 - DUT5 - 3. DUT1 disconnect with DUT2 - DUT5 - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 gatts -S -z load -p 0xA2" - - ['R SSC1 C +GATTS:StartService,OK,A002'] - - - LOOP 4 2 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleadv -D -z start" - - ["P SSC1 C +BLEADV:Start,OK"] - - - "SSC SSC{%d} bleconn -C -p 0x10 -a " - - ['R SSC{%d} C +BLECONN:GapConnect,OK,0010', 'R SSC1 C +BLECONN:GapConnect,OK'] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 bleconn -D -z server -p 0xA2 -a " - - ['P SSC{%d} C +BLECONN:GapDisconnect,OK', 'P SSC1 C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_GAP_12001 - <<: *GAP_CASE - test point 2: BLE GAP multi connection as both master and slave role test - summary: connected by 2 masters and connect to 2 slaves and do disconnect - steps: | - 1. DUT1 starts adv - 2. DUT2 DUT3 connect to DUT1 - 3. DUT1 connect to DUT4 DUT5 - 4. DUT1 do disconnect - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 gatts -S -z load -p 0xA2" - - ['R SSC1 C +GATTS:StartService,OK,A002'] - - - LOOP 2 2 "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 bleadv -D -z start" - - ["P SSC1 C +BLEADV:Start,OK"] - - - "SSC SSC{%d} bleconn -C -p 0x10 -a " - - ['R SSC{%d} C +BLECONN:GapConnect,OK,0010', 'P SSC1 C +BLECONN:GapConnect,OK'] - - - "SSC SSC[4-5] bleadv -D -z start" - - ["P SSC[4-5] C +BLEADV:Start,OK"] - - - LOOP 2 1 "[4,5]" "[4,5]" - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC{%d} C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 bleconn -D -z all" - - ["P SSC[2-5] C Disconnect"] -- ID: BTSTK_GAP_12002 - <<: *GAP_CASE - test point 2: BLE GAP multi connection as both master and slave role test - summary: connected by 2 masters and connect to 2 slaves and be disconnected - steps: | - 1. DUT1 starts adv - 2. DUT2 DUT3 connect to DUT1 - 3. DUT1 connect to DUT4 DUT5 - 4. DUT[2-5] do disconnect - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_INIT5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - *dut1_stop_adv - - - "SSC SSC1 gatts -S -z load -p 0xA2" - - ['R SSC1 C +GATTS:StartService,OK,A002'] - - - LOOP 2 2 "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 bleadv -D -z start" - - ["P SSC1 C +BLEADV:Start,OK"] - - - "SSC SSC{%d} bleconn -C -p 0x10 -a " - - ['R SSC{%d} C +BLECONN:GapConnect,OK,0010', 'R SSC1 C +BLECONN:GapConnect,OK'] - - - "SSC SSC[4-5] bleadv -D -z start" - - ["P SSC[4-5] C +BLEADV:Start,OK"] - - - LOOP 2 1 "[4,5]" "[4,5]" - - "" - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC{%d} C +BLECONN:GapConnect,OK'] - - - LOOP 4 1 "[2,3,4,5]" - - - "SSC SSC{%d} bleconn -D -z all" - - ["P SSC1 C Disconnect"] -- ID: BTSTK_GAP_50001 - <<: *GAP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GAP performance test - summary: BLE Connect and disconnect performance test - steps: | - 1. DUT1 disconnect with DUT2 - 2. DUT2 start advertising - 3. DUT1 connect to DUT2 - 4. do service discovery - 5. loop step 1-4 - 6. check connection fail ratio and average conn time - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. meet pass standard - initial condition: BLE_INIT2 - execution time: 6 - version: v1 (2017-05-19) - CI ready: 'No' - cmd set: - - "BLEStress/BLEConnPerformance" - - - "test_time = 20" - - "" - - - "average_conn_time = 3" - - "" - - - "fail_ratio = 0.01" - - "" - - - "fail_timeout = 10" - - "" -- ID: BTSTK_GAP_50004 - <<: *GAP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GAP performance test - summary: BLE Connect and disconnect correct performance test - steps: | - 1. DUT1 disconnect with DUT2 - 2. DUT2 start advertising - 3. DUT1 connect to DUT2 - 4. loop step 1-4 1000 times - 5. reboot - 6. loop step 1-5 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. meet pass standard - initial condition: BLE_INIT2 - execution time: 6 - version: v1 (2017-05-19) - CI ready: 'No' - cmd set: - - "BLEStress/BLEConnCorPerformance" - - - "test_time = 100" - - "" - - - "reboot_time = 1000" - - "" - - - "average_conn_time = 3" - - "" - - - "fail_ratio = 0.01" - - "" - - - "fail_timeout = 10" - - "" -- ID: BTSTK_GAP_51001 - <<: *GAP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GAP performance test - summary: BLE adv and scan forever - steps: | - 1. DUT1 do adv - 2. DUT2 do scan - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_INIT2 - execution time: 10 - cmd set: - - "BLEStress/BLEAdvScanPerformance" - - - "test_time = 600" - - "" -- ID: BTSTK_GAP_14001 - <<: *GAP_CASE - test point 2: BLE GAP set randAddr as random address - summary: adv with static random address and be connected - steps: | - 1. DUT2 do set randaddr - 2. DUT2 start adv and DUT1 start scan - 3. DUT1 connect to DUT2 - expected result: | - 1. succeed - 2. succeed - 3. succeed - cmd set: - - "" - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC2 ble -S -z randAddr -a -r 1" - - ["R SSC2 C +BLECONN:SetRandAddr,OK"] - - - "SSC SSC2 bleadv -D -z start -o 1" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start" - - ['R SSC1 P C Complete'] - - - "SSC SSC1 bleconn -C -p 0x10 -a -r 1" - - ["P SSC1 C +BLECONN:GapConnect,OK", "P SSC2 C +BLECONN:GapConnect,OK"] -- ID: BTSTK_GAP_14002 - <<: *GAP_CASE - test point 2: BLE GAP set as pablic address - summary: BLE GAP set invalid randaddr FF:FF:FF:FF:FF:FF - steps: | - 1. DUT1 set invalid randaddr FF:FF:FF:FF:FF:FF - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 ble -S -z randAddr -a FF:FF:FF:FF:FF:FF -r 1" - - ["R SSC1 C +BLECONN:SetRandAddr,ERROR"] -- ID: BTSTK_GAP_14003 - <<: *GAP_CASE - test point 2: BLE GAP set as pablic address - summary: BLE GAP set invalid randaddr 11:00:00:00:00:00 - steps: | - 1. DUT1 set invalid randaddr 11:00:00:00:00:00 - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 ble -S -z randAddr -a 11:00:00:00:00:00 -r 1" - - ["R SSC1 C +BLECONN:SetRandAddr,ERROR"] -- ID: BTSTK_GAP_14004 - <<: *GAP_CASE - test point 2: BLE GAP set as pablic address - summary: BLE GAP set invalid randaddr 10:FA:67:25:AB:DA - steps: | - 1. DUT1 set invalid randaddr 10:FA:67:25:AB:DA - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 ble -S -z randAddr -a 10:FA:67:25:AB:DA -r 1" - - ["R SSC1 C +BLECONN:SetRandAddr,ERROR"] -- ID: BTSTK_GAP_14005 - <<: *GAP_CASE - test point 2: BLE GAP set as pablic address - summary: BLE GAP set invalid randaddr 01:49:F0:AF:CA:DB - steps: | - 1. DUT1 set invalid randaddr 01:49:F0:AF:CA:DB - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 ble -S -z randAddr -a 01:49:F0:AF:CA:DB -r 1" - - ["R SSC1 C +BLECONN:SetRandAddr,ERROR"] -- ID: BTSTK_GAP_14006 - <<: *GAP_CASE - test point 2: BLE GAP set as pablic address - summary: BLE GAP set invalid randaddr 00:AC:F6:36:A4:6B - steps: | - 1. DUT1 set invalid randaddr 00:AC:F6:36:A4:6B - expected result: | - 1. failed - cmd set: - - "" - - - "SSC SSC1 ble -S -z randAddr -a 00:AC:F6:36:A4:6B -r 1" - - ["R SSC1 C +BLECONN:SetRandAddr,ERROR"] -- ID: BTSTK_GAP_14007 - <<: *GAP_CASE - test point 2: BLE set random address test - summary: BLE set random address as resolvable private address and cannot be scan - initial condition: BLE_INIT_SMP - steps: | - 1. SSC1 set adv params and config local privacy as true - 2. SSC1 bleadv and SSC2 blescan - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleadv -L -c 0 -t 3" - - ["R SSC1 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC1 ble -S -z privacy -p 1" - - ["R SSC1 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC1 bleadv -D -z start -o 2" - - ["R SSC1 C +BLEADV:OK"] - - - "SSC SSC2 blescan -D -z start -t 3 -c 0" - - ["R SSC2 NP C +BLESCAN:InquiryComplete"] -- ID: BTSTK_GAP_14008 - <<: *GAP_CASE - test point 2: BLE set random address test - summary: BLE pairing and set random address as resolvable private address, reconnect after disconnect - steps: | - 1. SSC2 set AuthReqMode and IOCAP,set RspKey as Enc and IRK - 2. pairing - 3. SSC1 disconnect to SSC2 - 4. SSC2 do local privacy - 5. SSC2 bleadv and SSC1 blescan - 6. SSC1 connect to SSC2 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - initial condition: BLE_INIT_SMP - cmd set: - - "" - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z RspKey -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z InitKey -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -D -z start -o 2" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z start -t 3" - - ["R SSC1 P C InquiryComplete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK", "R SSC2 C +BLECONN:GapConnect,OK"] -- ID: BTSTK_GAP_14009 - <<: *GAP_CASE - test point 2: BLE set random address test - summary: BLE pairing and set random address as resolvable private address, reconnect after reboot - steps: | - 1. SSC2 set AuthReqMode and IOCAP,set RspKey as Enc and IRK - 2. pairing - 3. SSC1 and SSC2 reboot - 4. SSC2 do local privacy - 5. SSC2 bleadv and SSC1 blescan - 6. SSC1 connect to SSC2 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - initial condition: BLE_INIT_SMP - allow fail: 2/3 - cmd set: - - "" - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z RspKey -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC[1-2] reboot" - - ['R SSC[1-2] C !!!ready!!!'] - - - "SSC SSC[1-2] ble -R" - - ["R SSC[1-2] C +BLE:OK"] - - - "SSC SSC2 gatts -S -z load -p 0xA2" - - ['R SSC2 C +GATTS:StartService,OK,A002'] - - - "SSC SSC2 ble -S -z privacy -p 1" - - ["R SSC2 C +BLECONN:SetResAddr,Success"] - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC2 bleadv -L -c 0 -t 3" - - ["R SSC2 C +BLEADV:SetAdv,OK C +BLEADV:SetScanRes,OK"] - - - "SSC SSC2 bleadv -D -z start -o 2" - - ["R SSC2 C +BLEADV:OK"] - - - "SSC SSC1 blescan -D -z stop" - - ["R SSC1 C +BLESCAN:OK"] - - - "SSC SSC1 blescan -D -z start -t 3 -c 0" - - ["R SSC1 P C InquiryComplete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK", "R SSC2 C +BLECONN:GapConnect,OK"] -- ID: BTSTK_GAP_15001 - <<: *GAP_CASE - test point 2: BLE GAP white list test - summary: add white list and remove - steps: | - 1. get white list - 2. DUT1 add DUT2 into white list - 3. remove DUT2 from white list - 4. remove DUT2 from white list - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_INIT_REBOOT2 - cmd set: - - "" - - - "SSC SSC1 ble -W -z get" - - ['P SSC1 C +BLE:GetWhiteList,OK,12'] - - - "SSC SSC1 ble -W -a -z add" - - ['P SSC1 C +BLE:AddWhiteList,Success'] - - - "SSC SSC1 ble -W -a -z remove" - - ['P SSC1 C +BLE:RemoveWhiteList,Success'] - - - "SSC SSC1 ble -W -a -z remove" - - ['P SSC1 C +BLE:RemoveWhiteList,Success'] -- ID: BTSTK_GAP_15002 - <<: *GAP_CASE - test point 2: BLE GAP white list test - summary: get white list test - steps: | - 1. DUT1 add white list DUT2 DUT3 DUT4 DUT5 - 2. DUT1 get white list - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_INIT_REBOOT2 - cmd set: - - "" - - - LOOP 4 1 "[0,1,2,4]" - - - "SSC SSC1 ble -W -z add -a c0:3e:72:bd:a8:c{%d}" - - ['P SSC1 C +BLE:AddWhiteList,Success'] - - - "SSC SSC1 ble -W -z get" - - ['P SSC1 C +BLE:GetWhiteList,OK,8'] -- ID: BTSTK_GAP_15003 - <<: *GAP_CASE - test point 2: BLE GAP white list test - summary: add white list twice - steps: | - 1. DUT1 add DUT2 into white list - 2. DUT1 add DUT2 into white list - 3. DUT1 get white list - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT_REBOOT2 - cmd set: - - "" - - - "SSC SSC1 ble -W -a -z add" - - ['P SSC1 C +BLE:AddWhiteList,Success'] - - - "SSC SSC1 ble -W -a -z add" - - ['P SSC1 C +BLE:AddWhiteList,Success'] - - - "SSC SSC1 ble -W -z get" - - ['P SSC1 C +BLE:GetWhiteList,OK,11'] -- ID: BTSTK_GAP_15004 - <<: *GAP_CASE - test point 2: BLE GAP white list test - summary: add 12 device to white list - steps: | - 1. DUT1 add 12 addresses into white list - 2. DUT1 get white list - 3. DUT1 add 13th address into white list - expected result: | - 1. succeed - 2. succeed - 3. failed - initial condition: BLE_INIT_REBOOT2 - cmd set: - - "" - - - LOOP 12 1 "['0','1','2','3','4','5','6','7','8','9','a','b']" - - '' - - - "SSC SSC1 ble -W -a c0:9b:0e:36:6d:7{%s} -z add" - - ['P SSC1 C +BLE:AddWhiteList,Success'] - - - "SSC SSC1 ble -W -z get" - - ['P SSC1 C +BLE:GetWhiteList,OK,0'] - - - "SSC SSC1 ble -W -a c0:9b:0e:36:6d:7c -z add" - - ['P SSC1 C +BLE:AddWhiteList,Fail'] -- ID: BTSTK_GAP_16001 - <<: *GAP_CASE - test point 2: BLE low power test - summary: test adv current and adv interval 32-32 - category: Performance - auto test: 'No' - steps: | - 1. DUT2 start adv - 2. test DUT2 current - expected result: | - 1. succeed - 2. succeed - cmd set: - - "BLEFunction/BLELowPower" - - - op_test = "start_adv" - - '' -- ID: BTSTK_GAP_16002 - <<: *GAP_CASE - test point 2: BLE low power test - summary: test scan current and scan window/interval 04 - category: Performance - auto test: 'No' - steps: | - 1. DUT2 start scan - 2. test DUT2 current - expected result: | - 1. succeed - 2. succeed - cmd set: - - "BLEFunction/BLELowPower" - - - op_test = "start_scan" - - "" -- ID: BTSTK_GAP_16003 - <<: *GAP_CASE - test point 2: BLE low power test - summary: test connect current and interval 6-6 - category: Performance - auto test: 'No' - steps: | - 1. DUT1 connect to DUT2 - 2. test DUT2 current - expected result: | - 1. succeed - 2. succeed - cmd set: - - "BLEFunction/BLELowPower" - - - op_test = "do_connect" - - "" diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_GATT.yml b/components/idf_test/integration_test/TC_IT_BTSTK_GATT.yml deleted file mode 100644 index b4a824d7b..000000000 --- a/components/idf_test/integration_test/TC_IT_BTSTK_GATT.yml +++ /dev/null @@ -1,1883 +0,0 @@ -.GATT_CASE: &GATT_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_CONN3 - test environment: SSC_T2_5 - execution time: 0 - module: BT Stack - sub module: GATT - version: v1 (2016-12-31) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.primary_service_discovery: &primary_service_discovery - LIST_MERGE: - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - -.included_service_connection: &included_primary_service_connection - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA0" - - ["R SSC2 C +GATTS:AddIncludedService,OK"] - - - "SSC SSC2 gatts -S -z add -p 0xA1" - - ["R SSC2 C +GATTS:StartService,OK,A001"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.included_second_service_connection: &included_second_service_connection - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA4" - - ["R SSC2 C +GATTS:StartService,OK,A004"] - - - "SSC SSC2 gatts -S -z load -p 0xA1" - - ["R SSC2 C +GATTS:CreateService,OK,A001"] - - - "SSC SSC1 gatts -S -z add -p 0xA1" - - ["R SSC1 C +GATTS:StartService,OK,A001"] - - - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA4" - - ["R SSC2 C +GATTS:AddIncludedService,OK"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.table_include_table_service: &table_include_table_service - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA5 -i 0xA2" - - ["R SSC2 C +GATTS:StartService,OK,A005"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.table_include_service: &table_include_service - LIST_MERGE: - - - "SSC SSC2 gatts -S -z load -p 0xA5 -i 0xA0" - - ["R SSC2 C +GATTS:StartService,OK,A005"] - - - SSC SSC1 gattc -F -r - - ['R SSC1 C +GATTC:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLECONN:GapConnect,OK,0010", "R SSC2 C +BLECONN:GapConnect"] - -.register_notify_c107: ®ister_notify_c107 - LIST_MERGE: - - - "SSC SSC1 gattc -N -z register -s 0xA000 -c 0xC107 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A000,C107"] - -.register_indicate_c108: ®ister_indicate_c108 - LIST_MERGE: - - - "SSC SSC1 gattc -N -z register -s 0xA000 -c 0xC108 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A000,C108"] - -.stop_adv: &stop_adv - LIST_MERGE: - - - "SSC SSC2 bleadv -D -z stop" - - ["R SSC2 C +BLEADV:Stop"] - -test cases: -- ID: BTSTK_GATT_60001 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set char value and value length longer than max length - allow fail: 1/2 - steps: | - 1. DUT2 create service - 2. DUT2 set value length - expected result: | - 1. succeed - 2. failed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z set -l 3" - - ["R SSC2 C +GATTS:SetAttrVal,ERROR"] -- ID: BTSTK_GATT_60002 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server get short char value and long char value - allow fail: 1/2 - steps: | - 1. DUT2 create service - 2. DUT2 get short char - 3. DUT2 get long char - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x01"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,256"] -- ID: BTSTK_GATT_60003 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set char value and get value - steps: | - 1. DUT2 create service - 2. DUT2 set short char value - 3. DUT2 get value - 4. DUT2 set long char value - 5. DUT2 get value - 6. DUT2 set long char value - 7. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x02"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -v 0x010203040506" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,6,0x010203040506"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -v 123456" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,6,0x313233343536"] -- ID: BTSTK_GATT_60004 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set special char value and get value - steps: | - 1. DUT2 create service - 2. DUT2 set char value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -v JKLJGFD*^" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,9,0x4A4B4C4A4746442A5E"] -- ID: BTSTK_GATT_60005 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set char value length=0 and get value - steps: | - 1. DUT2 create service - 2. DUT2 set char value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z set -l 0" - - ["R SSC2 C +GATTS:SetAttrVal,ERROR"] - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x01"] -- ID: BTSTK_GATT_60006 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server only set char value length and get value - steps: | - 1. DUT2 create service - 2. DUT2 set char value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - *stop_adv - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -l 5" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,5"] -- ID: BTSTK_GATT_60007 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: gattc write char value and gatts get - steps: | - 1. DUT1 do service discovery - 2. DUT1 write short char - 3. DUT2 get value - 4. DUT1 write longchar - 5. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C302", "R SSC1 C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC2 gatts -V -c 0xC302 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x01"] - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC304 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:Write,OK,0010,A002,C304"] - - - "SSC SSC2 gatts -V -c 0xC304 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,256"] -- ID: BTSTK_GATT_60008 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: gatts set char value and gattc read - steps: | - 1. DUT1 do service discovery - 2. DUT2 set short char value - 3. DUT1 read - 4. DUT2 set long char value - 5. DUT1 read - 6. DUT2 set long char length - 7. DU1 read - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC2 gatts -V -c 0xC300 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C300,1", "R SSC1 C +GATTC:Read,OK,0010,A002,C300"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,1", "R SSC1 C +GATTC:Read,OK,0010,A002,C301"] - - - "SSC SSC2 gatts -V -c 0xC301 -p 0xA2 -z set -l 5" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,5", "R SSC1 C +GATTC:Read,OK,0010,A002,C301"] -- ID: BTSTK_GATT_60009 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set descriptor value and value length longer than max length - steps: | - 1. DUT2 create service - 2. DUT2 set descriptor value length - expected result: | - 1. succeed - 2. failed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z set -l 3" - - ["R SSC2 C +GATTS:SetAttrVal,ERROR"] -- ID: BTSTK_GATT_60010 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server get short descriptor value - steps: | - 1. DUT2 create service - 2. DUT2 get short char - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x00"] -- ID: BTSTK_GATT_60011 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set descriptor value and get value - steps: | - 1. DUT2 create service - 2. DUT2 set descriptor value - 3. DUT2 get value - 4. DUT2 set descriptor value - 5. DUT2 get value - 6. DUT2 set descriptor value - 7. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x02"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -v 0x010203040506" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,6,0x010203040506"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -v 123456" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,6,0x313233343536"] -- ID: BTSTK_GATT_60012 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set special descriptor value and get value - steps: | - 1. DUT2 create service - 2. DUT2 set descriptor value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -v JKLJGFD*^" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,9,0x4A4B4C4A4746442A5E"] -- ID: BTSTK_GATT_60013 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server set descriptor value length=0 and get value - steps: | - 1. DUT2 create service - 2. DUT2 set descriptor value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z set -l 0" - - ["R SSC2 C +GATTS:SetAttrVal,ERROR"] - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x00"] -- ID: BTSTK_GATT_60014 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: GATT server only set descriptor value length and get value - steps: | - 1. DUT2 create service - 2. DUT2 set char value - 3. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_INIT3 - cmd set: - - "" - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -l 5" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,5"] -- ID: BTSTK_GATT_60015 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: gattc write descriptor value and gatts get - steps: | - 1. DUT1 do service discovery - 2. DUT1 write short descriptor - 3. DUT2 get value - 4. DUT1 write long descriptor - 5. DUT2 get value - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC300 -d 0x2901 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C300,2901", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C300,2901"] - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,1,0x01"] - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C301,2901"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z get" - - ["R SSC2 C +GATTS:GetAttrValue,256"] -- ID: BTSTK_GATT_60016 - <<: *GATT_CASE - test point 2: BLE GATT server get and set value - summary: gatts set value and gattc read - steps: | - 1. DUT1 do service discovery - 2. DUT2 set short descriptor value - 3. DUT1 read - 4. DUT2 set long descriptor value - 5. DUT1 read - 6. DUT2 set long descriptor length - 7. DU1 read - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC2 gatts -V -c 0xC300 -d 0x2901 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC300 -d 0x2901 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C300,2901,1", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C300,2901"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -v 0x02" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,2901,1", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C301,2901"] - - - "SSC SSC2 gatts -V -c 0xC301 -d 0x2901 -p 0xA2 -z set -l 5" - - ["R SSC2 C +GATTS:SetAttrVal,OK"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,2901,5", "R SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C301,2901"] -- ID: BTSTK_GATT_21007 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read auto reply short char created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read auto reply short char - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN3 - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C300,1", "R SSC1 C +GATTC:Read,OK,0010,A002,C300"] -- ID: BTSTK_GATT_21008 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read auto reply long char created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read auto reply long char - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C301,256", "P SSC1 C +GATTC:Read,OK,0010,A002,C301"] -- ID: BTSTK_GATT_21009 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read app reply short char created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read app reply short char - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC310 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C310,1", "P SSC1 C +GATTC:Read,OK,0010,A002,C310"] -- ID: BTSTK_GATT_21010 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read app reply long char created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read app reply long char - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC311 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C311,256", "P SSC1 C +GATTC:Read,OK,0010,A002,C311"] -- ID: BTSTK_GATT_21011 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read auto reply short descriptor created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read auto reply short descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC300 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C300,2901,1", "P SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C300,2901"] -- ID: BTSTK_GATT_21012 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read auto reply long descriptor created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read auto reply long descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C301,2901,256", "P SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C301,2901"] -- ID: BTSTK_GATT_21013 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read app reply short descriptor created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read app reply short descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC310 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C310,2901,1", "P SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C310,2901"] -- ID: BTSTK_GATT_21014 - <<: *GATT_CASE - test point 2: BLE GATT client read char and descriptor - summary: GATT client read app reply long descriptor created by table - steps: | - 1. DUT1 do discover - 2. DUT1 read app reply long descriptor - expected result: | - 1. succeed - 2. succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC311 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:ReadOnce,0010,A002,C311,2901,256", "P SSC1 C +GATTC:ReadDescriptor,OK,0010,A002,C311,2901"] -- ID: BTSTK_GATT_22010 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write with response to auto reply short char with response created by table - allow fail: 1/2 - steps: | - 1. DUT1 do service discovery - 2. GATT client write with response to auto reply short char with response created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -p 0x10 -r -v 0x01 -w 2" - - ["P SSC1 C +GATTC:WriteOnce,0010,A002,C302", "P SSC1 C +GATTC:Write,OK,0010,A002,C302"] -- ID: BTSTK_GATT_22011 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write without response to auto reply short char without response created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write without response to auto reply short char without response created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC303 -p 0x10 -v 0x01 -w 1 -r " - - - "P SSC1 C +GATTC:WriteOnce,0010,A002,C303" - - "P SSC2 C +GATTS:Write,OK,A002,C303" - - "P SSC1 C +GATTC:Write,OK,0010,A002,C303" -- ID: BTSTK_GATT_22012 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do execute to auto reply char created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do execute to auto reply char created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC304 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:Write,OK,0010,A002,C304"] -- ID: BTSTK_GATT_22013 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do cancel to auto reply char created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do cancel to auto reply char created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC304 -p 0x10 -l 256 -e 0 -r " - - ["P SSC1 C +GATTC:Write,OK,0010,A002,C304"] -- ID: BTSTK_GATT_22014 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to auto reply short descriptor created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write to auto reply short descriptor created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC300 -d 0x2901 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C300,2901", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C300,2901"] -- ID: BTSTK_GATT_22015 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to auto reply long descriptor created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write to auto reply long descriptor created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C301,2901"] -- ID: BTSTK_GATT_22016 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to auto reply long descriptor created by table and cancel - steps: | - 1. DUT1 do service discovery - 2. GATT client write to auto reply long descriptor created by table and cancel - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC301 -d 0x2901 -p 0x10 -l 256 -e 0 -r " - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C301,2901"] -- ID: BTSTK_GATT_22017 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write with response to app reply short char with response created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write with response to app reply short char with response created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC312 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C312", "R SSC1 C +GATTC:Write,OK,0010,A002,C312"] -- ID: BTSTK_GATT_22018 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write without response to app reply short char without response created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write without response to app reply short char without response created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC313 -p 0x10 -v 0x01 -w 1 -r " - - - "P SSC1 C +GATTC:WriteOnce,0010,A002,C313" - - "P SSC2 C +GATTS:Write,OK,A002,C313" - - "P SSC1 C +GATTC:Write,OK,0010,A002,C313" -- ID: BTSTK_GATT_22019 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do execute to app reply char created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do execute to app reply char created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC314 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:Write,OK,0010,A002,C314"] -- ID: BTSTK_GATT_22020 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client prepare write and do cancel to app reply char created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client prepare write and do cancel to app reply char created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC314 -p 0x10 -l 256 -e 0 -r " - - ["P SSC1 C +GATTC:Write,OK,0010,A002,C314"] -- ID: BTSTK_GATT_22021 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to app reply short descriptor created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write to app reply short descriptor created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC310 -d 0x2901 -p 0x10 -v 0x01 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C310,2901", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C310,2901"] -- ID: BTSTK_GATT_22022 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to app reply long descriptor created by table - steps: | - 1. DUT1 do service discovery - 2. GATT client write to app reply long descriptor created by table - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC311 -d 0x2901 -p 0x10 -l 256 -r " - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C311,2901"] -- ID: BTSTK_GATT_22023 - <<: *GATT_CASE - test point 2: BLE GATT client write char and descriptor - summary: GATT client write to app reply long descriptor created by table and cancel - steps: | - 1. DUT1 do service discovery - 2. GATT client write to app reply long descriptor created by table and cancel - expected result: | - 1. succeed - 2. write succeed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC311 -d 0x2901 -p 0x10 -l 256 -e 0 -r " - - ["P SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C311,2901"] -- ID: BTSTK_GATT_23005 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive notify on auto reply notify char created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on auto reply notification char and write to CCC - 3. DUT2 do notify - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv notify - initial condition: BLE_CONN3 - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C305"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC305 -d 0x2902 -p 0x10 -v 0x0100 -r " - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C305,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C305,2902"] - - - "SSC SSC2 gatts -N -c 0xC305 -p 0xA2 -v 0x01 -r " - - ["R SSC1 C +GATTC:Notification,0010,A002,C305,1"] -- ID: BTSTK_GATT_23006 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive indication on auto reply indication char created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on auto reply inidcation char and write to CCC - 3. DUT2 do indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv indication - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C306"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC306 -d 0x2902 -r -v 0x0002 -p 0x10" - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C306,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C306,2902"] - - - "SSC SSC2 gatts -I -c 0xC306 -p 0xA2 -v 0x01 -r " - - ["R SSC1 C +GATTC:Indication,0010,A002,C306,1"] -- ID: BTSTK_GATT_23007 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client can't receive notification/indication without write to CCC (auto service auto reply) - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on notify and inidcation char - 3. DUT2 do notify and indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 can recv notify and indication (this is aganist Spec, but a reasonable behavior in bluedroid) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C305"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C306"] - - - "SSC SSC2 gatts -N -c 0xC305 -p 0xA2 -v 0x01 -r " - - ["P SSC1 C +GATTC:Notification,0010,A002,C305,1"] - - - "SSC SSC2 gatts -I -c 0xC306 -p 0xA2 -v 0x01 -r " - - ["P SSC1 C +GATTC:Indication,0010,A002,C306,1"] -- ID: BTSTK_GATT_23008 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive notify on app reply notify char created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on app reply notification char and write to CCC - 3. DUT2 do notify - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv notify - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC315 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C315"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC315 -d 0x2902 -p 0x10 -r -v 0x0100" - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C315,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C315,2902"] - - - "SSC SSC2 gatts -N -c 0xC315 -p 0xA2 -v 0x01 -r " - - ["R SSC1 C +GATTC:Notification,0010,A002,C315,1"] -- ID: BTSTK_GATT_23009 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client receive indication on app reply indication char created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on app reply inidcation char and write to CCC - 3. DUT2 do indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 recv indication - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC316 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C316"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC316 -d 0x2902 -p 0x10 -r -v 0x0002" - - ["R SSC1 C +GATTC:WriteOnce,0010,A002,C316,2902", "R SSC1 C +GATTC:WriteDescriptor,OK,0010,A002,C316,2902"] - - - "SSC SSC2 gatts -I -c 0xC316 -p 0xA2 -v 0x01 -r " - - ["R SSC1 C +GATTC:Indication,0010,A002,C316,1"] -- ID: BTSTK_GATT_23010 - <<: *GATT_CASE - test point 2: BLE GATT client receive notify and indication - summary: GATT client can't receive notification/indication without write to CCC (auto service manual reply) - steps: | - 1. DUT1 do service discovery - 2. DUT1 register notify on notify and inidcation char - 3. DUT2 do notify and indication - expected result: | - 1. succeed - 2. succeed - 3. DUT1 can recv notify and indication (this is aganist Spec, but a reasonable behavior in bluedroid) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC315 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C315"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC316 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C316"] - - - "SSC SSC2 gatts -N -c 0xC315 -p 0xA2 -v 0x01 -r " - - ["P SSC1 C +GATTC:Notification,0010,A002,C315,1"] - - - "SSC SSC2 gatts -I -c 0xC316 -p 0xA2 -v 0x01 -r " - - ["P SSC1 C +GATTC:Indication,0010,A002,C316,1"] -- ID: BTSTK_GATT_24003 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid read - summary: GATT client read to a char without read property created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 read to auto reply char without read property create by table - 3. DUT1 read to app reply char without read property create by table - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC302 -p 0x10 -r " - - ["P SSC1 C +GATTC:Read,ERROR"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC312 -p 0x10 -r " - - ["P SSC1 C +GATTC:Read,ERROR"] -- ID: BTSTK_GATT_24004 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid read - summary: GATT client read to a descriptor without read property created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 read to auto reply descriptor without read property created by table - 3. DUT1 read to app reply descriptor without read property created by table - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC303 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:Read,ERROR"] - - - "SSC SSC1 gattc -R -z descriptor -s 0xA002 -c 0xC313 -d 0x2901 -p 0x10 -r " - - ["P SSC1 C +GATTC:Read,ERROR"] -- ID: BTSTK_GATT_25008 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write with response to a char without write property created by table - steps: | - 1. DUT1 do service discovery - 2. DUT1 write with response to auto reply char without write property - 3. DUT1 write with response to manual reply char without write property - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC300 -p 0x10 -r -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC310 -p 0x10 -r -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BTSTK_GATT_25009 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write without response to a char created by table without write property - steps: | - 1. DUT1 do service discovery - 2. DUT1 write without response to auto reply char created by table without write property - 3. DUT1 write without response to app reply char created by table without write property - expected result: | - 1. succeed - 2. succeed (write without response always succeed) - 3. succeed (write without response always succeed) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC300 -p 0x10 -r -l 1 -w 1" - - ["R SSC1 C +GATTC:Write,OK"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC300 -p 0x10 -r -l 1 -w 1" - - ["R SSC1 C +GATTC:Write,OK"] -- ID: BTSTK_GATT_25010 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write to a descriptor created by table without write property - steps: | - 1. DUT1 do service discovery - 2. DUT1 write to auto reply descriptor create by table without write property - 3. DUT1 write to app reply descriptor create by table without write property - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC302 -d 0x2901 -p 0x10 -r -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] - - - "SSC SSC1 gattc -W -z descriptor -s 0xA002 -c 0xC312 -d 0x2901 -p 0x10 -r -l 1" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BTSTK_GATT_25011 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client prepare write to a char created by table without write property - steps: | - 1. DUT1 do service discovery - 2. DUT1 prepare write to auto reply char created by table without write property - 3. DUT1 prepare write to app reply char created by table without write property - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC300 -p 0x10 -r -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] - - - "SSC SSC1 gattc -W -z longChar -s 0xA002 -c 0xC310 -p 0x10 -r -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BTSTK_GATT_25012 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client prepare write to a descriptor created by table without write property - steps: | - 1. DUT1 do service discovery - 2. DUT1 prepare write to auto reply descriptor created by table without write property - 3. DUT1 prepare write to app reply descriptor created by table without write property - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC302 -d 0x2901 -p 0x10 -r -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] - - - "SSC SSC1 gattc -W -z longDescriptor -s 0xA002 -c 0xC312 -d 0x2901 -p 0x10 -r -l 256" - - ["R SSC1 C +GATTC:Write,ERROR"] -- ID: BTSTK_GATT_25014 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write without response to a char created by table will send response - steps: | - 1. DUT1 do service discovery - 2. DUT1 write without response to auto reply char created by table will send response - 3. DUT1 write without response to app reply char created by table will send response - expected result: | - 1. succeed - 2. succeed (write without response always succeed) - 3. succeed (write without response always succeed) - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -p 0x10 -r -v 0x01 -w 1" - - ["R SSC1 C +GATTC:Write,OK"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -p 0x10 -r -v 0x01 -w 1" - - ["R SSC1 C +GATTC:Write,OK"] -- ID: BTSTK_GATT_25017 - <<: *GATT_CASE - test point 2: BLE GATT client do invalid write - summary: GATT client write short char value length longer than max length - initial condition: BLE_CONN3 - steps: | - 1. DUT1 do service discovery - 2. DUT1 write char value - expected result: | - 1. succeed - 2. failed - cmd set: - - "" - - *primary_service_discovery - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -l 2 -r " - - ["P SSC1 C +GATTC:Write,ERROR"] -- ID: BTSTK_GATT_26003 - <<: *GATT_CASE - test point 2: BLE GATT config mtu - summary: GATT client and server config different mtu size - steps: | - 1. client set mtu size 365 and server set mtu size 261 - 2. client config mtu - expected result: - 1. succeed - 2. succeed - cmd set: - - "" - - - "SSC SSC1 bleconn -D -z all" - - ["P SSC1 C +BLECONN:GapDisconnect,OK", "P SSC2 C +BLECONN:GapDisconnect,OK"] - - - "SSC SSC1 gattc -S -m 365" - - ["R SSC1 C +GATTC:OK"] - - - "SSC SSC2 gatts -C -m 261" - - ["R SSC2 C +GATTS:OK"] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['R SSC1 C +BLECONN:GapConnect,OK', 'R SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 gattc -C -r " - - ["R SSC1 C +GATTC:OK","P SSC[1-2] C ConfigMTU,OK,261"] -- ID: BTSTK_GATT_30001 - <<: *GATT_CASE - test point 2: BLE GATT multi connection service discovery test - summary: do primary service discovery when DUT1 role is master, connected with 4 slaves - steps: | - 1. DUT1 do primary service discovery on DUT[2-5] - expected result: | - 1. succeed - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 4 1 "[2,3,4,5]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] -- ID: BTSTK_GATT_30002 - <<: *GATT_CASE - test point 2: BLE GATT multi connection service discovery test - summary: do primary service discovery when DUT1 is slave, connected by 4 masters - steps: | - 1. DUT[2-5] do primary service discovery - expected result: | - 1. succeed - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Discover,OK"] -- ID: BTSTK_GATT_30003 - <<: *GATT_CASE - test point 2: BLE GATT multi connection service discovery test - summary: do primary service discovery when DUT1 connect to DUT[2-3] and connected by DUT[4-5] - steps: | - 1. DUT1 do primary service discovery for DUT[2-3] - 2. DUT[4-5] do primary service discovery for DUT1 - expected result: | - 1. succeed - 2. succeed - initial condition: BLE_CONN7 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 2 1 "[2,3]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC[4-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Discover,OK"] -- ID: BTSTK_GATT_31001 - <<: *GATT_CASE - test point 2: BLE GATT multi connection read test - summary: do read when DUT1 role is master, connected with 4 slaves - steps: | - 1. do primary service discovery - 2. do read long and read short - 3. loop step 1-2 for all DUTs - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 4 3 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C300,1"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,256"] -- ID: BTSTK_GATT_31002 - <<: *GATT_CASE - test point 2: BLE GATT multi connection read test - summary: do read when DUT1 is slave, connected by 4 masters - steps: | - 1. do primary service discovery on DUT[2-5] - expected result: | - 1. succeed - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Discover,OK"] - - - "SSC SSC[2-5] gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:ReadOnce,0010,A002,C300,1"] - - - "SSC SSC[2-5] gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:ReadOnce,0010,A002,C301,256"] -- ID: BTSTK_GATT_31003 - <<: *GATT_CASE - test point 2: BLE GATT multi connection read test - summary: do read when DUT1 connect to DUT[2-3] and connected by DUT[4-5] - steps: | - 1. DUT1 do primary service discovery for DUT[2-3] - 2. DUT1 do read on DUT[2-3] - 3. DUT[4-5] do primary service discovery for DUT1 - 4. DUT[4-5] do read on DUT1 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_CONN7 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 2 3 "[2,3]" "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C300,1"] - - - "SSC SSC1 gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC1 C +GATTC:ReadOnce,0010,A002,C301,256"] - - - "SSC SSC[4-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Discover,OK"] - - - "SSC SSC[4-5] gattc -R -z char -s 0xA002 -c 0xC300 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:ReadOnce,0010,A002,C300,1"] - - - "SSC SSC[4-5] gattc -R -z char -s 0xA002 -c 0xC301 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:ReadOnce,0010,A002,C301,256"] -- ID: BTSTK_GATT_32001 - <<: *GATT_CASE - test point 2: BLE GATT multi connection write test - summary: do write when DUT1 role is master, connected with 4 slaves - steps: | - 1. do primary service discovery - 2. do write long and write short - 3. loop step 1-2 for all DUTs - expected result: | - 1. succeed - 2. succeed - 3. succeed - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 4 3 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -l 1 -p 0x10 -r " - - ["R SSC1 C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC304 -l 256 -p 0x10 -r " - - ["R SSC1 C +GATTC:Write,OK,0010,A002,C304"] -- ID: BTSTK_GATT_32002 - <<: *GATT_CASE - test point 2: BLE GATT multi connection write test - summary: do write when DUT1 is slave, connected by 4 masters - steps: | - 1. do primary service discovery on DUT[2-5] - expected result: | - 1. succeed - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Discover,OK"] - - - "SSC SSC[2-5] gattc -W -z char -s 0xA002 -c 0xC302 -l 1 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC[2-5] gattc -W -z char -s 0xA002 -c 0xC304 -l 256 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Write,OK,0010,A002,C304"] -- ID: BTSTK_GATT_32003 - <<: *GATT_CASE - test point 2: BLE GATT multi connection write test - summary: do write when DUT1 connect to DUT[2-3] and connected by DUT[4-5] - steps: | - 1. DUT1 do primary service discovery for DUT[2-3] - 2. DUT1 do write on DUT[2-3] - 3. DUT[4-5] do primary service discovery for DUT1 - 4. DUT[4-5] do write on DUT1 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: BLE_CONN7 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 2 3 "[2,3]" "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC302 -l 1 -p 0x10 -r " - - ["R SSC1 C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC1 gattc -W -z char -s 0xA002 -c 0xC304 -l 256 -p 0x10 -r " - - ["R SSC1 C +GATTC:Write,OK,0010,A002,C304"] - - - "SSC SSC[4-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Discover,OK"] - - - "SSC SSC[4-5] gattc -W -z char -s 0xA002 -c 0xC302 -l 1 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Write,OK,0010,A002,C302"] - - - "SSC SSC[4-5] gattc -W -z char -s 0xA002 -c 0xC304 -l 256 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Write,OK,0010,A002,C304"] -- ID: BTSTK_GATT_33001 - <<: *GATT_CASE - test point 2: BLE GATT multi connection notify test - summary: do notify when DUT1 role is master, connected with 4 slaves - steps: | - 1. do primary service discovery - 2. do register nofity for char - 3. do notify on DUT[2-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT1 receive notification on DUT[2-5] - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 4 3 "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C305"] - - - "SSC SSC{%d} gatts -N -c 0xC305 -l 1 -p 0xA2 -r " - - ['P SSC1 RE "\+GATTC:Notification,0010,A002,C305,1,%%s"%%()'] -- ID: BTSTK_GATT_33002 - <<: *GATT_CASE - test point 2: BLE GATT multi connection notify test - summary: do notify when DUT1 is slave, connected by 4 masters - steps: | - 1. do primary service discovery on DUT[2-5] - 2. DUT[2-5] do register notify - 3. DUT1 do notify to DUT[2-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT[2-5] receive notification - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Discover,OK"] - - - "SSC SSC[2-5] gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:RegNotify,OK,0010,A002,C305"] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - [''] - - - "SSC SSC1 gatts -N -c 0xC305 -l 1 -p 0xA2 -r " - - ['P SSC{%d} RE "\+GATTC:Notification,0010,A002,C305,1,%%s"%%()'] -- ID: BTSTK_GATT_33003 - <<: *GATT_CASE - test point 2: BLE GATT multi connection notify test - summary: do notify when DUT1 connect to DUT[2-3] and connected by DUT[4-5] - steps: | - 1. DUT1 do primary service discovery for DUT[2-3] - 2. DUT1 register notify - 3. DUT[2-3] send notify to DUT1 - 4. DUT[4-5] do primary service discovery for DUT1 - 5. DUT[4-5] register notify - 6. DUT1 send notofy to DUT[4-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT1 receive notify from DUT[2-3] - 4. succeed - 5. succeed - 6. DUT[4-5] receive notify - initial condition: BLE_CONN7 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 2 2 "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C305"] - - - "SSC SSC[2-3] gatts -N -c 0xC305 -l 1 -p 0xA2 -r " - - ['P SSC1 RE "\+GATTC:Notification,0010,A002,C305,1,%%s"%%()'] - - - "SSC SSC[4-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Discover,OK"] - - - "SSC SSC[4-5] gattc -N -z register -s 0xA002 -c 0xC305 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:RegNotify,OK,0010,A002,C305"] - - - LOOP 2 1 "[4,5]" "[4,5]" - - [''] - - - "SSC SSC1 gatts -N -c 0xC305 -l 1 -p 0xA2 -r " - - ['P SSC{%d} RE "\+GATTC:Notification,0010,A002,C305,1,%%s"%%()'] -- ID: BTSTK_GATT_34001 - <<: *GATT_CASE - test point 2: BLE GATT multi connection indicate test - summary: do indicate when DUT1 role is master, connected with 4 slaves - steps: | - 1. do primary service discovery - 2. do register indication for char - 3. do indicate on DUT[2-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT1 receive indication on DUT[2-5] - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 4 2 "[2,3,4,5]" "[2,3,4,5]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C306"] - - - "SSC SSC[2-5] gatts -I -c 0xC306 -l 1 -p 0xA2 -r " - - ['P SSC1 RE "\+GATTC:Indication,0010,A002,C306,1,%%s"%%()'] -- ID: BTSTK_GATT_34002 - <<: *GATT_CASE - test point 2: BLE GATT multi connection indicate test - summary: do indicate when DUT1 is slave, connected by 4 masters - steps: | - 1. do primary service discovery on DUT[2-5] - 2. DUT[2-5] do register indication - 3. DUT1 do indicate to DUT[2-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT[2-5] receive indication - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - "SSC SSC[2-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:Discover,OK"] - - - "SSC SSC[2-5] gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC[2-5] C +GATTC:RegNotify,OK,0010,A002,C306"] - - - LOOP 4 1 "[2,3,4,5]" "[2,3,4,5]" - - [''] - - - "SSC SSC1 gatts -I -c 0xC306 -l 1 -p 0xA2 -r " - - ['P SSC{%d} RE "\+GATTC:Indication,0010,A002,C306,1,%%s"%%()'] -- ID: BTSTK_GATT_34003 - <<: *GATT_CASE - test point 2: BLE GATT multi connection indicate test - summary: do indicate when DUT1 connect to DUT[2-3] and connected by DUT[4-5] - steps: | - 1. DUT1 do primary service discovery for DUT[2-3] - 2. DUT1 register indication - 3. DUT[2-3] send indicate to DUT1 - 4. DUT[4-5] do primary service discovery for DUT1 - 5. DUT[4-5] register indication - 6. DUT1 send indicate to DUT[4-5] - expected result: | - 1. succeed - 2. succeed - 3. DUT1 receive indication from DUT[2-3] - 4. succeed - 5. succeed - 6. DUT[4-5] receive indication - initial condition: BLE_CONN7 - test environment: SSC_T5_1 - allow fail: 3/5 - cmd set: - - "" - - - LOOP 2 2 "[2,3]" "[2,3]" - - "" - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - - - "SSC SSC1 gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC1 C +GATTC:RegNotify,OK,0010,A002,C306"] - - - "SSC SSC[2-3] gatts -I -c 0xC306 -l 1 -p 0xA2 -r " - - ['P SSC1 RE "\+GATTC:Indication,0010,A002,C306,1,%%s"%%()'] - - - "SSC SSC[4-5] gattc -D -z primaryService -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:Discover,OK"] - - - "SSC SSC[4-5] gattc -N -z register -s 0xA002 -c 0xC306 -p 0x10 -r " - - ["R SSC[4-5] C +GATTC:RegNotify,OK,0010,A002,C306"] - - - LOOP 2 1 "[4,5]" "[4,5]" - - [''] - - - "SSC SSC1 gatts -I -c 0xC306 -l 1 -p 0xA2 -r " - - ['P SSC{%d} RE "\+GATTC:Indication,0010,A002,C306,1,%%s"%%()'] -- ID: BTSTK_GATT_50001 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT read char performance test - initial condition: BLE_CONN3 - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do read char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEGATTPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "read" - - "" - - - op_char = "0xC301" - - "" -- ID: BTSTK_GATT_50002 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT write char performance test - initial condition: BLE_CONN3 - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEGATTPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "write" - - "" - - - op_char = "0xC317" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_GATT_50003 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT notify performance test - initial condition: BLE_CONN3 - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEGATTPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "notify" - - "" - - - op_char = "0xC305" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_GATT_50004 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT indicate performance test - initial condition: BLE_CONN3 - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEGATTPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "indicate" - - "" - - - op_char = "0xC306" - - "" - - - op_len = 256 - - "" -- ID: BTSTK_GATT_50005 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT master connect 4 slave and read char performance test - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "read" - - "" - - - op_char = "0xC301" - - "" - - - op_len = 256 - - "" - - - master_duts = ["SSC1"] - - "" - - - slave_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" -- ID: BTSTK_GATT_50006 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT 4 master connect 1 slave and read char performance test - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "read" - - "" - - - op_char = "0xC301" - - "" - - - op_len = 256 - - "" - - - master_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" - - - slave_duts = ["SSC1"] - - "" -- ID: BTSTK_GATT_50007 - <<: *GATT_CASE - Test App: SSC_BLE, SSC_PSRAM - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT master connect 4 slave and write char performance test - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "write" - - "" - - - op_char = "0xC317" - - "" - - - op_len = 490 - - "" - - - master_duts = ["SSC1"] - - "" - - - slave_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" -- ID: BTSTK_GATT_50008 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: GATT 4 master connect 1 slave and write char performance test - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "write" - - "" - - - op_char = "0xC317" - - "" - - - op_len = 490 - - "" - - - master_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" - - - slave_duts = ["SSC1"] - - "" -- ID: BTSTK_GATT_50009 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: notify performance test when GATT master connects to 4 slaves - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "notify" - - "" - - - op_char = "0xC305" - - "" - - - op_len = 490 - - "" - - - master_duts = ["SSC1"] - - "" - - - slave_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" -- ID: BTSTK_GATT_50010 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: notify performance test when GATT 4 masters connect to 1 slave - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "notify" - - "" - - - op_char = "0xC305" - - "" - - - op_len = 490 - - "" - - - master_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" - - - slave_duts = ["SSC1"] - - "" -- ID: BTSTK_GATT_50011 - Test App: SSC_BLE, SSC_PSRAM - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: indicate performance test when GATT master connects 4 slaves - initial condition: BLE_CONN5 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "indicate" - - "" - - - op_char = "0xC306" - - "" - - - op_len = 256 - - "" - - - master_duts = ["SSC1"] - - "" - - - slave_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" -- ID: BTSTK_GATT_50012 - <<: *GATT_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE GATT performance test - summary: indicate performance test when GATT 4 masters connect 1 slave - initial condition: BLE_CONN6 - test environment: SSC_T5_1 - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLEMultiPerformance" - - - test_time = 120 - - "" - - - mtu = 512 - - "" - - - gatt_op = "indicate" - - "" - - - op_char = "0xC306" - - "" - - - op_len = 256 - - "" - - - master_duts = ["SSC2", "SSC3", "SSC4", "SSC5"] - - "" - - - slave_duts = ["SSC1"] - - "" diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_MISC.yml b/components/idf_test/integration_test/TC_IT_BTSTK_MISC.yml deleted file mode 100644 index 0df8c258e..000000000 --- a/components/idf_test/integration_test/TC_IT_BTSTK_MISC.yml +++ /dev/null @@ -1,529 +0,0 @@ -.MISC_CASE: &MISC_CASE - SDK: ESP32_IDF - Test App: SSC_BLE_WIFI - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_DEINIT1 - test environment: SSC_T1_1 - execution time: 0 - module: BT Stack - sub module: Misc - version: v1 (2016-12-31) - CI ready: 'Yes' - level: Integration - allow fail: '' - -test cases: -- ID: BTSTK_MISC_0101 - <<: *MISC_CASE - test point 2: bt host init and enable - summary: correct host init and deinit flow - steps: | - 1. disable and deinit bt - 2. init bt - 3. deinit bt - 4. init and enable bt - 5. disable and deinit bt - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - - "SSC SSC1 bt -D -z stop" - - ["R SSC1 C +BT"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z start" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z stop" - - ["R SSC1 C +BT:OK"] -- ID: BTSTK_MISC_0102 - <<: *MISC_CASE - test point 2: bt host init and enable - summary: incorrect host deinit disable flow - steps: | - 1. disable and deinit bt - 2. init and enable bt - 3. deinit bt - 4. disable bt - 5. disable bt - 6. deinit bt - 7. deinit bt - 8. disable bt - expected result: | - 1. succeed - 2. succeed - 3. fail - 4. succeed - 5. fail - 6. succeed - 7. fail - 8. fail - cmd set: - - "" - - - "SSC SSC1 bt -D -z stop" - - ["R SSC1 C +BT"] - - - "SSC SSC1 bt -D -z start" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z disable" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z disable" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z disable" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_0103 - <<: *MISC_CASE - test point 2: bt host init and enable - summary: incorrect host init enable flow - steps: | - 1. disable and deinit bt - 2. enable bt - 3. init bt - 4. init bt - 5. enable bt - 6. enable bt - 7. init bt - expected result: | - 1. succeed - 2. fail - 3. succeed - 4. fail - 5. succeed - 6. fail - 7. fail - cmd set: - - "" - - - "SSC SSC1 bt -D -z stop" - - ["R SSC1 C +BT"] - - - "SSC SSC1 bt -D -z enable" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z enable" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z enable" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_0201 - <<: *MISC_CASE - test point 2: bt controller init test - summary: bt controller init test - steps: | - 1. bt controller init - expected result: | - 1. OK - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] -- ID: BTSTK_MISC_0202 - <<: *MISC_CASE - test point 2: bt controller deinit test - summary: bt controller deinit test - steps: | - 1. bt controller init - 2. bt controller deinit - expected result: | - 1. OK - 2. OK - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:OK"] -- ID: BTSTK_MISC_0203 - <<: *MISC_CASE - test point 2: bt host init test - summary: bt host init test - steps: | - 1. bt controller init - 2. bt controller enable - 3. bt host init - expected result: | - 1. +BTC:OK - 2. +BTC:OK - 3. +BT:OK - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] -- ID: BTSTK_MISC_0204 - <<: *MISC_CASE - test point 2: bt host deinit test - summary: bt host deinit test - steps: | - 1. bt controller init - 2. bt controller enable - 3. bt host init - 4. bt host deinit - expected result: | - 1. OK - 2. OK - 3. OK - 4. OK - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:OK"] -- ID: BTSTK_MISC_0301 - <<: *MISC_CASE - test point 2: heap size unchanged after bt controller stop - summary: heap size unchanged after bt controller stop - steps: | - 1.get current heap size - 2.bt controller init - 3.enable bt controller - 4.bt host init - 5.enable bt host - 6.disable bt host - 7.bt host deinit - 8.disable bt controller - 9.bt controller deinit - 10.check current heap size - expected result: | - 1. +FREEHEAP - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.heap size unchanged - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 ram -Q" - - ['R SSC1 A :\+FREEHEAP:(\d+)\r\n'] - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z enable" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z disable" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z deinit" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 btc -D -z disable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 ram -Q" - - ['R SSC1 P '] -- ID: BTSTK_MISC_0401 - <<: *MISC_CASE - test point 2: bt controller init and enable - summary: incorrect controller init enable flow - steps: | - 1. disable and deinit btc - 2. enable btc - 3. init btc - 4. init btc - 5. enable btc - 6. enable btc - 7. init btc - expected result: | - 1. succeed - 2. fail - 3. succeed - 4. fail - 5. succeed - 6. fail - 7. fail - initial condition: WIFIBTSTOP - cmd set: - - "" - - - "SSC SSC1 btc -D -z stop" - - ["R SSC1 C +BTC"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:ERROR"] - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:ERROR"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:ERROR"] - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:ERROR"] -- ID: BTSTK_MISC_0402 - <<: *MISC_CASE - test point 2: bt controller init and enable - summary: correct controller init and deinit flow - steps: | - 1. disable and deinit btc - 2. init btc - 3. deinit btc - 4. init and enable btc - 5. disable and deinit btc - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - cmd set: - - "" - - - "SSC SSC1 btc -D -z stop" - - ["R SSC1 C +BTC"] - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z start" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z stop" - - ["R SSC1 C +BTC:OK"] -- ID: BTSTK_MISC_0403 - <<: *MISC_CASE - test point 2: bt controller init and enable - summary: incorrect controller deinit disable flow - steps: | - 1. disable and deinit btc - 2. init and enable btc - 3. deinit btc - 4. disable btc - 5. disable btc - expected result: | - 1. succeed - 2. succeed - 3. fail - 4. succeed - 5. fail - cmd set: - - "" - - - "SSC SSC1 btc -D -z stop" - - ["R SSC1 C +BTC"] - - - "SSC SSC1 btc -D -z start" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z deinit" - - ["R SSC1 C +BTC:ERROR"] - - - "SSC SSC1 btc -D -z disable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z disable" - - ["R SSC1 C +BTC:ERROR"] -- ID: BTSTK_MISC_0501 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT memory - steps: | - 1. DUT1 release BT mem - 2. DUT1 init and enable btc - expected result: | - 1. succeed - 2. fail - initial condition: BTC_DEINIT1 - cmd set: - - "" - - - "SSC SSC1 bt -R -m 1" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 btc -D -z start -m 2" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z start -m 1" - - ["R SSC1 C +BTC:ERROR"] -- ID: BTSTK_MISC_0502 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BLE memory - steps: | - 1. DUT1 release BT mem - 2. DUT1 init and enable btc - expected result: | - 1. succeed - 2. fail - initial condition: BTC_DEINIT1 - cmd set: - - "" - - - "SSC SSC1 bt -R -m 2" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 btc -D -z start -m 1" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z start -m 2" - - ["R SSC1 C +BTC:ERROR"] -- ID: BTSTK_MISC_0503 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT and BLE memory - steps: | - 1. DUT1 release BT mem - 2. DUT1 init and enable btc - expected result: | - 1. succeed - 2. fail - initial condition: BTC_DEINIT1 - cmd set: - - "" - - - "SSC SSC1 bt -R -m 3" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 btc -D -z start -m 3" - - ["R SSC1 C +BTC:ERROR"] -- ID: BTSTK_MISC_0504 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT memory after bt controller init - initial condition: BTC_DEINIT1 - steps: | - 1. DUT1 init bt controller - 2. DUT1 release BT memory - 3. DUT1 release BLE memory - 4. DUT1 release BT and BLE memory - expected result: | - 1. succeed - 2. fail - 3. fail - 4. fail - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 bt -R -m 1" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 2" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 3" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_0505 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT memory after bt controller enable and bluedriod disable - initial condition: BTC_DEINIT1 - steps: | - 1. DUT1 init and enable bt controller - 2. DUT1 release BT memory - 3. DUT1 release BLE memory - 4. DUT1 release BT and BLE memory - expected result: | - 1. succeed - 2. fail - 3. fail - 4. fail - cmd set: - - "" - - - "SSC SSC1 btc -D -z init" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 btc -D -z enable" - - ["R SSC1 C +BTC:OK"] - - - "SSC SSC1 bt -R -m 1" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 2" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 3" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_0506 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT memory after bt controller enable and bluedriod init - steps: | - 1. DUT1 init bluedriod - 2. DUT1 release BT memory - 3. DUT1 release BLE memory - 4. DUT1 release BT and BLE memory - expected result: | - 1. succeed - 2. fail - 3. fail - 4. fail - cmd set: - - "" - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -R -m 1" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 2" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 3" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_0507 - <<: *MISC_CASE - test point 2: bt mem release - summary: release BT memory after bt controller enable and bluedriod enable - steps: | - 1. DUT1 init and enable bluedriod - 2. DUT1 release BT memory - 3. DUT1 release BLE memory - 4. DUT1 release BT and BLE memory - expected result: | - 1. succeed - 2. fail - 3. fail - 4. fail - cmd set: - - "" - - - "SSC SSC1 bt -D -z init" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -D -z enable" - - ["R SSC1 C +BT:OK"] - - - "SSC SSC1 bt -R -m 1" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 2" - - ["R SSC1 C +BT:ERROR"] - - - "SSC SSC1 bt -R -m 3" - - ["R SSC1 C +BT:ERROR"] -- ID: BTSTK_MISC_5001 - <<: *MISC_CASE - category: Performance - test point 1: performance + stress - test point 2: BT Controller Performance test - summary: bt controller init and deinit Performance test - execution time: 6 - steps: | - 1.get current heap size - 2.bt controller init - 3.enable bt controller - 4.bt host init - 5.enable bt host - 6.disable bt host - 7.bt host deinit - 8.disable bt controller - 9.bt controller deinit - 10.loop step1 to step 9 - expected result: | - 1. +FREEHEAP - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.heap size unchanged - cmd set: - - "BLEStress/BLEInitDeinitPerformance" - - - "test_time = 420" - - "" diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml b/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml deleted file mode 100644 index bf81c2c83..000000000 --- a/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml +++ /dev/null @@ -1,2188 +0,0 @@ -.SMP_CASE: &SMP_CASE - SDK: ESP32_IDF - Test App: SSC_BLE - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: BLE_INIT_SMP - test environment: SSC_T2_5 - execution time: 0 - module: BT Stack - sub module: SMP - version: v1 (2017-05-26) - CI ready: 'Yes' - level: Integration - allow fail: '' - -.just_work_pair: &just_work_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.slave_passkey_entry_pair: &slave_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.master_passkey_entry_pair: &master_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:PassKeyReq', 'P SSC2 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC1 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.both_side_passkey_entry_pair: &both_side_passkey_entry_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1,2] C +BLESMP:PassKeyReq'] - - - "SSC SSC[1,2] blesmp -K -r -a 1 -k 123456" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.numberic_comparision_pair: &numberic_comparision_pair - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1-2] blesmp -C -r -a 1" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - -.check_connection: &check_connection - LIST_MERGE: - - - "SSC SSC1 gattc -D -z primaryService -p 0x10 -r " - - ["R SSC1 C +GATTC:Discover,OK"] - -.disconnect: &disconnect - LIST_MERGE: - - - "SSC SSC1 bleconn -D -z all" - - ['P SSC1 C +BLECONN:GapDisconnect,OK', 'P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['P SSC2 C +BLEADV:OK'] - -.connect: &connect - LIST_MERGE: - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - -.config_just_work: &config_just_work - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_master_passkey_entry: &config_master_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - -.config_slave_passkey_entry: &config_slave_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_both_side_passkey_entry: &config_both_side_passkey_entry - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x02" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_numberic_comparision: &config_numberic_comparision - LIST_MERGE: - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - -.config_bond_device: &config_bond_device - LIST_MERGE: - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - -test cases: -- ID: BTSTK_SMP_01001 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity None + None test - steps: | - 1. set sec properity None on initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_01002 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity None + SC test - steps: | - 1. set sec properity None on initiator and SC on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_01003 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity None + MITM test - steps: | - 1. set sec properity None on initiator and MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01004 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity None + SC_MITM test - steps: | - 1. set sec properity None on initiator and SC_MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01005 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC + None test - steps: | - 1. set sec properity SC only on initiator and None on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_01006 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC + SC test - steps: | - 1. set sec properity SC on initiator and SC on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_01007 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC + MITM test - steps: | - 1. set sec properity SC on initiator and MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01008 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC + SC_MITM test - steps: | - 1. set sec properity SC on initiator and SC_MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use numberic comparision and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_01009 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity MITM + None test - steps: | - 1. set sec properity MITM on initiator and None on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01010 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity MITM + SC test - steps: | - 1. set sec properity MITM on initiator and SC on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - allow fail: '' - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01011 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity MITM + MITM test - steps: | - 1. set sec properity MITM on initiator and MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01012 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity MITM + SC_MITM test - steps: | - 1. set sec properity MITM on initiator and SC_MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01013 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC_MITM + None test - steps: | - 1. set sec properity SC_MITM on initiator and SC on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01014 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC_MITM + SC test - steps: | - 1. set sec properity SC_MITM on initiator and SC on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use numberic comparision and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x08" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_01015 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC_MITM + MITM test - steps: | - 1. set sec properity SC_MITM on initiator and MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_01016 - <<: *SMP_CASE - test point 2: BLE SMP sec properity test - summary: BLE SMP sec properity SC_MITM + SC_MITM test - steps: | - 1. set sec properity SC_MITM on initiator and SC_MITM on responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2, do pair procedure - 4. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use numberic comparision and pair succeed - 4. succeed - cmd set: - - "" - - - "SSC SSC1 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC2 C +BLESMP:OK'] - - - "SSC SSC[1-2] blesmp -S -z IOCAP -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_02001 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayOnly + DisplayOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayOnly on initiator and DisplayOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayOnly on initiator and DisplayOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just work and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02002 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayOnly + DisplayYesNo test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayOnly on initiator and DisplayYesNo on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayOnly on initiator and DisplayYesNo on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just work and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02003 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayOnly + KeyboardOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayOnly on initiator and KeyboardOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayOnly on initiator and KeyboardOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (initiator displays, responder inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02004 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayOnly + NoInputNoOutput test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayOnly on initiator and NoInputNoOutput on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayOnly on initiator and NoInputNoOutput on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02005 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayOnly + KeyboardDisplay test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayOnly on initiator and KeyboardDisplay on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayOnly on initiator and KeyboardDisplay on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (initiator displays, responder inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x00" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02006 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayYesNo + DisplayOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayYesNo on initiator and DisplayOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayYesNo on initiator and DisplayOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just work and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02007 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayYesNo + DisplayYesNo test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayYesNo on initiator and DisplayYesNo on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayYesNo on initiator and DisplayYesNo on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just work and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use numberic comparision and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_02008 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayYesNo + KeyboardOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayYesNo on initiator and KeyboardOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayYesNo on initiator and KeyboardOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (initiator displays, responder inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02009 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayYesNo + NoInputNoOutput test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayYesNo on initiator and NoInputNoOutput on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayYesNo on initiator and NoInputNoOutput on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02010 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities DisplayYesNo + KeyboardDisplay test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to DisplayYesNo on initiator and KeyboardDisplay on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to DisplayYesNo on initiator and KeyboardDisplay on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use numberic comparision and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x01" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_02011 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardOnly + DisplayOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardOnly on initiator and DisplayOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardOnly on initiator and DisplayOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (responder displays, initiator inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (responder displays, initiator inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02012 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardOnly + DisplayYesNo test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardOnly on initiator and DisplayYesNo on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardOnly on initiator and DisplayYesNo on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (responder displays, initiator inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (responder displays, initiator inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02013 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardOnly + KeyboardOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardOnly on initiator and KeyboardOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardOnly on initiator and KeyboardOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator and responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (initiator and responder inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *both_side_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *both_side_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02014 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardOnly + NoInputNoOutput test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardOnly on initiator and NoInputNoOutput on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardOnly on initiator and NoInputNoOutput on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02015 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardOnly + KeyboardDisplay test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardOnly on initiator and KeyboardDisplay on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardOnly on initiator and KeyboardDisplay on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (responder displays, initiator inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (responder displays, initiator inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x02" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02016 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities NoInputNoOutput + DisplayOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to NoInputNoOutput on initiator and DisplayOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to NoInputNoOutput on initiator and DisplayOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02017 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities NoInputNoOutput + DisplayYesNo test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to NoInputNoOutput on initiator and DisplayYesNo on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to NoInputNoOutput on initiator and DisplayYesNo on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02018 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities NoInputNoOutput + KeyboardOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to NoInputNoOutput on initiator and KeyboardOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to NoInputNoOutput on initiator and KeyboardOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02019 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities NoInputNoOutput + NoInputNoOutput test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to NoInputNoOutput on initiator and NoInputNoOutput on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to NoInputNoOutput on initiator and NoInputNoOutput on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02020 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities NoInputNoOutput + KeyboardDisplay test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to NoInputNoOutput on initiator and KeyboardDisplay on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to NoInputNoOutput on initiator and KeyboardDisplay on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x03" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02021 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardDisplay + DisplayOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and DisplayOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardDisplay on initiator and DisplayOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (responder displays, initiator inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (responder displays, initiator inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x00" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02022 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardDisplay + DisplayYesNo test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and DisplayYesNo on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardDisplay on initiator and DisplayYesNo on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (responder displays, initiator inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use numberic comparision and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *master_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x01" - - ['P SSC2 C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_02023 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardDisplay + KeyboardOnly test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and KeyboardOnly on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardDisplay on initiator and KeyboardOnly on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use passkey entry (initiator displays, responder inputs) and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x02" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection -- ID: BTSTK_SMP_02024 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardDisplay + NoInputNoOutput test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and NoInputNoOutput on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardDisplay on initiator and NoInputNoOutput on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use just works and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use just works and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x03" - - ['P SSC2 C +BLESMP:OK'] - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_02025 - <<: *SMP_CASE - test point 2: BLE SMP IO Capabilities test - summary: BLE SMP IO Capabilities KeyboardDisplay + KeyboardDisplay test - allow fail: 2/3 - steps: | - 1. set sec properity MITM on both initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and KeyboardDisplay on responder - 3. DUT1 connect to DUT2, do pair (if required) - 4. do service discovery - 5. disconnect - 6. set sec properity SC_MITM on both initiator and responder - 7. set IOCAP to KeyboardDisplay on initiator and KeyboardDisplay on responder - 8. DUT1 connect to DUT2, do pair (if required) - 9. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. use passkey entry (initiator displays, responder inputs) and pair succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. use numberic comparision and pair succeed - 9. succeed - cmd set: - - "" - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x04" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *slave_passkey_entry_pair - - *check_connection - - *disconnect - - - "SSC SSC[1-2] blesmp -S -z AuthReqMode -v 0x0C" - - ['P SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 blesmp -S -z IOCAP -v 0x04" - - ['P SSC1 C +BLESMP:OK'] - - - "SSC SSC2 blesmp -S -z IOCAP -v 0x04" - - ['P SSC2 C +BLESMP:OK'] - - *numberic_comparision_pair - - *check_connection -- ID: BTSTK_SMP_03001 - <<: *SMP_CASE - test point 2: BLE SMP pair with pairing request test - summary: BLE SMP start pair with secruity request - steps: | - 1. set sec properity None on initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2 - 4. DUT2 send secruity request, do pair (if required) - 5. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. connected - 4. use just work and pair succeed - 5. succeed - cmd set: - - "" - - *config_just_work - - *just_work_pair - - *check_connection -- ID: BTSTK_SMP_03002 - <<: *SMP_CASE - test point 2: BLE SMP initiate pair test - summary: BLE SMP start pair with pairing request - steps: | - 1. set sec properity None on initiator and responder - 2. set IOCAP to KeyboardDisplay on initiator and responder - 3. DUT1 connect to DUT2 - 4. DUT1 send pair req, do pair (if required) - 5. do service discovery - expected result: | - 1. succeed - 2. succeed - 3. connected - 4. use just work and pair succeed - 5. succeed - cmd set: - - "" - - *config_just_work - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - *check_connection -- ID: BTSTK_SMP_05003 - <<: *SMP_CASE - test point 2: BLE SMP unsuccessful pair reply test - summary: BLE SMP unsuccessful passkey entry on both side test - steps: | - 1. enter both side passkey entry phase - 2. entry different passkey and accept - 3. enter both side passkey entry phase - 4. entry same passkey and reject - 5. enter both side passkey entry phase - 6. send numberic comparision accept - 7. enter both side passkey entry phase - 8. send numberic comparision reject - expected result: | - 1. succeed - 2. pair failed - 3. succeed - 4. pair failed - 5. succeed - 6. pair failed - 7. succeed - 8. pair failed - cmd set: - - "" - - *config_both_side_passkey_entry - - - LOOP 2 5 "[1,0]" "['000002','000001']" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['R SSC[1,2] C +BLESMP:PassKeyReq'] - - - "SSC SSC2 blesmp -K -r -a [1,{%d}] -k [000001,{%s}]" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect - - - LOOP 2 5 "[1,0]" "[0,1]" - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1,2] C +BLESMP:PassKeyReq'] - - - "SSC SSC[1,2] blesmp -C -r -a [{%d},{%d}]" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - - *disconnect -- ID: BTSTK_SMP_05004 - <<: *SMP_CASE - test point 2: BLE SMP unsuccessful pair reply test - summary: BLE SMP reject pair - steps: | - 1. DUT1 connect to DUT2 - 2. DUT2 send security req - 3. DUT1 reject pairing - 4. disconnect - 5. DUT1 connect to DUT2 - 6. DUT1 send pairing req - 7. DUT2 reject pairing - 4. disconnect - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - 8. succeed - cmd set: - - "" - - *connect - - - "SSC SSC2 blesmp -E -r -z Enc" - - [""] - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 blesmp -E -r -z Enc" - - [""] -- ID: BTSTK_SMP_06002 - <<: *SMP_CASE - test point 2: BLE SMP use API in abnormal state - summary: BLE SMP use phase 2 API in phase 1 - steps: | - 1. enter entry passkey phase - 2. send ble security response - 3. continue pairing - expected result: | - 1. succeed - 2. failed - 3. pair succeed - cmd set: - - "" - - *config_slave_passkey_entry - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] -- ID: BTSTK_SMP_06003 - <<: *SMP_CASE - test point 2: BLE SMP use API in abnormal state - summary: BLE SMP use phase 1 API in phase 2 - steps: | - 1. enter phase 1 (don't send security response) - 2. do passkey entry - 3. do number comparision - expected result: | - 1. succeed - 2. failed - 3. failed - cmd set: - - "" - - *config_slave_passkey_entry - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 blesmp -K -r -a 1 -k " - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] -- ID: BTSTK_SMP_06004 - <<: *SMP_CASE - test point 2: BLE SMP use API in abnormal state - summary: BLE SMP master disconnect during pairing and repairing - steps: | - 1. enter phase 1 (don't send security response) - 2. disconnect - 3. enter phase 1, send response but do not do pair - 4. disconnect - expected result: | - 1. succeed - 2. disconnected - 3. succeed - 4. disconnected - cmd set: - - "" - - *config_slave_passkey_entry - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:SecReq'] - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - *disconnect -- ID: BTSTK_SMP_06005 - <<: *SMP_CASE - test point 2: BLE SMP use API in abnormal state - summary: BLE SMP slave disconnect during pairing and repairing - steps: | - 1. enter phase 1 (don't send security response) - 2. disconnect - 3. enter phase 1, send response but do not do pair - 4. disconnect - expected result: | - 1. succeed - 2. disconnected - 3. succeed - 4. disconnected - cmd set: - - "" - - *config_slave_passkey_entry - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC1 C +BLESMP:SecReq'] - - - "SSC SSC2 bleconn -D -z all" - - ['P SSC2 C +BLECONN:GapDisconnect,OK', 'P SSC1 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['P SSC2 C +BLEADV:Start,OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC2 C +BLESMP:PassKeyReq', 'P SSC1 A :BLESMP:PassKeyNotify,(\d+)'] - - - "SSC SSC2 bleconn -D -z all" - - ['P SSC2 C +BLECONN:GapDisconnect,OK', 'P SSC1 C +BLECONN:GapDisconnect,OK'] -- ID: BTSTK_SMP_07001 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP just work pairing and reconnect - steps: | - 1. DUT1 and DUT2 SMP with just work pair - 2. DUT1 disconnect - 3. DUT1 connect to DUT2 - 4. DUT2 send auth request - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - cmd set: - - "" - - *config_just_work - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC1 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLECONN:GapConnect,OK', 'P SSC2 C +BLECONN:GapConnect,OK'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success'] -- ID: BTSTK_SMP_07003 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP slave passkey enter and reconnect - steps: | - 1. DUT1 and DUT2 SMP with slave passkey enter - 2. DUT1 reconnect - 3. DUT1 connect to DUT2 - 4. DUT2 send auth request - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - cmd set: - - "" - - *config_slave_passkey_entry - - *slave_passkey_entry_pair - - *disconnect - - *slave_passkey_entry_pair -- ID: BTSTK_SMP_07004 - <<: *SMP_CASE - test point 2: BLE SMP no bond test and repairing - summary: BLE SMP slave passkey enter and reboot - steps: | - 1. DUT1 and DUT2 SMP with slave passkey enter - 2. DUT1 reboot - 3. DUT1 connect to DUT2 - 4. DUT2 send auth request - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. failed - cmd set: - - "" - - *config_slave_passkey_entry - - *slave_passkey_entry_pair - - - "SSC SSC1 reboot" - - ['P SSC2 C +BLECONN:GapDisconnect,OK'] - - - "SSC SSC1 ble -R" - - ['R SSC1 C +BLE:'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - *slave_passkey_entry_pair -- ID: BTSTK_SMP_50001 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT read char performance test after just work pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do read char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "read" - - "" - - - pair_op = "just_work_pair" - - "" - - - op_char = "0xC301" - - "" -- ID: BTSTK_SMP_50002 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT read char performance test after numberic comparision pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do read char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "read" - - "" - - - pair_op = "numberic_comparision_pair" - - "" - - - op_char = "0xC301" - - "" -- ID: BTSTK_SMP_50003 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT write char performance test after just work pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "write" - - "" - - - op_char = "0xC304" - - "" - - - pair_op = "just_work_pair" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_50004 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT write char performance test after numberic comparision pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do write char for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "write" - - "" - - - op_char = "0xC304" - - "" - - - pair_op = "numberic_comparision_pair" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_50005 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT notify performance test after just work pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "notify" - - "" - - - op_char = "0xC305" - - "" - - - pair_op = "just_work_pair" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_50006 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT notify performance test after numberic comparision pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "notify" - - "" - - - op_char = "0xC305" - - "" - - - pair_op = "numberic_comparision_pair" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_50007 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT indicate performance test after just work pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "indicate" - - "" - - - pair_op = "just_work_pair" - - "" - - - op_char = "0xC306" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_50008 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP GATT performance test - summary: GATT indicate performance test after numberic comparision pair - Test App: SSC_BLE_PERF - steps: | - 1. update connection parameter - 2. do primary service discovery - 3. do notify for some time - expected result: | - 1. succeed - 2. succeed - 3. calculate throughput - execution time: 2 - cmd set: - - "BLEStress/BLESMPGATTPerformance" - - - test_time = 420 - - "" - - - mtu = 512 - - "" - - - gatt_op = "indicate" - - "" - - - pair_op = "numberic_comparision_pair" - - "" - - - op_char = "0xC306" - - "" - - - op_len = 490 - - "" -- ID: BTSTK_SMP_51001 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP performance test - summary: BLE SMP Connect and disconnect performance test - steps: | - 1. DUT2 set AuthReqMode and RspKey - 2. DUT1 disconnect with DUT2 - 3. DUT2 start advertising - 4. DUT1 connect to DUT2 - 5. do service discovery - 6. loop step 1-4 - 7. check connection fail ratio and average conn time - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. meet pass standard - execution time: 6 - version: v1 (2017-05-19) - CI ready: 'No' - cmd set: - - "BLEStress/BLESMPConnPerformance" - - - "test_time = 420" - - "" - - - "average_conn_time = 3" - - "" - - - "fail_ratio = 0.01" - - "" - - - "fail_timeout = 10" - - "" -- ID: BTSTK_SMP_52001 - <<: *SMP_CASE - category: Performance - test point 1: performance + stress - test point 2: BLE SMP performance test for bond - summary: BLE SMP bond, remove, get bondlist, rebond - steps: | - 1. DUT1 bond 15 devices and get bond list - 2. DUT1 bond 16th device and get bond list - 3. rebond removed bond device and get bond list - 4. remove all bond and get bond list - 5. loop step 1 to step 4 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - execution time: 2 - cmd set: - - "BLEStress/BLESMPBondPerformance" - - - test_time = 120 - - "" diff --git a/components/idf_test/integration_test/TC_IT_MESH_COMM.yml b/components/idf_test/integration_test/TC_IT_MESH_COMM.yml deleted file mode 100644 index b7b64b0e1..000000000 --- a/components/idf_test/integration_test/TC_IT_MESH_COMM.yml +++ /dev/null @@ -1,2854 +0,0 @@ -.MESH_COMM_CASE: &MESH_COMM_CASE - SDK: ESP32_IDF - Test App: SSC_MESH - auto test: 'Yes' - category: Function - execution time: 0.0 - module: Mesh - sub module: Communication - version: v1 (2018-08-15) - level: Integration - allow fail: '' - initial condition: MESH_INIT1 - CI ready: 'NO' - -.throughput_cmd_set: &throughput_cmd_set - LIST_MERGE: - - - 'bcn_interval = [None]' - - [''] - - - 'test_cycles = 2' - - [''] - - - 'send_len = [1460, 1024, 512, 256]' - - [''] - - - 'measure_time_sec = 30' - - [''] - - - 'send_interval = [0, 100]' - - - 'send_interval = [0, 100]' - - [''] - - - 'send_type = "ucast"' - - [''] - - - 'send_flag = 2' - - [''] - - -.mesh_config_all_duts_no_router: &mesh_config_all_duts_no_router - LIST_MERGE: - - - 'SSC SSC1 meshset -T -o 0 -t 1' - - ['P SSC1 C +MESHSET:TYPE,OK'] - - - 'MSSC SSC[2-] meshset -X -o 0 -i 1' - - ['P SSC[2-] C +MESHSET:FIX_ROOT,OK'] - - - 'MSSC SSC[1-] meshset -M -o 0 -t -e -l 10' - - ['P SSC[1-] C +MESHSET:MAP_AUTH,OK'] - - - 'SSC SSC[1-] meshset -G -o 0 -m -n -t -e - -i ' - - ['P SSC[1-] C +MESHSET:CFG,OK'] - - -.root_do_connect: &root_do_connect - LIST_MERGE: - - - 'SOC SOC1 LISTEN ' - - ['R SOC_COM L OK'] - - - 'SSC MNODE(0) mesh -S -o 0 -i -t ' - - ['P MNODE(0) C +CONNECT,OK', 'P SOC1 C ACCEPT'] - - - 'SOC SOC1 MACCEPT GSOC1' - - ['R SOC_COM L OK'] - -test cases: -- ID: MESH_COMM_0101 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to self - summary: no-child root send ucast to self with default parameters - CI ready: 'Yes' - test environment: SSC_T1_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0102 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to self - summary: root send ucast to self with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0103 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to L2 - summary: root send ucast to L2 with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0104 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to L3 - summary: root send ucast to L3 with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0105 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,-1) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to leaf - summary: root send ucast to leaf with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0106 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to root - summary: L2 send unicast to root with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0107 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,1) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to brother - summary: L2 send unicast to brother with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0108 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to L3 - summary: L2 send unicast to L3 with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0109 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,1) C +MESHRXPKT,OK - - - DELAY 3 - - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,1) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to brother - summary: L2 send unicast to brother, delay 3s, send again - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0110 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d -l 1000 -c 100 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send unicast to root - summary: L3 send unicast to root with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0111 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d -l 1000 -c 100 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send unicast to L2 - summary: L3 send unicast to L2 with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0112 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d -l 1000 -c 100 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send unicast to self - summary: L3 send unicast to self with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0113 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast to root - summary: leaf send unicast to root with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0114 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHRXPKT,OK C +MESHTXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast to itself - summary: leaf send unicast to itself with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0115 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,1) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast to another L2 node - summary: leaf send unicast to another l2 node with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0116 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast to another L3 node - summary: leaf send unicast to another L3 node with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0117 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 8 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 4 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 0 - - - P MNODE(0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. fail - 2. succeed - 3. fail - steps: |- - 1. root send unicast to L2 with flag TODS - 2. root send unicast to L2 with flag FROMDS - 3. root send unicast to L2 without flag set - summary: root send unicast to L2 with different flag - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0118 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 8 - - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 4 - - - P MNODE(0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 0 - - - P MNODE(0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. fail - 3. fail - steps: |- - 1. L2 send unicast to root with flag TODS - 1. L2 send unicast to root with flag FROMDS - 1. L2 send unicast to root without flag set - summary: node send unicast upward to root with different flag - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0119 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - LOOP 4 1 "[0,1,2,3]" - - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -p {%d} - - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to root with differet protocal - summary: node send unicast with differet protocal - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0120 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - LOOP 4 1 "[0,1,2,3]" - - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -p {%d} - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send unicast to L2 with differet protocal - summary: root send unicast with differet protocal - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0121 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -t 0 - - - P MNODE(0) C +MESHTXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -t 1 - - - P MNODE(0) C +MESHTXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -t 2 - - - P MNODE(0) C +MESHTXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -t 2 - - - P MNODE(0,0) C +MESHTXPKT,FAIL - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 -t 0 - - - P MNODE(0,0) C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. root send unicast to L2 with tos = P2P - 2. root send unicast to L2 with tos = E2E - 3. root send unicast to L2 with tos = DEF - 4. L2 send unicast to root with tos = DEF - 5. L2 send unicast to root with tos = P2P - summary: node send unicast with different tos - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0122 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -t 0 -p 1 -f 4 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send unicast to L2 with flag=FROMDS, protocal=HTTP, tos=P2P - summary: root send unicast with flag=FROMDS, protocal=HTTP, tos=P2P - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0123 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 4 -p 1 - -t 1 - - - P MNODE(0) C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - steps: |- - 1. root send unicast to L2 with flag=FROMDS, protocal=HTTP, tos=E2E - summary: root send unicast with flag=FROMDS, protocal=HTTP and tos=E2E - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0124 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 8 -p 1 -t 0 - - - P MNODE(0) C +MESHRXPKT,OK - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to root with flag=TODS, protocal=HTTP, tos=P2P - summary: node send unicast to root with flag=TODS, protocal=HTTP and tos=P2P - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0125 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 8 -p 1 -t 1 - - - P MNODE(0,0) C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to root with flag=TODS, protocal=HTTP, tos=E2E - summary: node send unicast to root with flag=TODS, protocal=HTTP and tos=E2E - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0126 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d 01:00:5E:00:00:00 -l 1460 -c 20 -b 20 -f 8 - - - P MNODE(0) C TODS_PKT,OK C +MESHTXPKT,OK C +MESHSEND,OK - expected result: |- - 1. succeed - steps: |- - 1. root send unicast with multicast address - summary: root send unicast with multicast address wtth flag TODS - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0127 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. meshsend unicast between two nodes - summary: meshsend unicast test between diffent nodes - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0128 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - *mesh_config_all_duts_no_router - - - SSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - SSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s"%%() - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. set all duts to establish no router network - 2. layer1 send package to layer2 - 3. layer1 send package to DS - 4. layer2 send package to layer1 - 5. layer2 send package to DS - summary: no router network, meshsend unicast test - initial condition: MESH_DEINIT_STA - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0129 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - steps: |- - 1. root send unicast with inexistent dst_addr - summary: root send unicast with inexistent dst_addr - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0130 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 0 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,FAIL C +MESHSEND,OK - - P MNODE(0,0) NC +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 64 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0) meshsend -S -d -l 1600 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,FAIL C +MESHSEND,OK - - P MNODE(0,0) NC +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send unicast to another node with different length - summary: node send unicast to another node with different length - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0131 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f - - - P MNODE(0) C +MESHTXPKT,FAIL - - - ASSERT - - - '' - expected result: |- - 1. fail - steps: |- - 1. root send unicast to leaf with invalid flag value - summary: (ASSERT) root send unicast with invalid flag value - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0132 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -p - - - P MNODE(0) C +MESHTXPKT,FAIL - - - ASSERT - - - '' - expected result: |- - 1. fail - steps: |- - 1. root send unicast to leaf with invalid proto value - summary: (ASSERT) root send unicast with invalid proto value - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0133 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -t - - - P MNODE(0) C +MESHTXPKT,FAIL - - - ASSERT - - - '' - expected result: |- - 1. fail - steps: |- - 1. root send unicast to leaf with invalid tos value - summary: (ASSERT) root send unicast with invalid tos value - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0134 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -l 1460 -c 10 -b 100 -f 10 - - - P MNODE(0) C +MESHRXPKT,OK - - P MNODE(0,-1) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) NC +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast without dst_addr - summary: leaf send unicast without dst_addr but with flag=P2P|TODS (to root) - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0135 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 200 -b 20 -f 2 - - - P MNODE(0) C +MESHRXPKT,OK - - - DELAY 2 - - - '' - - - SSC MNODE(0,0) meshsend -D - - - P MNODE(0,0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L2 send packets to root - 2. stop L2 send task - summary: stop send task when node send packets to root - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0136 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 200 -b 20 -f 2 - - - '' - - - DELAY 2 - - - '' - - - SSC MNODE(0) meshsend -D - - - P MNODE(0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root send packets to L2 - 2. stop root send task - summary: stop send task when root send packets to L2 - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0137 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) reboot - - - P MNODE(0,-1) C !!!ready!!! - - - DELAY 15 - - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. disable a node - 2. root send unicast to this node - summary: root send unicast to disabled node - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0138 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - '' - - - SSC MNODE(0,-1) mesh -I -o 1 - - - P MNODE(0,-1) C +MESH:DEINIT,OK - - P MNODE(0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root send unicast to leaf - 2. leaf deinit - summary: root send unicast to deinited node - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0139 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d ff:ff:ff:ff:ff:ff -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send broadcast packet with multicast option - 2. todo - summary: root send broadcast packet with multicast option - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0140 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - steps: |- - 1. root send multicast to L2/L3 with unicast addr - summary: root send packet with unicast addr and multicast option - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0141 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - MSSC SSC[1-] meshsend -S -d -l 1460 -c 50 -b 200 -f 2 - - - '' - - - DELAY 50 - - - P SSC[1-] C +MESHTXPKT,OK +MESHSEND,OK - - - SSC SSC[1-] mesh -Q -o 2 - - - R SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. all nodes send unicast to root - 1. check mesh network - summary: all nodes send unicast to root,check mesh network - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0142 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 200 -b 50 -f 8 - - - '' - - - DELAY 2 - - - '' - - - SSC MNODE(0,0) meshsend -D - - - P MNODE(0,0) C +MESHSEND:STOP,OK - - - DELAY 10 - - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 100 -b 100 -f 8 - - - P MNODE(0,0) C +MESHSEND,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send unicast to server - 2. L2 meshsend stop - 3. delay 10s,L2 send unicast to server again - summary: node send unicast to server with stop - CI ready: 'No' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: ucast meshsend test -- ID: MESH_COMM_0201 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1200 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send multicast to root - summary: no-child root send multicast to root with default parameters - CI ready: 'Yes' - test environment: SSC_T1_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0202 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1200 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send multicast to root - summary: root send multicast to root with default parameters - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0203 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send multicast to L2/L3 - summary: root send multicast to L2/L3 with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0204 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -P -p 1 - - - P MNODE(0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send multicast to itself - summary: L2 send multicast to itself with default parameters - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0205 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -P -p 1 - - - P MNODE(0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send multicast to L1/L3 - summary: L2 send multicast to L1/L3 with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0206 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -P -p 1 - - - P MNODE(0,0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send multicast to L1/L2 - summary: L3 send multicast to L1/L2 with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0207 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -P -p 1 - - - P MNODE(0,0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0,0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0,0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send multicast to itself - summary: L3 send multicast to itself with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0208 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -P -p 1 - - - P MNODE(0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send multicast to itself/root - summary: L2 send multicast to root/itself with default parameters - CI ready: 'Yes' - test environment: SSC_T6_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0209 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -P -p 1 - - - P MNODE(0,0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) meshsend -P -p 0 -t 7 -l 18 - - - P MNODE(0,0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 20 -b 20 -f - 2 - - - P MNODE(0,0,0) C +MESHSEND,OK C +MESHTXPKT,OK C +MESHRXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send multicast to itself/L1/L2 - summary: L3 send multicast to itself/L1/L2 with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0210 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 10 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - DELAY 5 - - '' - - - SSC MNODE(0,0) mesh -Q -o 6 - - - P MNODE(0,0) RE \+MESH_RECV_CNT:\d+, - expected result: |- - 1. succeed - steps: |- - 1. root send multicast with duplicate mac list in option list - summary: root send multicast with duplicate mac list in option list - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0211 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -P -p 1 - - - P MNODE(0,0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 10 -b 20 -f - 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - - - DELAY 5 - - '' - - - SSC MNODE(0) mesh -Q -o 6 - - - P MNODE(0) RE \+MESH_RECV_CNT:\d+, - expected result: |- - 1. succeed - steps: |- - 1. L3 send multicast with duplicate mac list in option list - summary: L3 send multicast with duplicate mac list in option list - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0212 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -P -p 1 - - - P MNODE(0,0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) mesh -D -o 0 -g - - - P MNODE(0,0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0,0) meshsend -P -p 0 -t 7 -l 12 - - - P MNODE(0,0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 0 -c 10 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - - P MNODE(0,0) NC +MESHRXPKT,OK - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1000 -c 10 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - - - SSC MNODE(0,0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send multicast with different length - summary: node send multicast with different length - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: multicast test -- ID: MESH_COMM_0301 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d ff:ff:ff:ff:ff:ff -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK - expected result: |- - 1. succeed - steps: |- - 2. root send broadcast - summary: no-child root send broadcast with default parameters - CI ready: 'NO' - test environment: SSC_T1_MESH1 - test point 1: basic function - test point 2: broadcast test -- ID: MESH_COMM_0302 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d ff:ff:ff:ff:ff:ff -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 2. root send broadcast - summary: root send broadcast with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: broadcast test -- ID: MESH_COMM_0303 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d ff:ff:ff:ff:ff:ff -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send broadcast - summary: L2 send broadcast with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: broadcast test -- ID: MESH_COMM_0304 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d ff:ff:ff:ff:ff:ff -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHSEND,OK C +MESHTXPKT,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L3 send broadcast - summary: L3 send broadcast with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: broadcast test -- ID: MESH_COMM_0305 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d ff:ff:ff:ff:ff:ff -l 1460 -c 10 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHTXPKT,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send broadcast - summary: leaf send broadcast with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: broadcast test -- ID: MESH_COMM_0401 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root send ucast to server - summary: root send ucast tods server with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0402 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0,-1) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send unicast to server - summary: leaf send unicast tods server with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0403 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send multicast to server - summary: L2 send unicast tods server with default parameters - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0404 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -P -p 1 - - - P MNODE(0) C +DELETE_MESHOPT - - - SSC MNODE(0) mesh -D -o 0 -g - - - P MNODE(0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1200 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHSEND,OK C +MESHTXPKT,FAIL - expected result: |- - 1. succeed - steps: |- - 1. root send multicast to server - summary: root send multicast to server with default parameters - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0405 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -P -p 1 - - - P MNODE(0,0) C +DELETE_MESHOPT - - - SSC MNODE(0,0) mesh -D -o 0 -g - - - P MNODE(0,0) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,0) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0,0) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,0) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1200 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHSEND,OK C +MESHTXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. L2 send multicast to server - summary: L2 send multicast to server with default parameters - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0406 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) meshsend -P -p 1 - - - P MNODE(0,-1) C +DELETE_MESHOPT - - - SSC MNODE(0,-1) mesh -D -o 0 -g - - - P MNODE(0,-1) C +MESH_ADDR_LIST_ADD - - - SSC MNODE(0,-1) meshsend -P -p 0 -t 7 -l 6 - - - P MNODE(0,-1) C +MESHSEND:OPTION,1 - - - SSC MNODE(0,-1) meshsend -S -w 1 -d 01:00:5E:00:00:00 -l 1200 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHSEND,OK C +MESHTXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. leaf send multicast to server - summary: leaf send multicast to server with default parameters - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0407 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SSC MNODE(0) mesh -Q -o 9 - - - P MNODE(0) C +CLEAR_COUNT - - - SOC GSOC1 MSEND 1460 10 200 - - - P SOC_COM C MESHSEND:OK - - P MNODE(0) C +MESHRXPKT,OK - - - DELAY 5 - - '' - - - SSC MNODE(0) mesh -Q -o 6 - - - P MNODE(0) RE \+MESH_RECV_CNT:\d+, - expected result: |- - 1. succeed - steps: |- - 1. server send unicast to root - summary: server send unicast to root with common package - test environment: SSC_T3_MESH2 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0408 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - MESHOPT string "070c00" - - - R PC_COM C +MESHOPT:OK - - - SOC GSOC1 MSEND 01:00:5E:00:00:00 1000 10 200 - - - P SOC_COM C MESHSEND:OK - - P MNODE(0,0) C +MESHRXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. server send multicast to node - summary: server send multicast to node - test environment: SSC_T12_MESH2 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0409 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SOC GSOC1 MSEND ff:ff:ff:ff:ff:ff 100 10 200 - - - P SOC_COM C MESHSEND:OK - - P MNODE(0) C +MESHRXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. server send broadcast - summary: server send broadcast - test environment: SSC_T12_MESH2 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0410 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 3 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n -t - -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - '' - - - SSC SSC[1-2] mesh -Q -o 2 - - - P SSC[1-2] T topo - - - MESHTREE - - - R PC_COM C MESHTREE:2%20nodes - - - SSC SSC2 meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P SSC2 C +MESHSEND,OK - - P SSC1 C +MESHRXPKT,OK - - - SSC SSC1 meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P SSC1 C +MESHSEND,OK - - P SSC2 C +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. set one leaf node ssc1 and a normal node ssc2 - 2. ssc2 send package to ssc1 - 3. ssc1 send package to ssc2 - summary: normal node send unicast to leaf type node, leaf type node send unicast to normal root - initial condition: MESH_DEINIT_STA - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: basic function - test point 2: meshsend tods and fromds test -- ID: MESH_COMM_0501 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -Q -o 10 - - - P MNODE(0) C +ROUTETABLE,OK - - - SSC MNODE(0) meshsend -S -w 2 -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P SSC[1-] C +MESHRXPKT,OK - expected result: |- - 1. succeed - steps: |- - 1. root table send test - summary: root table send test with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: table send test -- ID: MESH_COMM_0502 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) mesh -Q -o 10 - - - P MNODE(0,0) C +ROUTETABLE,OK - - - SSC MNODE(0,0) meshsend -S -w 2 -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0,0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - P MNODE(0,0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config - 3. mesh start - 4. L2 table send test - summary: L2 table send test with default parameters - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: basic function - test point 2: table send test -- ID: MESH_COMM_0601 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i 0 - - - P SSC[1-] C +MESHSET:CFG,OK - - - SSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - SSC SSC[1-] mesh -Q -o 2 - - - R SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,-1) C +MESHRXPKT,OK - - - SSC MNODE(0,-1) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 - - - P MNODE(0,-1) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. mesh config: beacon_encrypt=True - 3. mesh start - 4. root send unicast to L2 and leaf with beacon_encrypt=0 - summary: unicast send test after network established with beacon_encrypt=0 - initial condition: MESH_DEINIT_STA - CI ready: 'NO' - test environment: SSC_T6_MESH1 - test point 1: basic function - test point 2: mixed meshsend test -- ID: MESH_COMM_0602 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i 1 - - - P SSC[1-] C +MESHSET:CFG,OK - - - SSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - - SSC SSC[1-] mesh -Q -o 2 - - - R SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s"%%() - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC MNODE(0) mesh -S -o 0 -i -t - - - P MNODE(0) C +CONNECT,OK, P SOC1 C ACCEPT - - - SOC SOC1 MACCEPT GSOC1 - - - R SOC_COM L OK - - - SOC GSOC1 MSEND 1460 10 200 - - - P SOC_COM C MESHSEND,OK - - P MNODE(0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config: set assoc_encrypt=True - 3. mesh start - 4. server send unicast to root with assoc_encrypt=True - summary: server send unicast to root after network established with beacon_encrypt=1 - initial condition: MESH_DEINIT_STA - CI ready: 'NO' - test environment: SSC_T12_MESH2 - test point 1: basic function - test point 2: mixed meshsend test -- ID: MESH_COMM_0701 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d -l 1000 -c 100 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK - - P MNODE(0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - P MNODE(0,0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L3 node send unicast to root - 2. disable the parent node - summary: disable parent node when node send unicast to root - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0702 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1000 -c 100 -b 50 -f 2 - - - P MNODE(0,0) C +MESHTXPKT,OK - - - DELAY 1 - - - '' - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY 5 - - P MNODE(0,0) C MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L2 node send unicast to its' brother node - 2. disable its' parent node - summary: disable parent node when L2 node send unicast to its' brother node - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0703 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) meshsend -S -d -l 1000 -c 100 -b 20 -f 2 - - - P MNODE(0,0,0) C +MESHTXPKT,OK - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - - DELAY 5 - - - P MNODE(0,0,0) C +MESHTXPKT,FAIL C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L3 node send unicast to its' brother node - 2. disable its' parent node - summary: disable parent node when L3 node send unicast to its' brother node - CI ready: 'Yes' - test environment: SSC_T12_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0704 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -R -o 1 - - - P MNODE(0) C +MESHRX:STOP,OK - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 20 -b 20 -f 2 - - - '' - - - DELAY 3 - - - P PC_COM C DELAYDONE - - P MNODE(0,0) C +MESHTXPKT,OK NC +MESHSEND,OK - - P MNODE(0) NC +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. disable recv task on root - 2. L2 node send unicast to root - summary: disable a node recv task, another node send unicast to the node - CI ready: 'Yes' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0705 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 100 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK - - P MNODE(0,0) C +MESHRXPKT,OK - - - SSC MNODE(0,0) mesh -R -o 1 - - - P MNODE(0,0) C +MESHRX:STOP,OK - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - - SSC MNODE(0,0) mesh -R - - - P MNODE(0,0) C +MESHRXPKT,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root node send unicast to L2 - 2. disable L2 recv task - summary: disable recv task while another node send unicast to the node - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0706 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SOC GSOC1 MSEND 1000 50 200 - - - '' - - - SSC MNODE(0) mesh -R -o 1 - - - P MNODE(0) C +MESHRX:STOP,OK - - - DELAY 30 - - - '' - expected result: |- - 1. succeed - steps: |- - 1. disable the recv task while server sending unicast to the node - summary: disable recv task while server sending unicast to the node - CI ready: 'NO' - test environment: SSC_T3_MESH2 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0707 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SSC SSC[1-] meshsend -S -d -l 1460 -c 100 -b 20 -f 8 - - - P SSC[1-] C +MESHTXPKT,OK - - P MNODE(0) C TODS_PKT,OK - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - '' - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. all nodes send unicast to server - 2. disable root - summary: disable root when all nodes send unicast to server - CI ready: 'NO' - test environment: SSC_T12_MESH2 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0708 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC SSC[1-] meshsend -S -d -l 1460 -c 100 -b 20 -f 2 - - - '' - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - '' - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. all nodes send unicast to root - 2. disable root - summary: disable root when all nodes send unicast to root - CI ready: 'NO' - test environment: SSC_T12_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0709 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 2000 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK - - - DELAY 2 - - - '' - - - SSC MNODE(0,0) mesh -T -o 1 - - - P MNODE(0,0) C +MESH:STOP,OK - - P MNODE(0) C +MESHTXPKT,OK - - - SSC MNODE(0) meshsend -D - - - P MNODE(0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root send packets to L2 - 2. disable the recv node when root send packets - summary: recv node disable when root send packets to node - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0710 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 2000 -b 20 -f 2 - - - "" - - - DELAY 2 - - - '' - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - P MNODE(0,0) C +MESHTXPKT,FAIL - - - SSC MNODE(0,0) meshsend -D - - - P MNODE(0,0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L2 send packets to root - 2. disable the recv node when root send packets - summary: recv node disable when L2 send packets to the node - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0711 - <<: *MESH_COMM_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 2000 -b 20 -f 8 - - - P MNODE(0,0) C +MESHTXPKT,OK - - - DELAY 2 - - - '' - - - SSC MNODE(0) mesh -R -o 1 - - - P MNODE(0) C +MESHRX:STOP,OK - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P MNODE(0,0) NC +MESHTXPKT,FAIL - - - SSC MNODE(0) mesh -R - - - P MNODE(0) C +MESHRX:START,OK - - - SSC MNODE(0,0) meshsend -D - - - P MNODE(0,0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L2 send packets to server - 2. server close when L2 send packets to server - summary: server close when node send packets to server - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0712 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 2000 -b 20 -f 8 - - - '' - - - DELAY 2 - - - '' - - - SOC GSOC1 CLOSE - - - P MNODE(0) C +TCPSOC:CLOSED - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P MNODE(0) C +MESHTXPKT,OK NC +MESHTXPKT,FAIL - - - SSC MNODE(0) meshsend -D - - - P MNODE(0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root send packets to server - 2. server close when root send packets to server - summary: server close when root send packets to server - CI ready: 'NO' - test environment: SSC_T3_MESH2 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0713 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SSC MNODE(0,0,0) meshsend -S -d -l 1460 -c 2000 -b 20 -f 8 - - - "" - - - DELAY 2 - - - '' - - - SOC GSOC1 CLOSE - - - P MNODE(0) C +TCPSOC:CLOSED - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P MNODE(0,0,0) C +MESHTXPKT,OK NC +MESHTXPKT,FAIL - - - SSC MNODE(0,0,0) meshsend -D - - - P MNODE(0,0,0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - steps: |- - 1. root disconnect with server when L3 send packets to server - summary: root disconnect with server when L3 send packets to server - CI ready: 'NO' - test environment: SSC_T12_MESH2 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0714 - <<: *MESH_COMM_CASE - cmd set: - - '' - - *root_do_connect - - - SSC MNODE(0) meshsend -S -d -l 1460 -c 2000 -b 100 -f 8 - - - '' - - - DELAY 2 - - - '' - - - SSC MNODE(0) mesh -S -o 1 - - - '' - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P MNODE(0) C +TCPSOC:CLOSED C +CONNECTSTOP,OK C +MESHTXPKT,OK NC +MESHTXPKT,FAIL - - - SSC MNODE(0) meshsend -D - - - P MNODE(0) C +MESHSEND:STOP,OK - expected result: |- - 1. succeed - steps: |- - 1. root disconnect with server when root send packets to server - summary: root disconnect with server when root send packets to server - CI ready: 'NO' - test environment: SSC_T3_MESH2 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_0715 - <<: *MESH_COMM_CASE - cmd set: - - '' -# - *root_do_connect - - - SSC MNODE(0,0) meshsend -S -d -l 1460 -c 100 -b 50 -f 8 - - - P MNODE(0,0) C +MESHTXPKT,OK - - P MNODE(0) C TODS_PKT,OK - - - SSC MNODE(0) mesh -R -o 1 - - - P MNODE(0) C +MESHRX:STOP,OK - - - DELAY 10 - - - P PC_COM C DELAYDONE - - P MNODE(0,0) NC +MESHSEND,OK - - - SSC MNODE(0) mesh -R - - - P MNODE(0) C +MESHRX:START,OK C TODS_PKT,OK - - P MNODE(0,0) C +MESHSEND,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. L2 send packets to server - 2. server stop recv when node send packets to server - summary: root stop recv when node send packets to server - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: abnormal user - test point 2: destory network -- ID: MESH_COMM_5001 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - '' - - - MSSC SSC[1-] meshsend -S -d -l 1460 -c 50 -b 200 -f 2 - - - '' - - - DELAY 50 - - - P SSC[1-] C +MESHTXPKT,OK +MESHSEND,OK - - - SSC SSC[1-] mesh -Q -o 2 - - - R SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. all nodes send unicast to root - 1. check mesh network - summary: all nodes(T50) send unicast to root,check mesh network - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5002 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - '' - - - MSSC SSC[1-] meshsend -S -d -l 1460 -c 30 -b 200 -f 8 - - - '' - - - DELAY 50 - - - P SSC[1-] C +MESHTXPKT,OK C +MESHSEND,OK - - - SSC SSC[1-] mesh -Q -o 2 - - - R SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s%20nodes"%%() - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. all nodes send unicast to server - 2. check mesh network - summary: all nodes send unicast to server,check mesh network - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5003 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshStressSend - - - test_time = 60 - - - '' - - - node_send_type = "unicast" - - - '' - - - node_send_delay = 500 - - - '' - - - server_send_flag = True - - - '' - - - server_send_type = "broadcast" - - - '' - - - server_send_delay = 500 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - steps: |- - 1. all nodes send unicast to random target, server sending broadcast - summary: All node send unicast to random nodes, server sending broadcast - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5004 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshStressSend - - - test_time = 60 - - - '' - - - node_send_type = "unicast" - - - '' - - - node_send_delay = 500 - - - '' - - - server_send_flag = False - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - steps: |- - 1. all nodes send unicast to random target - summary: All node send unicast to random nodes - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5005 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshTableSend - - - source_addr = "MNODE(0)" - - - '' - - - send_counts = 1000 - - - '' - - - check_timeout = 60 - - - '' - - - send_delay = 0 - - - '' - - - send_flag = 18 - - - '' - - - packet_type = 1 - - - '' - comment: Mesh Stress - execution time: 1.0 - expected result: - 1. succeed - 2. succeed - 3. succeed - steps: - 1. established mesh network - 2. node send packets to its mesh table - 3. check send/recv time and lose rate - summary: root send unicast to its' mesh table, calculate the send/recv time and lose rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5006 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshTableSend - - - source_addr = "MNODE(0,0)" - - - '' - - - send_counts = 1000 - - - '' - - - check_timeout = 60 - - - '' - - - send_delay = 0 - - - '' - - - send_flag = 18 - - - '' - - - packet_type = 1 - - - '' - comment: Mesh Stress - execution time: 1.0 - expected result: - 1. succeed - 2. succeed - 3. succeed - steps: - 1. established mesh network - 2. L2 send packets to its mesh table - 3. check send/recv time and lose rate - summary: L2 send unicast to its' mesh table, calculate the send/recv time and lose rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5007 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshTableSend - - - source_addr = "MNODE(0,0,0)" - - - '' - - - send_counts = 1000 - - - '' - - - check_timeout = 60 - - - '' - - - send_delay = 0 - - - '' - - - send_flag = 18 - - - '' - - - packet_type = 1 - - - '' - comment: Mesh Stress - execution time: 1.0 - expected result: - 1. succeed - 2. succeed - 3. succeed - steps: - 1. established mesh network - 2. L3 send packets to its mesh table - 3. check send/recv time and lose rate - summary: L3 send unicast to its' mesh table, calculate the send/recv time and lose rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_5008 - <<: *MESH_COMM_CASE - category: Stress - cmd set: - - MeshStress/MeshMixture - - - test_time = 720 - - - '' - - - send_delay = 100 - - - '' - - - unicast_addr = "random" - - - '' - comment: Mesh Stress - execution time: 1.0 - expected result: - 1. succeed - 2. succeed - 3. succeed - steps: - 1. established mesh network - 2. delay some time,send unicast with random address - 3. check mesh network - summary: mesh mixture stress test - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend stress - test point 2: meshsend ucast/mcast/bcast stress test -- ID: MESH_COMM_6001 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: L1 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L1(T3), calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6002 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: L1 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L1(T50), calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6003 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0)'] - - - '' - comment: L1 send packet to L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L2(T3), calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T3_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6004 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0)'] - - - '' - comment: L1 send packet to L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L2(T50), calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6005 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0,0)'] - - - '' - comment: L1 send packet to L3 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L3, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6006 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0,0,0)'] - - - '' - comment: L1 send packet to L4 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to L4, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6007 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: L2 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to L1, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6008 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - receiver = ['MNODE(0,0,0)'] - - - '' - comment: L2 send packet to L3 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to L3, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6009 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - receiver = ['MNODE(0,0,0,0)'] - - - '' - comment: L2 send packet to L4 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to L4, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6010 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: L3 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send packet to L1, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6012 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - receiver = ['MNODE(0,0)'] - - - '' - comment: L3 send packet to L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send packet to L2, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6013 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - receiver = ['MNODE(0,0,0,0)'] - - - '' - comment: L3 send packet to L4 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send packet to L4, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6014 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0,0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: L4 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L4 send packet to L1, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6015 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0,0)'] - - - '' - - - receiver = ['MNODE(0,0)'] - - - '' - comment: L4 send packet to L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L4 send packet to L2, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6016 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0,0)'] - - - '' - - - receiver = ['MNODE(0,0,0)'] - - - '' - comment: L4 send packet to L3 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L4 send packet to L3, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6017 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - receiver = ['MNODE(0,1)'] - - - '' - comment: L2 send packet to its brother - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to its brother, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6018 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - receiver = ['MNODE(0,0,1)'] - - - '' - comment: L3 send packet to its brother - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send packet to its brother, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6019 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - receiver = ['MNODE(0,1)'] - - - '' - comment: L3 send packet to its uncle - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send packet to its uncle, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6020 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0)', 'MNODE(0,1)'] - - - '' - comment: L1 send packet to two L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to two L2 node, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6021 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(l2)'] - - - '' - comment: L1 send packet to all L2 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to all L2, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6022 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(l3)'] - - - '' - comment: L1 send packet to all L3 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to all L3, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6023 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(l2)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: all L2 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: all L2 send packet to L1, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6024 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = [] - - - '' - comment: L1 send packet to table - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send packet to table, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6025 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - receiver = [] - - - '' - comment: L2 send packet to table - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to table, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6026 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - receiver = ['MNODE(0,0,*)'] - - - '' - comment: L2 send packet to L2's table - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send packet to L2's table, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6027 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['!MNODE(0)'] - - - '' - - - receiver = ['MNODE(0)'] - - - '' - comment: non-L1 send packet to L1 - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: all nodes except root send packet to L1, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6028 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0)'] - - - '' - - - send_type = 'bcast' - - - '' - comment: L1 send broadcast - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L1 send broadcast, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6029 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0)'] - - - '' - - - send_type = 'bcast' - - - '' - comment: L2 send broadcast - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L2 send broadcast, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6030 - <<: *MESH_COMM_CASE - category: Performance - cmd set: - - MeshStress/MeshSendReceive - - *throughput_cmd_set - - - sender = ['MNODE(0,0,0)'] - - - '' - - - send_type = 'bcast' - - - '' - comment: L3 send broadcast - execution time: 0.5 - expected result: - 1. succeed - steps: - 1. calculate throughput and packet loss rate - summary: L3 send broadcast, calculate throughput and packet loss rate - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast throughput and packetloss -- ID: MESH_COMM_6101 - <<: *MESH_COMM_CASE - cmd set: - - MeshStress/MeshSendRecv - - - test_time = 1 - - - '' - - - source_adde_list = ["MNODE(0)", "MNODE(0,0)", "MNODE(0,0,0)", "MNODE(0,0,0,0)", "MNODE(0,0,0,0,0)", "MNODE(0,-1)"] - - - '' - - - dst_addr_list = ["MNODE(0)", "MNODE(0,0)", "MNODE(0,0,0)", "MNODE(0,0,0,0)", "MNODE(0,0,0,0,0)", "MNODE(0,-1)"] - - - '' - - - send_delay = 500 - - - '' - - - send_counts = 10 # reduce counts to 10 - - - '' - - - loss_rate_standard = 0.5 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. node send unicast to another node - 2. calculate send/recv time and loss rate - summary: calculate send/recv time and loss rate between different nodes - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast delaytime and packetloss -- ID: MESH_COMM_6102 - <<: *MESH_COMM_CASE - cmd set: - - MeshStress/MeshSendRecv - - - test_time = 1 - - - '' - - - source_adde_list = ["GSOC1"] - - - '' - - - dst_addr_list = ["MNODE(0)", "MNODE(0,0)", "MNODE(0,0,0)", "MNODE(0,0,0,0)", "MNODE(0,0,0,0,0)", "MNODE(0,-1)"] - - - '' - - - send_delay = 500 - - - '' - - - send_counts = 10 # reduce counts to 10 - - - '' - - - loss_rate_standard = 0.5 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. calculate packet send/recv time - steps: |- - 1. server send unicast to differet nodes - 2. calculate send/recv time and loss rate - summary: calculate send/recv time and loss rate between server send unicast to different nodes - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast delaytime and packetloss -- ID: MESH_COMM_6103 - <<: *MESH_COMM_CASE - cmd set: - - MeshStress/MeshSendRecv - - - test_time = 1 - - - '' - - - source_adde_list = ["MNODE(0)", "MNODE(0,0)", "MNODE(0,0,0)", "MNODE(0,0,0,0)", "MNODE(0,0,0,0,0)", "MNODE(0,-1)"] - - - '' - - - dst_addr_list = ["GSOC1"] - - - '' - - - send_delay = 500 - - - '' - - - send_counts = 10 # reduce counts to 10 - - - '' - - - loss_rate_standard = 0.5 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. calculate packet send/recv time - steps: |- - 1. differet nodes send unicast to server - 2. calculate send/recv time and loss rate - summary: calculate send/recv time and loss rate between different node and server - CI ready: 'NO' - test environment: SSC_T50_MESH1 - test point 1: meshsend performance - test point 2: ucast/mcast/bcast delaytime and packetloss diff --git a/components/idf_test/integration_test/TC_IT_MESH_EST.yml b/components/idf_test/integration_test/TC_IT_MESH_EST.yml deleted file mode 100644 index 12c9979e9..000000000 --- a/components/idf_test/integration_test/TC_IT_MESH_EST.yml +++ /dev/null @@ -1,4722 +0,0 @@ -.MESH_CASE: &MESH_CASE - SDK: ESP32_IDF - Test App: SSC_MESH - auto test: 'Yes' - category: Function - test point 1: self organized function - initial condition: MESH_DEINIT_STA - test environment: SSC_T50_MESH1 - execution time: 0.0 - module: Mesh - sub module: Establish - version: v1 (2018-08-15) - CI ready: 'No' - level: Integration - allow fail: '' - -.mesh_init_all_duts: &mesh_init_all_duts - LIST_MERGE: - - - 'MSSC SSC[1-] mesh -I' - - ['P SSC[1-] C +MESH:INIT,OK'] - -.mesh_start_all_duts: &mesh_start_all_duts - LIST_MERGE: - - - 'MSSC SSC[1-] mesh -T' - - ['P SSC[1-] C +MESH:START,OK'] - -.mesh_config_all_duts: &mesh_config_all_duts - LIST_MERGE: - - - 'MSSC SSC[1-] meshset -M -o 0 -t -e -l 10' - - ['P SSC[1-] C +MESHSET:MAP_AUTH,OK'] - - - 'MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i ' - - ['P SSC[1-] C +MESHSET:CFG,OK'] - - - 'MSSC SSC[1-] meshset -L -o 0 -l ' - - ['P SSC[1-] C +MESHSET:MLAYER,OK'] - - - 'MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC[1-] C +MESHSET:SWITCH,OK'] - - - 'MSSC SSC[1-] meshset -K -o 0 -i ' - - ['P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK'] - - - 'MSSC SSC[1-] meshset -J -o 0 -t ' - - ['P SSC[1-] C +MESHSET:ASSOC,OK'] - -.mesh_config_all_duts_no_router: &mesh_config_all_duts_no_router - LIST_MERGE: - - - 'SSC SSC1 meshset -T -o 0 -t 1' - - ['P SSC1 C +MESHSET:TYPE,OK'] - - - 'MSSC SSC[2-] meshset -X -o 0 -i 1' - - ['P SSC[2-] C +MESHSET:FIX_ROOT,OK'] - - - 'MSSC SSC[1-] meshset -M -o 0 -t -e -l 10' - - ['P SSC[1-] C +MESHSET:MAP_AUTH,OK'] - - - 'SSC SSC[1-] meshset -G -o 0 -m -n -t -e - -i ' - - ['P SSC[1-] C +MESHSET:CFG,OK'] - - - 'MSSC SSC[1-] meshset -L -o 0 -l ' - - ['P SSC[1-] C +MESHSET:MLAYER,OK'] - - - 'MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC[1-] C +MESHSET:SWITCH,OK'] - - - 'MSSC SSC[1-] meshset -K -o 0 -i ' - - ['P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK'] - - - 'MSSC SSC[1-] meshset -J -o 0 -t ' - - ['P SSC[1-] C +MESHSET:ASSOC,OK'] - -.mesh_config_dut1: &mesh_config_dut1 - LIST_MERGE: - - - 'SSC SSC1 meshset -M -o 0 -t -e -l 10' - - ['P SSC1 C +MESHSET:MAP_AUTH,OK'] - - - 'SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i ' - - ['P SSC1 C +MESHSET:CFG,OK'] - - - 'SSC SSC meshset -L -o 0 -l ' - - ['P SSC1 C +MESHSET:MLAYER,OK'] - - - 'SSC SSC1 meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC1 C +MESHSET:SWITCH,OK'] - - - 'SSC SSC1 meshset -K -o 0 -i ' - - - 'SSC SSC1 meshset -K -o 0 -i ' - - ['P SSC1 C +MESHSET:ALLOW_ROOTS,OK'] - - - 'SSC SSC1 meshset -J -o 0 -t ' - - ['P SSC1 C +MESHSET:ASSOC,OK'] - -.mesh_config_dut1_no_router: &mesh_config_dut1_no_router - LIST_MERGE: - - - 'SSC SSC1 meshset -T -o 0 -t 1' - - ['P SSC1 C +MESHSET:TYPE,OK'] - - - 'SSC SSC1 meshset -M -o 0 -t -e -l 10' - - ['P SSC1 C +MESHSET:MAP_AUTH,OK'] - - - 'SSC SSC1 meshset -G -o 0 -m -n -t -e - -i ' - - ['P SSC1 C +MESHSET:CFG,OK'] - - - 'SSC SSC1 meshset -L -o 0 -l ' - - ['P SSC1 C +MESHSET:MLAYER,OK'] - - - 'SSC SSC1 meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC1 C +MESHSET:SWITCH,OK'] - - - 'SSC SSC1 meshset -K -o 0 -i ' - - - 'SSC SSC1 meshset -K -o 0 -i ' - - ['P SSC1 C +MESHSET:ALLOW_ROOTS,OK'] - - - 'SSC SSC1 meshset -J -o 0 -t ' - - ['P SSC1 C +MESHSET:ASSOC,OK'] - -.mesh_config_cs_duts: &mesh_config_cs_duts - LIST_MERGE: - - - 'MSSC SSC[4-] meshset -M -o 0 -t -e -l 10' - - ['P SSC[4-] C +MESHSET:MAP_AUTH,OK'] - - - 'MSSC SSC[4-] meshset -G -o 0 -m -s -p -n -h 1 -t - -e -i ' - - ['P SSC[4-] C +MESHSET:CFG,OK'] - - - 'MSSC SSC[4-] meshset -L -o 0 -l ' - - ['P SSC[4-] C +MESHSET:MLAYER,OK'] - - - 'MSSC SSC[4-] meshset -W -o 0 -t -n -l -i -k ' - - ['P SSC[4-] C +MESHSET:SWITCH,OK'] - - - 'MSSC SSC[4-] meshset -K -o 0 -i ' - - ['P SSC[4-] C +MESHSET:ALLOW_ROOTS,OK'] - - - 'MSSC SSC[4-] meshset -J -o 0 -t 15' - - ['P SSC[4-] C +MESHSET:ASSOC,OK'] - -.mesh_check_tree_num: &mesh_check_tree_num - LIST_MERGE: - - - 'MSSC SSC[1-] mesh -Q -o 2' - - ['P SSC[1-] T topo'] - - - 'MESHTREE' - - ['R PC_COM RE "MESHTREE:%%s"%%()'] - -.mesh_tree_stably: &mesh_tree_stably - LIST_MERGE: - - - 'SSC MNODE(0) mesh -Q -o 1 -t ' - - ['R MNODE(0) C MESH_STABLE_CHECK:PASS'] - -.est_performance_cmd_set: &est_performance_cmd_set - LIST_MERGE: - - - 'test_counts = 15' - - [''] - - - 'start_number_list = [0]' - - [''] - - - 'ie_encrypt = True' - - [''] - - - 'establish_fail_time = 1200' - - [''] - - - 'assoc_time = 20' - - [''] - - - 'stable_time = 120' - - [''] - - - 'map_encrypt = True' - - [''] - - - 'destroy_mode = "deinit"' - - [''] - -test cases: -- ID: MESH_EST_0101 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n 15 -t - - - R SSC1 C +MESHSET:CFG,FAIL - - - SSC SSC1 meshset -G -o 0 -m -s -p -n -t 11 - - - R SSC1 C +MESHSET:CFG,FAIL - - - SSC SSC1 meshset -G -o 0 -m -s -p -n -t 0 - - - R SSC1 C +MESHSET:CFG,FAIL - - - SSC SSC1 meshset -G -o 0 -m -n -t - - - R SSC1 C +MESHSET:CFG,FAIL - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 meshset -G -o 1 - - - P SSC1 RE "MESH_ID,%%s"%%() - - P SSC1 C +MESHGET:CFG,OK - expected result: |- - 1. fail - 2. fail - 3. fail - 4. fail - 5. succeed - steps: |- - 1. mesh init - 2. set config with channel 15 - 3. set config with max_connection 0 / 11 - 4. set config without router ssid - 5. set/get valid config - test environment: SSC_T1_MESH1 - summary: mesh set/get config before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0102 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -S -o 0 -t 0 - - - P SSC1 C +MESHSET:SCAN_TIME,FAIL - - - SSC SSC1 meshset -S -o 0 -t 2000 - - - P SSC1 C +MESHSET:SCAN_TIME,FAIL - - - SSC SSC1 meshset -S -o 0 -t 500 - - - P SSC1 C +MESHSET:SCAN_TIME,OK - - - SSC SSC1 meshset -S -o 1 - - - P SSC1 C +MESHGET:SCAN_TIME,OK,500 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. set invalid scan time - 3. set/get valid scan time - test environment: SSC_T1_MESH1 - summary: mesh set/get passive scan time before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0103 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -Q -o 0 -i 15 - - - P SSC1 C +MESHSET:QSIZE,FAIL - - - SSC SSC1 meshset -Q -o 0 -i 40 - - - P SSC1 C +MESHSET:QSIZE,OK - - - SSC SSC1 meshset -Q -o 1 - - - P SSC1 C +MESHGET:QSIZE,OK,40 - expected result: |- - 1. succeed - 2. fail - 3. succeed - steps: |- - 1. mesh init - 2. set invalid qsize - 3. set/get valid qsize - test environment: SSC_T1_MESH1 - summary: mesh set/get qsize before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0104 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -P -o 0 -n 0 - - - P SSC1 C +MESHSET:PERCENT,FAIL - - - SSC SSC1 meshset -P -o 0 -n 110 - - - P SSC1 C +MESHSET:PERCENT,FAIL - - - SSC SSC1 meshset -P -o 0 -n 100 - - - P SSC1 C +MESHSET:PERCENT,OK - - - SSC SSC1 meshset -P -o 1 - - - P SSC1 C +MESHGET:PERCENT,OK,1 - expected result: |- - 1. succeed - 2. fail - 3. succeed - steps: |- - 1. mesh init - 2. set invalid vote percentage - 3. set/get valid vote percentage - test environment: SSC_T1_MESH1 - summary: mesh set/get vote percentage before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0105 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK -# - - SSC SSC1 meshset -Z -x 1 -o 0 -t 300 -l 3000 -# - - P SSC1 C +MESHSET:ANNOUNCE,FAIL -# - - SSC SSC1 meshset -Z -x 1 -o 0 -t 500 -l 1000 -# - - P SSC1 C +MESHSET:ANNOUNCE,FAIL - - - SSC SSC1 meshset -Z -x 1 -o 0 -t 500 -l 3000 - - - P SSC1 C +MESHSET:ANNOUNCE,OK - - - SSC SSC1 meshset -Z -x 1 -o 1 - - - P SSC1 C +MESHGET:ANNOUNCE,OK,500,3000 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. set invalid announce interval - 3. set/get valid announce interval - test environment: SSC_T1_MESH1 - summary: mesh set/get announce interval before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0106 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -J -o 0 -t 9 - - - P SSC1 C +MESHSET:ASSOC,FAIL - - - SSC SSC1 meshset -J -o 0 -t 10 - - - P SSC1 C +MESHSET:ASSOC,OK - - - SSC SSC1 meshset -J -o 1 - - - P SSC1 C +MESHGET:ASSOC,OK,10 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. set invalid assoc expire - 3. set/get valid assoc expire - test environment: SSC_T1_MESH1 - summary: mesh set/get assoc expire before mesh start - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0107 #TODO: support max_layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -L -o 0 -l 0 - - - P SSC1 C +MESHSET:MLAYER,FAIL - - - SSC SSC1 meshset -L -o 0 -l -1 - - - P SSC1 C +MESHSET:MLAYER,FAIL - - - SSC SSC1 meshset -L -o 0 -l 65537 - - - P SSC1 C +MESHSET:MLAYER,FAIL -# - - SSC SSC1 meshset -L -o 0 -l 26 -# - - P SSC1 C +MESHSET:MLAYER,FAIL - - - SSC SSC1 meshset -L -o 0 -l 1 - - - P SSC1 C +MESHSET:MLAYER,OK - - - SSC SSC1 meshset -L -o 1 - - - P SSC1 C +MESHGET:MLAYER,OK,1 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. set invalid max_layer - 3. set/get valid max_layer - test environment: SSC_T1_MESH1 - summary: mesh set/get max_lay test - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0108 #TODO: map_password can only be set in esp_mesh_set_config - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -M -o 0 -t -e -l 10 - - - P SSC1 C +MESHSET:MAP_AUTH,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 meshset -o 0 -L -l 2 - - - P SSC1 C +MESHSET:MLAYER,OK - - - SSC SSC1 meshset -P -o 0 -n 60 - - - P SSC1 C +MESHSET:PERCENT,OK - - - SSC SSC1 meshset -o 0 -J -t 20 - - - P SSC1 C +MESHSET:ASSOC,OK - - - SSC SSC1 meshset -o 0 -K -i 1 - - - P SSC1 C +MESHSET:ALLOW_ROOTS,OK - - - SSC SSC1 meshset -S -o 0 -t 500 - - - P SSC1 C +MESHSET:SCAN_TIME,OK - - - SSC SSC1 meshset -W -o 0 -t -n -l -i -k - - - P SSC1 C +MESHSET:SWITCH,OK - - - SSC SSC1 meshset -H -o 0 -t -i -l - - - P SSC1 C +MESHSET:THRESHOLD,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init - 2. set invalid max_layer - 3. set/get valid max_layer - test environment: SSC_T1_MESH1 - summary: mesh set all configurations in order - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0110 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -o 0 -L -l 1 - - - P SSC[1-2] C +MESHSET:MLAYER,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - P SSC[1-2] C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config two duts with max_lay = 0 - 2. start mesh - 3. check ..... - test environment: SSC_T2_MESH1 - summary: two duts establish mesh network with max layer = 1 - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0111 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e [,] -i 0 - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 20 - - - P PC_COM C DELAYDONE - - P SSC2 NC MESH_EVENT_CONNECTED - - P SSC1 NC MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config two duts with different map_password and ie not encrypted - 2. start mesh - 3. check not connected - test environment: SSC_T2_MESH1 - summary: two duts establish mesh network with different map_password - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0112 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i [0,1] - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - P SSC[1-2] C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config two duts with different ie_encrypt - 2. start mesh - 3. check both connected with router - test environment: SSC_T2_MESH1 - summary: two duts establish mesh network with different ie_encrypt - test point 2: mesh configuration test - CI ready: 'Yes' -- ID: MESH_EST_0113 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - [,] -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - P SSC2 C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config two duts with different channel - 2. start mesh - 3. check dut1 connected and dut2 disconnected - test environment: SSC_T2_MESH1 - summary: two duts establish mesh network with different channel - test point 2: mesh configuration test - CI ready: 'No' - #TODO: not work after v3.3 -- ID: MESH_EST_0114 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -o 0 -L -l [2,1] - - - P SSC[1-2] C +MESHSET:MLAYER,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 60 - - - '' - - - SSC SSC[1-2] mesh -Q -o 2 - - - P SSC[1-2] T topo - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. config two duts with different max_layer [2,1] - 2. start dut1(max_layer=2) first - 3. dut1 connected with router then start dut2(max_layer=1) - 4. check ..... - test environment: SSC_T2_MESH1 - summary: (ASSERT) two duts establish mesh network with different max_layer[2,1] - test point 2: mesh configuration test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0115 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] mesh -I - - - P SSC[1-3] C +MESH:INIT,OK - - - SSC SSC[1-3] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-3] C +MESHSET:CFG,OK - - - SSC SSC[1-3] meshset -o 0 -L -l 2 - - - P SSC[1-3] C +MESHSET:MLAYER,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - SSC SSC1 mesh -Q -o 3 - - - '' - - - DELAY 5 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - - - SSC SSC3 mesh -T - - - P SSC3 C +MESH:START,OK - - - SSC SSC[1-3] mesh -Q -o 3 - - - '' - - - DELAY 10 - - - P SSC3 C MESH_EVENT_NO_PARENT_FOUND - - - DELAY 60 - - - '' - - - SSC SSC[1-3] mesh -Q -o 2 - - - P SSC[1-3] T topo -# TODO: check more? - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. config 3 duts with different max_layer=2 and max_connect=1 - 2. start dut1(max_layer=2) first - 3. dut1 connected with router then start dut2(max_layer=1) - 3. dut1 connected with router then start dut2(max_layer=1) - 4. check ..... - test environment: SSC_T3_MESH1 - summary: 3 duts establish mesh network with max_connection 1 and max_layer 2 - test point 2: mesh configuration test - CI ready: 'No' -- ID: MESH_EST_0201 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config - 3. mesh start - 4. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: dut1 establish mesh network with simple configuration - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0202 - <<: *MESH_CASE - cmd set: - - '' - - - LOOP 2 6 "[2,3]" - - - '' - - - SSC SSC1 reboot - - - P SSC1 C !!!ready!!! - - - SSC SSC1 op -S -o {%d} - - - P SSC1 C +MODE:OK - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. set wifi op_mode (AP/APSTA) - 2. mesh init - 3. mesh config - 4. mesh start - 5. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: dut1 start mesh in different wifi mode (AP/APSTA) - test point 2: network establish test - CI ready: 'No' -#TODO: add case: start mesh with station connected -- ID: MESH_EST_0203 #TODO: which step call wifi scan - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 sta -S - - - P SSC1 C +SCAN_DONE:OK - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. wifi scan - 2. mesh init - 3. mesh config - 4. mesh start - 5. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: dut1 start mesh during wifi scan - test point 2: network establish test - CI ready: 'No' -- ID: MESH_EST_0204 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - P SSC1 C +JAP:CONNECTED - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. connect to router - 2. mesh init - 3. mesh config - 4. mesh start - 5. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: dut1 start mesh after wifi connected with router - test point 2: network establish test - CI ready: 'Yes' -#TODO: start during connecting to router -- ID: MESH_EST_0205 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config with max_layer 1 - 3. mesh start - 4. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: dut1 start mesh with max layer 1, establish mesh network - test point 2: network establish test - CI ready: 'No' -- ID: MESH_EST_0206 - <<: *MESH_CASE - cmd set: - - '' - - - SOC SOC1 LISTEN ' - - - P SOC_COM L OK - - - SSC MNODE(0) mesh -S -o 0 -i -t - - - P MNODE(0) C +CONNECT,OK - - P SOC1 C ACCEPT - - - SOC SOC1 MACCEPT GSOC1 - - - P SOC_COM L OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. mesh network already established - 2. root connect to TCP server - initial condition: MESH_INIT1 - test environment: SSC_T1_MESH2 - summary: dut1 establish mesh network, then root connect to TCP server - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0207 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config - 3. mesh start - 4. check mesh tree established and stable - test environment: SSC_T2_MESH1 - summary: two duts start mesh together to establish mesh network - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0208 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i 0 - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config without ie_encrypt - 3. mesh start - 4. check mesh tree established and stable - test environment: SSC_T2_MESH1 - summary: two duts start mesh without ie_encrypt, establish mesh network - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0209 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config without map_password - 3. mesh start - 4. check mesh tree established and stable - test environment: SSC_T2_MESH1 - summary: two duts start mesh without map_password, establish mesh network - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0210 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. start mesh on dut1 - 2. dut1 connected with router - 3. start mesh on dut2 - 4. dut2 connected with dut1 - test environment: SSC_T2_MESH1 - summary: dut2 start mesh after dut1 connected, establish mesh network - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0211 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - DELAY 10 30 - - - '' - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. start mesh on dut1 - 2. dut1 connected with router - 3. delay some time then start mesh on dut2 - 4. dut2 connected with dut1 - test environment: SSC_T2_MESH1 - summary: dut2 start mesh after dut1 connected more than 10s, establish mesh network - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0212 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -o 0 -L -l 1 - - - P SSC[1-2] C +MESHSET:MLAYER,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 60 - - - '' - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config two duts with max_lay = 1 - 2. start mesh - 3. check ..... - sub module: Establish - test environment: SSC_T2_MESH1 - summary: (ASSERT) 2 duts start mesh with max_layer=1, establish mesh network - test point 2: network establish test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0213 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-12] mesh -I - - - P SSC[1-12] C +MESH:INIT,OK - - - MSSC SSC[1-12] meshset -G -o 0 -m -s -p -n - -b -t 10 -e -i - - - P SSC[1-12] C +MESHSET:CFG,OK - - - MSSC SSC[1-12] meshset -o 0 -L -l 2 - - - P SSC[1-12] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-11] mesh -T - - - P SSC[1-11] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config 11 duts with max_layer=2 and mac_connection=10 - 2. 11 duts start mesh - 3. check mesh network establish - sub module: Establish - test environment: SSC_T12_MESH1 - summary: establish special mesh_network with max_lay=2 and max_connection=10 - test point 2: network establish test - CI ready: 'No' -- ID: MESH_EST_0214 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-7] mesh -I - - - P SSC[1-7] C +MESH:INIT,OK - - - MSSC SSC[1-7] meshset -G -o 0 -m -s -p -n - -b -t 2 -e -i - - - P SSC[1-7] C +MESHSET:CFG,OK - - - MSSC SSC[1-7] meshset -o 0 -L -l 3 - - - P SSC[1-7] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-7] mesh -T - - - P SSC[1-7] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE 7 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config 7 duts with max_lay=3 and max_connection=2 - 2. 7 duts start mesh - 3. check mesh network establish - sub module: Establish - test environment: SSC_T12_MESH1 - summary: set max_conn=2 and max_layer=3, establish full mesh tree - test point 2: network establish test - CI ready: 'No' -# TODO: full tree, destroy and re-establish -- ID: MESH_EST_0215 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-25] mesh -I - - - P SSC[1-25] C +MESH:INIT,OK - - - MSSC SSC[1-25] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-25] C +MESHSET:CFG,OK - - - MSSC SSC[1-25] meshset -o 0 -L -l 25 - - - P SSC[1-25] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-25] mesh -T - - - P SSC[1-25] C +MESH:START,OK - - - DELAY 120 - - - '' - - - VALUE 25 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config 25 duts with max_connection=1 - 2. 25 duts start mesh - 3. check mesh network establish - test environment: SSC_T50_MESH1 - summary: establish special mesh_network with max_connection=1 and max_layer=25 - test point 2: network establish test - CI ready: 'Yes' -- ID: MESH_EST_0216 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config all duts with simple configuration - 2. all duts start mesh - 3. check mesh network establish - test environment: SSC_T50_MESH1 - summary: multiple nodes establish mesh_network simple configuration - test point 2: network establish test - CI ready: 'Yes' - -- ID: MESH_EST_0301 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 5 - - - P MNODE(0,0) C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, then reboot root - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0302 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) mesh -I -o 1 - - - P MNODE(0,0) C MESH:DEINIT,OK - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. layer2 stop mesh - 2. root find child leave - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, then layer2 stop mesh - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0303 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - DELAY 5 - - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 15 - - - P MNODE(0,0) C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. power reset root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, then power reset root - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0304 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - SSC MNODE(0) op -S -o 2 - - - P MNODE(0) C +MODE:OK - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 15 - - - P MNODE(0,0) C MESH_EVENT_CONNECTED,1 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. power reset root and - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, power reset root and switch to softAP mode - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0305 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -V -o 2 - - - P MNODE(0) C MESH:SAVE,OK - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - SSC MNODE(0) mesh -T -o 2 - - - P MNODE(0) C MESH:START,OK - - - DELAY 10 - - - P MNODE(0) C MESH_EVENT_CONNECTED,1 - - P MNODE(0,0) C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root set auto start mesh and power reboot - 2. it become root again and the other node join - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, root restart mesh, it still root - test point 2: network destroy test - CI ready: 'No' - #TODO: root still root after restart will not run on CI -- ID: MESH_EST_0306 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0,0) - - - P MNODE(0,0) C !!!ready!!! - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. power reset layer2 - 2. root find child leave - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: 2 duts establish mesh network, then power reset layer2 - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0307 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -I -o 1 - - - P MNODE(0) C MESH:DEINIT,OK - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root mesh stop - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, root mesh stop - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0308 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, reboot root - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0309 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. power reboot root - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, power reboot root - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0310 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -V -o 2 - - - P MNODE(0) C MESH:SAVE,OK - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - SSC MNODE(0) mesh -T -o 2 - - - P MNODE(0) C MESH:START,OK - - - DELAY 10 - - - P MNODE(0) C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root set auto start mesh and power reboot - 2. it become root again and the other node join - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes establish mesh network, root restart mesh, it still root - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0311 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) mesh -I -o 1 - - - P MNODE(0,0) C MESH:DEINIT,OK - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. one of layer2 nodes mesh deinit - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, one of layer2 nodes mesh deinit - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0313 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot one of layer2 nodes - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, reboot one of layer2 nodes - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0314 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0,0) - - - P MNODE(0,0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot one of layer2 nodes - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, power reset one of layer2 nodes - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0315 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) mesh -I -o 1 - - - P MNODE(0,-1) C MESH:DEINIT,OK - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. one of leaf nodes mesh stop - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, one of leaf nodes mesh stop - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0316 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,-1) reboot - - - P MNODE(0,-1) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot one of leaf nodes - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, reboot one of leaf nodes - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0317 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0,-1) - - - P MNODE(0,-1) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot one of leaf nodes - 2. others re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, power reset one of leaf nodes - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0318 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -V -o 2 - - - P MNODE(0) C MESH:SAVE,OK - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - SSC MNODE(0) mesh -T -o 2 - - - P MNODE(0) C MESH:START,OK - - - DELAY 10 - - - P MNODE(0) C MESH_EVENT_CONNECTED,1 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root restart mesh with same configuration - 2. re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, root reboot and start mesh, it still root - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0319 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -V -o 2 - - - P MNODE(0) C MESH:SAVE,OK - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - SSC MNODE(0) mesh -T -o 2 - - - P MNODE(0) C MESH:START,OK - - - DELAY 10 - - - P MNODE(0) C MESH_EVENT_CONNECTED,1 - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root restart mesh with same configuration - 2. re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, root power reset and start mesh, it still root - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0320 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -V -o 2 - - - P MNODE(0) C MESH:SAVE,OK - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY 1 5 - - - '' - - - SSC MNODE(0) mesh -T -o 2 - - - P MNODE(0) C MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root restart mesh with same configuration - 2. re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, root reboot and wait some time, then start mesh - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0321 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - - - FREBOOT SSC1 - - - P SSC1 C !!!ready!!! - - - DELAY 10 - - - P SSC2 C MESH_EVENT_DISCONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set dut2 ap mode, dut1 start mesh and connect to dut2 - 2. power reset dut2 (station mode), check dut1 disconnected - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: power off router, check root disconnected - test point 2: network destroy test - CI ready: 'Yes' -- ID: MESH_EST_0322 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - - - FREBOOT SSC1 - - - P SSC1 C !!!ready!!! - - - DELAY 10 - - - P SSC2 C MESH_EVENT_DISCONNECTED - - - DELAY 30 - - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set dut2 ap mode, dut1 start mesh and connect to dut2 - 2. power reset dut2 (station mode), check dut1 disconnected - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: power off router for a while, check root connected - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0323 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - - - SSC SSC1 ap -K -a 1 - - - P SSC1 C +AP:KICK - - P SSC2 C MESH_EVENT_DISCONNECTED C MESH_EVENT_CONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set dut2 ap mode, dut1 start mesh and connect to dut2 - 2. router deauth root, check dut1 disconnected then connected - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: router deauth root, check root disconnected then connected - test point 2: network destroy test - CI ready: 'Yes' -#TODO: waive root -- ID: MESH_EST_0324 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -W -o 0 -t 100 - - - P MNODE(0) C +MESH:VOTE,OK - - - DELAY 1 3 - - - '' - - - FREBOOT MNODE(0) - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. waive_root and power reset root - 2. re-establish network - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, root waive vote after network established, then power reboot root - test point 2: network destroy test - CI ready: 'No' -- ID: MESH_EST_0501 #TODO: support layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l 1000 - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config all duts with max_connection=1 and max_layer>127 - 2. all duts start mesh - 3. check mesh network establish - sub module: Establish - test environment: SSC_T50_MESH1 - summary: (chain) establish mesh_network with max_connection=1 and max_layer>127 - test point 2: chain topology test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0502 #TODO: support layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l 1000 - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config all duts with max_layer>127 - 2. all duts start mesh - 3. check mesh network establish - sub module: Establish - test environment: SSC_T50_MESH1 - summary: (chain) establish mesh_network with max_layer>127 - test point 2: chain topology test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0503 #TODO: support layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -o 0 -L -l [127,128] - - - P SSC[1-2] C +MESHSET:MLAYER,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 60 - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. set a node with max_layer 127 and another 128 - 2. 2 duts start mesh - 3. check mesh network establish - sub module: Establish - test environment: SSC_T2_MESH1 - summary: (chain) set a node with max_layer 126 and another 127, establish mesh_network - test point 2: chain topology test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0504 #TODO: support layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l 1000 - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config all duts with max_layer>127 - 2. all duts start mesh - 3. check mesh network establish - 4. reboot root, others re-establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: (chain) (ASSERT) establis mesh_network first, then reboot root - test point 2: chain topology test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0505 #TODO: support layer>127 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l 1000 - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. config all duts with max_layer>127 - 2. all duts start mesh - 3. check mesh network establish - 4. reboot leaf, others re-establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: (chain) (ASSERT) establis mesh_network first, then reboot leaf - test point 2: chain topology test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_0601 - <<: *MESH_CASE - cmd set: - - MeshStress/MeshChannelSwitch - - - 'simple_test = True' - - [''] - expected result: |- - 1. succeed - steps: |- - 1. channel switch function test - sub module: Establish - test environment: SSC_T6_MESH1 - summary: (channel switch) channel switch function test - test point 2: channel switch test - CI ready: 'No' - auto test: 'Yes' -- ID: MESH_EST_0602 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t - - - P SSC[1-2] C +SAP:OK - - - SSC SSC2 op -S -o 1 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - SSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - DELAY 30 - - - P SSC2 C +SOFTAP:STACONNECTED - - - DELAY 20 - - - '' - - *mesh_check_tree_num - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1,dut2 set esp32 softAP in different channel - 2. dut[3-] start mesh and connected with dut1 - 3. reboot dut1's softAP, check dut[3-] connected with dut2 - sub module: Establish - test environment: SSC_T50_MESH1 - summary: stop router1,mesh network switch to another channel router network - test point 2: channel switch test - CI ready: 'No' - auto test: 'Yes' -- ID: MESH_EST_0603 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t - - - P SSC[1-2] C +SAP:OK - - - SSC SSC2 op -S -o 1 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - MSSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - FREBOOT SSC1 - - - P SSC1 C !!!ready!!! - - - DELAY 30 - - - P SSC2 C +SOFTAP:STACONNECTED - - - DELAY 20 - - - '' - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1,dut2 set esp32 softAP in different channel - 2. dut[3-] start mesh and connected with dut1 - 3. stop dut1's softAP, check dut[3-] connected with dut2 - sub module: Establish - test environment: SSC_T50_MESH1 - summary: power reset router1,mesh network switch to another channel router network - test point 2: channel switch test -- ID: MESH_EST_0604 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t - - - P SSC[1-2] C +SAP:OK - - - SSC SSC2 op -S -o 1 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - SSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:6 - - - SSC SSC2 mac - - - P SSC2 A :\+APMAC:(.+)\r\n - - - SSC MNODE(0) mesh -H -m -n 7 -t 10 - - - P MNODE(0) C MESH:SWITCH_CHANNEL,OK - - - DELAY - - - P SSC2 C +SOFTAP:STACONNECTED - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. dut[1-2]set esp32 softAP in channel [6,7] - 2. dut[3-] start mesh and connected with dut1 - 3. root switch channel to new channel 7 - 4. check dut[3-] disconnected with dut1,connected to dut2,and switch to new channel - sub module: Establish - test environment: SSC_T50_MESH1 - summary: root switch channel,mesh form old network switch to another channel router network - test point 2: channel switch test -- ID: MESH_EST_0605 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] op -S -o 2 - - - P SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] ap -S -s -p -n [1,6,11] -t - - - P SSC[1-3] C +SAP:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - - MSSC SSC[4-] meshset -M -o 0 -t -e -l 10 - - - P SSC[4-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[4-] meshset -G -o 0 -m -s -p -n 1 -h 1 -t - -e -i - - - P SSC[4-] C +MESHSET:CFG,OK - - - MSSC SSC[4-] meshset -L -o 0 -l - - - P SSC[4-] C +MESHSET:MLAYER,OK - - - MSSC SSC[4-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[4-] C +MESHSET:SWITCH,OK - - - MSSC SSC[4-] meshset -K -o 0 -i - - - P SSC[4-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[4-] meshset -J -o 0 -t - - - P SSC[4-] C +MESHSET:ASSOC,OK - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - VALUE -3 - - - R PC_COM L OK - - - DELAY - - - '' - - *mesh_check_tree_num - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:1 - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - DELAY 60 - - - '' - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() NC ROOT_CONFLICT - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. dut[1-3]set esp32 softAP in channel [1,6,11] - 2. dut[4-] start mesh and connected with dut1 - 3. dut1 set sta mode - 4. check dut[4-] connected with router,and switch to new channel establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: stop router1,mesh choice switch to another channel router establish network - test point 2: channel switch test -- ID: MESH_EST_0606 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t - - - P SSC[1-2] C +SAP:OK - - - SSC SSC2 op -S -o 1 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - SSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - SSC MNODE(0) reboot - - - P MNODE(0) C !!!ready!!! - - - DELAY - - - P SSC2 C +SOFTAP:STACONNECTED - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1,dut2 set esp32 softAP in different channel - 2. dut[3-] start mesh and connected with dut1 - 3. stop dut1's softAP and reboot root, check mesh switch channel and establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: stop dut1's softAP and reboot root, mesh choice switch to another channel router establish network - test point 2: channel switch test -- ID: MESH_EST_0607 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1] op -S -o 2 - - - P SSC[1] C +MODE:OK - - - SSC SSC[1] ap -S -s -p -n 6 -t - - - P SSC[1] C +SAP:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - SSC SSC[1] ap -S -s -p -n 7 -t - - - P SSC[1] C +SAP:OK - - - DELAY 30 - - - P SSC1 C +SOFTAP:STACONNECTED - - - DELAY 20 - - - '' - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1,dut2 set esp32 softAP in different channel - 2. dut[2-] start mesh and connected with dut1 - 3. stop dut1's softAP and reboot root, check mesh switch channel and establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: router switch another channel, mesh choice switch to another channel establish network - test point 2: channel switch test -- ID: MESH_EST_0608 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - - SSC SSC[4] meshset -T -o 0 -t 1 - - - P SSC[4] C +MESHSET:TYPE,OK - - - MSSC SSC[5-] meshset -X -o 0 -i 1 - - - P SSC[5-] C +MESHSET:FIX_ROOT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[5-] C +MESH:START,OK - - - DELAY - - - P SSC[5-] C MESH_EVENT_CONNECTED - - - SSC SSC[1] op -S -o 2 - - - P SSC[1] C +MODE:OK - - - SSC SSC[1] ap -S -s -p -n 7 -t - - - P SSC[1] C +SAP:OK - - - DELAY - - - '' - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. no-router mesh network fix root - 2. dut[4-] start mesh and establish mesh network - 3. dut1 set ap mode in diffent channel,check mesh switch channel and establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: mesh set fix root, choice switch to another channel link new router - test point 2: channel switch test -- ID: MESH_EST_0609 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t - - - P SSC[1-2] C +SAP:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - - MSSC SSC[4-] meshset -M -o 0 -t -e -l 10 - - - P SSC[4-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[4-] meshset -G -o 0 -m -s -p -n 6 -h 1 -t - -e -i - - - P SSC[4-] C +MESHSET:CFG,OK - - - MSSC SSC[4-] meshset -L -o 0 -l - - - P SSC[4-] C +MESHSET:MLAYER,OK - - - MSSC SSC[4-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[4-] C +MESHSET:SWITCH,OK - - - MSSC SSC[4-] meshset -K -o 0 -i - - - P SSC[4-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[4-] meshset -J -o 0 -t - - - P SSC[4-] C +MESHSET:ASSOC,OK - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - VALUE -3 - - - R PC_COM L OK - - - DELAY - - - '' - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set two router in different channel - 2. all duts set channel to the first router - 3. check mesh network connected with the first router - sub module: Establish - test environment: SSC_T50_MESH1 - summary: two routers, set channel, establish network - test point 2: channel switch test -- ID: MESH_EST_0610 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] op -S -o 2 - - - P SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] ap -S -s -p -t -n - [,,] - - - P SSC[1-3] C +SAP:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() NC ROOT_CONFLICT - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC[4-] NC MESH_EVENT_DISCONNECTED - execution time: 2.0 - expected result: |- - 1. set router - 2. check network establish - initial condition: MESH_DEINIT_STA - steps: |- - 1. set three router with different channel - 2. start all nodes to establish mesh network - summary: multiple router, establish mesh network - test point 2: channel switch test - test environment: SSC_T50_MESH1 - CI ready: 'Yes' - auto test: 'Yes' -- ID: MESH_EST_0611 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] op -S -o 2 - - - P SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] ap -S -s -p -t -n - [,,] - - - P SSC[1-3] C +SAP:OK - - - SSC SSC[2-3] op -S -o 1 - - - P SSC[2-3] C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() NC ROOT_CONFLICT - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC[4-] NC MESH_EVENT_DISCONNECTED - - - SSC SSC[2-3] op -S -o 2 - - - P SSC[2-3] C +MODE:OK - - - FREBOOT SSC1 - - - P SSC1 C !!!ready!!! - - - DELAY - - - '' - - - SSC SSC[2-3] op -S -o 2 - - - P SSC[2-3] C +MODE:OK - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() NC ROOT_CONFLICT - execution time: 2.0 - expected result: |- - 1. establish mesh network - 2. power reset router and check restablish mesh network - initial condition: MESH_DEINIT_STA - steps: |- - 1. establish mesh network with channel and bssid allow switch - 2. power reset the the router, check the network connected with other router - summary: multiple router, network switch router - test point 2: channel switch test - test environment: SSC_T50_MESH1 -- ID: MESH_EST_0612 - <<: *MESH_CASE - cmd set: - - MeshStress/MeshNetworkDestroy - - - 'destroy_nodes = "MNODE(*,)"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_INIT_SWITCH - steps: |- - 1. enable all nodes establish network - 2. reboot all roots after network established - summary: multiple router, reboot all roots after network established - test point 2: channel switch test - test environment: SSC_T50_MESH1 -- ID: MESH_EST_0613 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n 6 -t - - - P SSC1 C +SAP:OK - - - MSSC SSC[2-] mesh -I - - - P SSC[2-] C +MESH:INIT,OK - - - MSSC SSC[2-] meshset -M -o 0 -t -e -l 10 - - - P SSC[2-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[2-] meshset -G -o 0 -m -s -p -n 6 -h 0 -t - -e -i - - - P SSC[2-] C +MESHSET:CFG,OK - - - MSSC SSC[2-] meshset -L -o 0 -l - - - P SSC[2-] C +MESHSET:MLAYER,OK - - - MSSC SSC[2-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[2-] C +MESHSET:SWITCH,OK - - - MSSC SSC[2-] meshset -K -o 0 -i - - - P SSC[2-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[2-] meshset -J -o 0 -t - - - P SSC[2-] C +MESHSET:ASSOC,OK - - - MSSC SSC[2-] mesh -T - - - P SSC[2-] C +MESH:START,OK - - - DELAY 60 - - - P SSC[2-] C MESH_EVENT_CONNECTED - - - SSC SSC1 ap -S -s -p -n 7 -t - - - P SSC1 C +SAP:OK - - - DELAY 30 - - - '' - - - MSSC SSC[2-] channel -G - - - P SSC[2-] C +CHANNEL:7 - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - - DELAY 60 - - - P MNODE(0,0,0) C MESH_EVENT_CONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 set esp32 softAP in channel 6 - 2. dut[2-] start mesh and connected with dut1 - 3. set dut1's softAP dfferent channel and reboot dut MNODE(0,0), check MNODE(0,0,0) CONNECTED - sub module: Establish - test environment: SSC_T50_MESH1 - summary: mesh tree channel switch follow router,reboot layer2 check layer3 - test point 2: channel switch test -- ID: MESH_EST_0614 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] op -S -o 2 - - - P SSC[1-2] C +MODE:OK - - - SSC SSC[1-2] ap -S -s -p -n [6,7] -t -h 1 - - - P SSC[1-2] C +SAP:OK - - - SSC SSC2 op -S -o 1 - - - P SSC2 C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - *mesh_config_cs_duts - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE -3 - - - R PC_COM L OK - - *mesh_check_tree_num - - - MSSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - DELAY - - - P SSC2 C +SOFTAP:STACONNECTED - - - DELAY 20 - - - '' - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:7 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1,dut2 set esp32 softAP in different channel - 2. dut[3-] start mesh and connected with dut1 - 3. stop dut1's softAP, check dut[3-] connected with hide dut2 - sub module: Establish - test environment: SSC_T50_MESH1 - summary: stop router1,mesh network switch to another channel hide router network - test point 2: channel switch test -- ID: MESH_EST_0615 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] op -S -o 2 - - - P SSC[1-3] C +MODE:OK - - - SSC SSC[1-3] ap -S -s -p -n [1,6,11] -t -h 1 - - - P SSC[1-3] C +SAP:OK - - - SSC SSC[2-3] op -S -o 1 - - - P SSC[2-3] C +MODE:OK - - - MSSC SSC[4-] mesh -I - - - P SSC[4-] C +MESH:INIT,OK - - - MSSC SSC[4-] meshset -M -o 0 -t -e -l 10 - - - P SSC[4-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[4-] meshset -G -o 0 -m -s -p -n 1 -h 1 -t - -e -i - - - P SSC[4-] C +MESHSET:CFG,OK - - - MSSC SSC[4-] meshset -L -o 0 -l - - - P SSC[4-] C +MESHSET:MLAYER,OK - - - MSSC SSC[4-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[4-] C +MESHSET:SWITCH,OK - - - MSSC SSC[4-] meshset -K -o 0 -i - - - P SSC[4-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[4-] meshset -J -o 0 -t - - - P SSC[4-] C +MESHSET:ASSOC,OK - - - MSSC SSC[4-] mesh -T - - - P SSC[4-] C +MESH:START,OK - - - VALUE -3 - - - R PC_COM L OK - - - DELAY - - - '' - - *mesh_check_tree_num - - - MSSC SSC[4-] channel -G - - - P SSC[4-] C +CHANNEL:1 - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - SSC SSC[2-3] op -S -o 2 - - - P SSC[2-3] C +MODE:OK - - - DELAY 60 - - - '' - - - MSSC SSC[4-] mesh -Q -o 2 - - - P SSC[4-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() NC ROOT_CONFLICT - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. dut[1-3]set esp32 softAP in channel [1,6,11] - 2. dut[4-] start mesh and connected with dut1 - 3. dut1 set sta mode - 4. check dut[4-] connected with router,and switch to new channel establish mesh network - sub module: Establish - test environment: SSC_T50_MESH1 - summary: stop router1,mesh choice switch to another hide channel router establish network - test point 2: channel switch test -- ID: MESH_EST_0616 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1-3] meshset -T -o 0 -t 1 - - - P SSC[1-3] C +MESHSET:TYPE,OK - - - MSSC SSC[4-] meshset -X -o 0 -i 1 - - - P SSC[4-] C +MESHSET:FIX_ROOT,OK - - - MSSC SSC[1-] meshset -M -o 0 -t -e -l 10 - - - P SSC[1-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -n 0 -h 1 -t - -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -L -o 0 -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[1-] C +MESHSET:SWITCH,OK - - - MSSC SSC[1-] meshset -K -o 0 -i - - - P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[1-] meshset -J -o 0 -t - - - P SSC[1-] C +MESHSET:ASSOC,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - VALUE - - - R PC_COM L OK - - - DELAY - - - '' - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. no-router mesh set three roots - 2. dut[1-] start mesh and establish mesh trees - 3. check mesh trees - sub module: Establish - test environment: SSC_T50_MESH1 - summary: mesh no router and set three roots, establish trees and check - test point 2: channel switch test -- ID: MESH_EST_0617 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -T -o 0 -t 1 - - - P SSC[1-2] C +MESHSET:TYPE,OK - - - MSSC SSC[3-] meshset -X -o 0 -i 1 - - - P SSC[3-] C +MESHSET:FIX_ROOT,OK - - - MSSC SSC[1-] meshset -M -o 0 -t -e -l 10 - - - P SSC[1-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -n 0 -h 1 -t - -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -L -o 0 -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[1-] C +MESHSET:SWITCH,OK - - - MSSC SSC[1-] meshset -K -o 0 -i - - - P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[1-] meshset -J -o 0 -t - - - P SSC[1-] C +MESHSET:ASSOC,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - VALUE - - - R PC_COM L OK - - - DELAY - - - '' - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "TREE_TOTAL_NODES:%%s"%%() - - - SSC SSC1 reboot - - - P SSC1 C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. no-router mesh set two roots - 2. dut[1-] start mesh and establish mesh trees - 3. reboot dut1,check establish mesh trees - sub module: Establish - test environment: SSC_T50_MESH1 - summary: mesh no router and set two roots, reboot one root establish tree and check mesh tree - test point 2: channel switch test -- ID: MESH_EST_0618 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1] meshset -T -o 0 -t 1 - - - P SSC[1] C +MESHSET:TYPE,OK - - - MSSC SSC[2-] meshset -X -o 0 -i 1 - - - P SSC[2-] C +MESHSET:FIX_ROOT,OK - - - MSSC SSC[1-] meshset -M -o 0 -t -e -l 10 - - - P SSC[1-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -n 6 -h 1 -t - -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -L -o 0 -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[1-] C +MESHSET:SWITCH,OK - - - MSSC SSC[1-] meshset -K -o 0 -i - - - P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[1-] meshset -J -o 0 -t - - - P SSC[1-] C +MESHSET:ASSOC,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - VALUE - - - R PC_COM L OK - - - DELAY - - - '' - - *mesh_check_tree_num - - - SSC SSC1 mesh -T -o 1 - - - P SSC1 C +MESH:STOP,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n 7 -h 1 -t - -e -i - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY - - - '' - - - MSSC SSC[1-] channel -G - - - P SSC[1-] C +CHANNEL:7 - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. no-router mesh set fix root - 2. dut[1-] start mesh and establish mesh trees - 3. stop dut1 set another channel then start,check establish mesh trees - sub module: Establish - test environment: SSC_T50_MESH1 - summary: no router change root to another channel, establish tree and check mesh tree - test point 2: channel switch test -- ID: MESH_EST_0619 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - SSC SSC[1] meshset -T -o 0 -t 1 - - - P SSC[1] C +MESHSET:TYPE,OK - - - MSSC SSC[2-] meshset -X -o 0 -i 1 - - - P SSC[2-] C +MESHSET:FIX_ROOT,OK - - - MSSC SSC[1-] meshset -M -o 0 -t -e -l 10 - - - P SSC[1-] C +MESHSET:MAP_AUTH,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -n 6 -h 1 -t - -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -L -o 0 -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] meshset -W -o 0 -t -n -l -i -k - - - P SSC[1-] C +MESHSET:SWITCH,OK - - - MSSC SSC[1-] meshset -K -o 0 -i - - - P SSC[1-] C +MESHSET:ALLOW_ROOTS,OK - - - MSSC SSC[1-] meshset -J -o 0 -t - - - P SSC[1-] C +MESHSET:ASSOC,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - VALUE - - - R PC_COM L OK - - - DELAY - - - '' - - *mesh_check_tree_num - - - SSC SSC1 mesh -H -n 7 -t 10 - - - P SSC1 C MESH:SWITCH_CHANNEL,OK - - - DELAY - - - '' - - - MSSC SSC[1-] channel -G - - - P SSC[1-] C +CHANNEL:7 - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. no-router mesh set fix root - 2. dut[1-] start mesh and establish mesh trees - 3. dut1 call channel switch API to another channel,check establish mesh trees - sub module: Establish - test environment: SSC_T50_MESH1 - summary: no router root call channel switch API, establish tree and check mesh tree - test point 2: channel switch test -- ID: MESH_EST_3001 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -t - - - P SSC1 C +MESHSET:CFG,FAIL - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -t - - - P SSC1 C +MESHSET:CFG,OK - expected result: |- - 1. fail - 2. succeed - steps: |- - 1. set config without init - 2. init and set config - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: mesh config without mesh init - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'Yes' -- ID: MESH_EST_3002 - <<: *MESH_CASE - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - cmd set: - - '' - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,FAIL - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,FAIL - expected result: |- - 1. fail - 2. fail - steps: |- - 1. mesh start without init - 2. mesh start without set config - summary: mesh start without init or config - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'Yes' -- ID: MESH_EST_3003 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 1 10 - - - '' - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. mesh init/config - 2. mesh start twice - test environment: SSC_T1_MESH1 - summary: mesh start again after mesh start - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'Yes' - #TODO: if start twice will connected successfully -- ID: MESH_EST_3003 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config with wrong channel - 3. mesh start - 4. check parent not found - test environment: SSC_T1_MESH1 - summary: mesh start with wrong router channel - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'No' - #TODO: not work after v3.3 -- ID: MESH_EST_3004 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - R SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -t - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 meshset -M -o 0 -t 8 -s -l 10 - - - P SSC1 C +MESHSET:MAP_AUTH,FAIL - - - SSC SSC1 meshset -M -o 0 -t 3 -s -l 100 - - - P SSC1 C +MESHSET:MAP_PWD,FAIL - - - SSC SSC1 meshset -E -o 0 -i 1 -s -l 100 - - - P SSC1 C +MESHSET:MIE_KEY,FAIL - expected result: |- - 1. succeed - 2. fail - 3. fail - 3. fail - steps: |- - 1. mesh init/config - 2. set map_password with auth=8 - 3. set map_password with len>64 - 4. set ie_key with len>64 - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: mesh config with parameter value overflow - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'Yes' -- ID: MESH_EST_3005 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config and switch wifi op_mode to station - 3. mesh start - 4. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: (ASSERT) switch to station mode after mesh config - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_3006 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config and switch wifi op_mode to station - 3. mesh start - 4. check mesh connected and layer is 1 - test environment: SSC_T1_MESH1 - summary: (ASSERT) switch to soft_ap mode after mesh config - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_3007 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -n -t - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init - 2. mesh config with inexistent router - 3. mesh start - 4. check mesh no parent found - test environment: SSC_T1_MESH1 - summary: start mesh with inexistent router - test point 1: abnormal/special use - test point 2: mesh init/config/start test - CI ready: 'Yes' -- ID: MESH_EST_3101 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) sta -S - - - P MNODE(0) C +SCANDONE - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P MNODE(0) NC MESH_EVENT_SCAN_DONE - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. establish mesh network - 2. wifi scan and check no MESH_EVENT_SCAN_DONE - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: (ASSERT) wifi scan on root without set self organized - test point 1: abnormal/special use - test point 2: use wifi api after mesh start - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_3102 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) sta -S - - - P MNODE(0,0) C +SCANDONE - - P MNODE(0,0) NC MESH_EVENT_SCAN_DONE - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. establish mesh network - 2. wifi scan and check no MESH_EVENT_SCAN_DONE - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: (ASSERT) wifi scan on layer2 without set self organized - test point 1: abnormal/special use - test point 2: use wifi api after mesh start - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_3103 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 1 - - - '' - - - SSC SSC1 sta -S - - - P SSC1 C +SCANDONE - - P SSC1 NC MESH_EVENT_SCAN_DONE - - - ASSERT - - - '' - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. establish mesh network - 2. wifi scan and check no MESH_EVENT_SCAN_DONE - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: (ASSERT) wifi scan during mesh scan without set self organized - test point 1: abnormal/special use - test point 2: use wifi api after mesh start - CI ready: 'No' - auto test: 'No' -- ID: MESH_EST_3104 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 5 - - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 ap -Q - - - R SSC2 A :\+APCONFIG:(\w+) - - - SSC SSC1 sta -C -s -p - - - P SSC1 C +JAP:DISCONNECTED - - - DELAY 10 - - - P PC_COM C DELAYDONE - - P SSC1 NC +JAP:CONNECTED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut2 start mesh - 2. dut1 connect to dut2, check disconnected - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: normal station can't connected with mesh root - test point 1: abnormal/special use - test point 2: use wifi api after mesh start - CI ready: 'Yes' -#TODO: one(some) of the nodes set wrong password, establish---- -- ID: MESH_EST_2001 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 meshset -U -o 0 -m -s -p -b -n - -t 1 -l 1 - - - P SSC1 C +MESHSET:PARENT,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. dut1 set parent be router - 3. start dut1 and check it connected with router - 4. start dut2 and check it connected with dut1 - test environment: SSC_T2_MESH1 - summary: set dut1 parent as router with mesh_id, dut2 without set_parent, check dut2 connected with dut1 - test point 1: manual network function - test point 2: set parent test - CI ready: 'Yes' -- ID: MESH_EST_2002 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 meshset -U -o 0 -s -p -b -n - -t 1 -l 1 - - - P SSC1 C +MESHSET:PARENT,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. set dut1 parent to router without mesh_id - 3. start dut1 and check it connected with router - 4. start dut2 and check it connected with dut1 - test environment: SSC_T2_MESH1 - summary: set dut1 parent to router without mesh_id, dut2 without set_parent, check dut2 connected with dut1 - test point 1: manual network function - test point 2: set parent test - CI ready: 'Yes' -- ID: MESH_EST_2003 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 meshset -U -o 0 -m -s -p -b -n - -t 1 -l 1 - - - P SSC1 C +MESHSET:PARENT,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 10 - - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. set dut1 parent to router - 3. start dut2 and check it connected with router - 4. start dut1 and check it connected with router - test environment: SSC_T2_MESH1 - summary: set dut1 parent to router, start dut1 with amother root already exists - test point 1: manual network function - test point 2: set parent test - CI ready: 'Yes' -- ID: MESH_EST_2004 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 ap -Q - - - R SSC1 A :\+APCONFIG:(\w+), - - - SSC SSC2 meshset -U -o 0 -m -s -p -n -t 2 -l 2 - - - P SSC2 C +MESHSET:PARENT,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. set dut2 parent to dut1 - 3. start dut1 and check it connected with router - 4. start dut2 and check it connected with dut1 - test environment: SSC_T2_MESH1 - summary: set dut2 parent to dut1(root), start dut2 after dut1 connected - test point 1: manual network function - test point 2: set parent test - CI ready: 'Yes' -- ID: MESH_EST_2005 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 ap -Q - - - R SSC1 A :\+APCONFIG:(\w+), - - - SSC SSC2 meshset -U -o 0 -s -p -n -t 2 -l 2 - - - P SSC2 C +MESHSET:PARENT,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. set dut2 parent to dut1 without mesh_id - 3. start dut1 and check it connected with router - 4. start dut2 and check it connected with dut1 - test environment: SSC_T2_MESH1 - summary: set dut2 parent to dut1(root) without mesh_id, start dut2 after dut1 connected - test point 1: manual network function - test point 2: set parent test - CI ready: 'Yes' -- ID: MESH_EST_2006 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] mesh -I - - - P SSC[1-3] C +MESH:INIT,OK - - - SSC SSC[1-3] meshset -G -o 0 -m [,,] -s -p -n - -b -t -e -i - - - P SSC[1-3] C +MESHSET:CFG,OK - - - SSC SSC[1,3] mesh -T - - - P SSC[1,3] C +MESH:START,OK - - P SSC[1,3] C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - - - SSC SSC3 ap -Q - - - R SSC3 A :\+APCONFIG:(\w+), - - - SSC SSC2 meshset -U -o 0 -m -s -p -n -t 2 -l 2 - - - P SSC2 C +MESHSET:PARENT,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_DISCONNECTED - - P SSC3 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - steps: |- - 1. mesh init/config - 2. dut1,dut3 start mesh with different mesh id - 3. dut2 connect to dut1 first - 4. set dut2's parent to dut3 - 5. check dut2 leave dut1 and join dut3 - test environment: SSC_T3_MESH1 - summary: set one node's parent to another mesh network - test point 1: manual network function - test point 2: set parent test - CI ready: 'No' -- ID: MESH_EST_2007 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 op -S -o 2 - - - P SSC2 C +MODE:OK - - - SSC SSC2 ap -S -s -n - - - P SSC2 C +SAP:OK - - - SSC SSC1 meshset -U -o 0 -s -n -t 1 -l 1 - - - P SSC1 C +MESHSET:PARENT,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - P SSC2 C +SOFTAP:STACONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. dut1 start mesh and establish network - 3. set dut2 softAP mode - 4. set dut1's parent to dut2 - test environment: SSC_T2_MESH1 - summary: set ont node's parent to another Router after connected - test point 1: manual network function - test point 2: set parent test - CI ready: 'No' -#- ID: MESH_EST_2008 -# <<: *MESH_CASE -# cmd set: -# - '' -# - - SSC SSC[1-2] mesh -I -# - - P SSC[1-2] C +MESH:INIT,OK -# - - SSC SSC[1-2] meshset -G -o 0 -m -s -n -t -i -# - - P SSC[1-2] C +MESHSET:CFG,OK -# - - SSC SSC1 meshset -U -o 0 -s -n -t 1 -l 1 -# - - P SSC1 C +MESHSET:PARENT,OK -# - - SSC SSC[1-2] mesh -T -# - - P SSC[1-2] C +MESH:START,OK -# - P SSC2 C MESH_EVENT_CONNECTED,2 -# - P SSC1 C MESH_EVENT_CHILD_CONNECTED -# expected result: |- -# 1. succeed -# 2. succeed -# 3. succeed -# 4. succeed -# steps: |- -# 1. mesh init/config -# 2. dut1 set parent to inexist router -# 3. start mesh -# 4. check dut2 connected with dut1 -# test environment: SSC_T2_MESH1 -# summary: set one node's parent to inexist router and establish network -# test point 1: manual network function -# test point 2: set parent test -# CI ready: 'Yes' -- ID: MESH_EST_2101 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC1 meshset -G -o 0 -m -n -t -e - -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - SSC SSC1 mesh -Q -o 2 - - - P SSC1 C IS_ROOT - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init/config dut1 no-router and set type root - 2. mesh start - 3. check dut1 is root - test environment: SSC_T1_MESH1 - summary: dut1 set type root, start mesh without router - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2102 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 mesh -Q -o 2 - - - P SSC1 C IS_ROOT - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init/config dut1 set type root - 2. mesh start - 3. check dut1 connected with router and type root - test environment: SSC_T1_MESH1 - summary: dut1 set type root, set router and start mesh - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2103 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC2 meshset -X -o 0 -i 1 - - - P SSC2 C +MESHSET:FIX_ROOT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -n -t -e - -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init/config all duts no-router, set dut1 root - 2. mesh start all duts - 3. check mesh tree established and stably - test environment: SSC_T2_MESH1 - summary: dut1 set type root, dut2 fix root, establish mesh network without router - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2104 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC1 meshset -G -o 0 -m -n -t -e - -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init/config all duts no-router, set dut1 root - 2. mesh start all duts - 3. check mesh tree established and stably - test environment: SSC_T2_MESH1 - summary: dut1 set type root without router, dut2 set router without set type, establish mesh network - test point 1: manual network function - test point 2: no-router function test - CI ready: 'No' -- ID: MESH_EST_2105 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC1 meshset -G -o 0 -m -n -t -e - -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 2 5 - - - '' - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 1 - - - P SSC1 C +MESHGET:TYPE,OK,0 - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 5 - - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC2 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. start one dut with root leaf - 2. check mesh type cleared after re-init mesh - 3. start mesh and let this dut be layer2 - test environment: SSC_T2_MESH1 - summary: check mesh root type info cleared after mesh re-init - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2106 - <<: *MESH_CASE - cmd set: - - '' - - *mesh_init_all_duts - - *mesh_config_all_duts_no_router - - *mesh_start_all_duts - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. mesh init/config all duts no-router, set dut1 root - 2. mesh start all duts - 3. check mesh tree established and stably - test environment: SSC_T50_MESH1 - summary: multiple nodes, establish mesh network without router - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2107 - <<: *MESH_CASE - cmd set: - - '' - - *mesh_init_all_duts - - *mesh_config_all_duts_no_router - - *mesh_start_all_duts - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC SSC1 reboot - - - P SSC1 C !!!ready!!! - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 50 - - - P SSC[2-] C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh no-router network - 2. root reboot - 3. check others can't connected - test environment: SSC_T50_MESH1 - summary: multiple nodes, establish mesh network without router, then root reboot - test point 1: manual network function - test point 2: no-router function test - CI ready: 'No' -- ID: MESH_EST_2108 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 0 -t 1 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC2 meshset -X -o 0 -i 1 - - - P SSC2 C +MESHSET:FIX_ROOT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -n -t -e - -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - MSSC SSC[1-2] meshset -A -n -t -l 15 -i - - - P SSC[1-2] C +MESHSET:ATTEMPTS,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - - P SSC2 C MESH_EVENT_DISCONNECTED - - - DELAY 40 - - - P SSC2 C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh no-router network - 2. root deinit - 3. check layer2 no parent found - test environment: SSC_T2_MESH1 - summary: no-router, root deinit and check layer2 no parent found - test point 1: manual network function - test point 2: no-router function test - CI ready: 'No' -- ID: MESH_EST_2109 - <<: *MESH_CASE - cmd set: - - '' - - *mesh_init_all_duts - - *mesh_config_all_duts_no_router - - - MSSC SSC[1-] meshset -A -n -t -l 15 -i - - - P SSC[1-] C +MESHSET:ATTEMPTS,OK - - *mesh_start_all_duts - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 60 - - - P MNODE(0,0) C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh no-router network - 2. root deinit - 3. check others can't connected - test environment: SSC_T6_MESH1 - summary: multiple nodes, establish mesh network without router, then root deinit - test point 1: manual network function - test point 2: no-router function test - CI ready: 'No' -- ID: MESH_EST_2110 - <<: *MESH_CASE - cmd set: - - '' - - *mesh_init_all_duts - - *mesh_config_all_duts_no_router - - *mesh_start_all_duts - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - FREBOOT SSC1 - - - P SSC1 C !!!ready!!! - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - *mesh_config_dut1_no_router - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY - - - '' - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh no-router network - 2. root restart mesh - 3. check mesh tree re-establish - test environment: SSC_T50_MESH1 - summary: multiple nodes, establish mesh network without router, then root restart root and check mesh network re-establish - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2111 - <<: *MESH_CASE - cmd set: - - '' - - *mesh_init_all_duts - - *mesh_config_all_duts_no_router - - *mesh_start_all_duts - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - - DELAY - - - '' - - - VALUE -1 - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh no-router network - 2. one of the l2 nodes reboot - 3. check mesh tree re-establish - test environment: SSC_T50_MESH1 - summary: multiple nodes, establish mesh network without router, then reboot one of the l2 nodes - test point 1: manual network function - test point 2: no-router function test - CI ready: 'No' -- ID: MESH_EST_2112 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] mesh -I - - - P SSC[1-3] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -T -o 0 -t 1 - - - P SSC[1-2] C +MESHSET:TYPE,OK - - - SSC SSC3 meshset -X -o 0 -i 1 - - - P SSC3 C +MESHSET:FIX_ROOT,OK - - - SSC SSC[1-3] meshset -G -o 0 -m -n -t -e - -i - - - P SSC[1-3] C +MESHSET:CFG,OK - - - SSC SSC[2-3] mesh -T - - - P SSC[2-3] C +MESH:START,OK - - P SSC3 C MESH_EVENT_CONNECTED,2 - - - SSC SSC2 mesh -I -o 1 - - - P SSC2 C +MESH:DEINIT,OK - - P SSC3 C MESH_EVENT_DISCONNECTED - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC3 C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. all duts set no-router, dut1 and dut2 is root, dut3 fix root - 2. start dut2 and dut3 establish network - 3. deinit dut2 and start dut1, dut3 disconencted with dut2 then connect to dut1 - test environment: SSC_T3_MESH1 - summary: set two no-router root, check node switch between two root - test point 1: manual network function - test point 2: no-router function test - CI ready: 'Yes' -- ID: MESH_EST_2201 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -t 3 - - - P SSC1 C +MESHSET:TYPE,OK - - - MSSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - MSSC SSC1 meshset -o 0 -L -l - - - P SSC1 C +MESHSET:MLAYER,OK - - - MSSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_NO_PARENT_FOUND - - - SSC SSC1 op -Q - - - P SSC1 C +CURMODE:1 - - - LOOP 3 2 "[0,1,2]" "[0,1,2]" - - '' - - - SSC SSC1 sleep -S -t {%d} - - - P SSC1 C +SLEEP_MODE:OK - - - SSC SSC1 sleep -Q - - - P SSC1 C +CURMODE:{%d} - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. start one dut with mesh type leaf - 2. check not connect to Router - 3. check station mode - 4. check nonsleep/light/modem sleep mode setable - test environment: SSC_T1_MESH1 - summary: start dut1 as leaf, check disconnected, station mode, and sleep mode setable - test point 1: manual network function - test point 2: standalone station test - CI ready: 'Yes' -- ID: MESH_EST_2202 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC1 meshset -T -t 3 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -o 0 -L -l - - - P SSC[1-2] C +MESHSET:MLAYER,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 15 - - - '' - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - DELAY 5 - - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - P SSC1 C MESH_EVENT_CONNECTED,2 - - - SSC SSC1 op -Q - - - P SSC1 C +CURMODE:1 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. first start one dut with mesh type leaf - 2. then start the normal node - 3. check if networking established - 4. check wifo op mode station - test environment: SSC_T2_MESH1 - summary: dut1 start mesh with type leaf, dut2 normal node, establish network - test point 1: manual network function - test point 2: standalone station test - CI ready: 'Yes' -- ID: MESH_EST_2203 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -t 3 - - - P SSC1 C +MESHSET:TYPE,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 3 10 - - - '' - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -T -o 1 - - - P SSC1 C +MESHGET:TYPE,OK,0 - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 5 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. start one dut with type leaf - 2. check mesh type cleared after re-init mesh - 3. start mesh and connected with Router - test environment: SSC_T1_MESH1 - summary: check mesh leaf type info cleared after mesh re-init - test point 1: manual network function - test point 2: standalone station test - CI ready: 'Yes' -- ID: MESH_EST_2204 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-5] meshset -T -t 3 - - - P SSC[1-5] C +MESHSET:TYPE,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] meshset -o 0 -L -l - - - P SSC[1-] C +MESHSET:MLAYER,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - MSSC SSC[1-5] meshset -T -o 1 - - - P SSC[1-5] C +MESHGET:TYPE,OK,3 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. several duts set type leaf - 2. all duts start mesh together - 3. check if networking established - 4. check leaf type nodes - test environment: SSC_T50_MESH1 - summary: several duts set type leaf, all duts start mesh together - test point 1: manual network function - test point 2: standalone station test - CI ready: 'No' -- ID: MESH_EST_2301 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshset -D -m - - - P MNODE(0,0) C MESHSET:MESH_ID,OK - - P MNODE(0,0) C MESH_EVENT_DISCONNECTED - - - DELAY 10 - - - P MNODE(0,0) C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - steps: |- - 1. dynamic set mesh id - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: dynamic set mesh id, check disconnected with parent - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' - #TODO: v3.1 will not run dynamic cases on CI -- ID: MESH_EST_2302 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) meshset -D -m - - - P MNODE(0) C MESHSET:MESH_ID,OK - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - expected result: |- - 1. succeed - steps: |- - 1. root dynamic set mesh id - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: root dynamic set mesh id, check child leave - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2303 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) meshset -D -m - - - P MNODE(0,0) C MESHSET:MESH_ID,OK - - P MNODE(0,0) C MESH_EVENT_CHILD_DISCONNECTED C MESH_EVENT_DISCONNECTED - - - DELAY 15 - - - '' - - - SSC MNODE(0,0) mesh -Q -o 2 - - - P MNODE(0,0) C IS_ROOT - expected result: |- - 1. succeed - steps: |- - 1. layer2 dynamic set mesh id - initial condition: MESH_INIT1 - test environment: SSC_T6_MESH1 - summary: layer2 dynamic set mesh id, check disconnected and child leave - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2304 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -i 0 - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC MNODE(0,0) meshset -D -m - - - P MNODE(0,0) C MESHSET:MESH_ID,OK - - P MNODE(0,0) C MESH_EVENT_CHILD_DISCONNECTED C MESH_EVENT_DISCONNECTED - - - DELAY 10 - - - P MNODE(0,0) C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - steps: |- - 1. root dynamic set mesh id - initial condition: MESH_DEINIT_STA - test environment: SSC_T6_MESH1 - summary: layer2 dynamic set mesh id without ie_encrypt, check disconnected and child leave - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2305 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m [,] -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - MSSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - MSSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - SSC SSC1 meshset -D -m - - - P SSC1 C MESHSET:MESH_ID,OK - - P SSC1 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - steps: |- - 1. layer2 dynamic set mesh id - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh id on disconnected node, check connected - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2306 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m [,] -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - MSSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 meshset -D -m - - - P SSC1 C MESHSET:MESH_ID,OK - - - MSSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - steps: |- - 1. layer2 dynamic set mesh id - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh id on root, check new node join - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2307 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m [,] -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - MSSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - P SSC[1-2] C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 meshset -D -m - - - P SSC1 C MESHSET:MESH_ID,OK - - - P SSC1 C MESH_EVENT_DISCONNECTED - - - DELAY 5 - - P SSC1 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. set 2 duts with different mesh_id, both root - 2. dynamic set mesh id on dut1 - 3. dut1 disconnected with router and join the other network - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh id on root, check disconnected and join new network - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2308 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i 0 - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC MNODE(0,0) meshset -E -i 1 -e -l 10 - - - P MNODE(0,0) C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - P MNODE(0,0) C MESH_EVENT_CHILD_DISCONNECTED C MESH_EVENT_DISCONNECTED - - - DELAY 15 - - - '' - - - SSC MNODE(0,0) mesh -Q -o 2 - - - P MNODE(0,0) C IS_ROOT - expected result: |- - 1. succeed - steps: |- - 1. all duts establish mesh neetwork with ie_encrypt = 0 - 2. layer 2 dynamic set mesh ie encrypt - 3. check layer2 disconnected with parent and then become root - initial condition: MESH_DEINIT_STA - test environment: SSC_T6_MESH1 - summary: dynamic set mesh ie encrypt, check disconnected and child leave - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'No' -- ID: MESH_EST_2309 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i 1 - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - VALUE - - - R PC_COM L OK - - *mesh_check_tree_num - - *mesh_tree_stably - - - SSC MNODE(0,0) meshset -E -i 1 -e -l 10 - - - P MNODE(0,0) C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - P MNODE(0,0) C MESH_EVENT_CHILD_DISCONNECTED C MESH_EVENT_DISCONNECTED - - - DELAY 15 - - - '' - - - SSC MNODE(0,0) mesh -Q -o 2 - - - P MNODE(0,0) C IS_ROOT - expected result: |- - 1. succeed - steps: |- - 1. all duts establish mesh neetwork with ie_encrypt = 1 - 2. layer 2 dynamic set mesh ie encrypt key - 3. check layer2 disconnected with parent and then become root - initial condition: MESH_DEINIT_STA - test environment: SSC_T6_MESH1 - summary: dynamic set mesh ie key, check disconnected and child leave - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2310 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i [0,1] - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - SSC SSC2 meshset -E -i 0 -e -l 10 - - - P SSC2 C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. dut1 set ie_encrypt=0 and dut2 set ie encrypt=1 - 2. start dut1 to be root first - 3. start dut2 and dynamic set mesh ie encrypt=0 - 4. check dut2 connected with dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh ie encrypt to 0, check connected - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2311 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i [1,0] - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - SSC SSC2 meshset -E -i 1 -e -l 10 - - - P SSC2 C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. dut1 set ie_encrypt=1 and dut2 set ie encrypt=0 - 2. start dut1 to be root first - 3. start dut2 and dynamic set mesh ie encrypt=1 - 4. check dut2 connected with dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh ie encrypt to 1, check connected - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2312 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - MSSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i 0 - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC[1-2] meshset -E -i 1 -e [,] -l 10 - - - P SSC[1-2] C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - - SSC SSC2 meshset -E -i 1 -e -l 10 - - - P SSC2 C MESHSET:MIE_FUNC,OK C MESHSET:MIE_KEY,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. 2 duts config mesh with different ie_encrypt key - 2. dut2 dynamic set mesh ie encrypt key after start - 3. check dut2 connected with dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: dynamic set mesh ie key, check connected - test point 1: manual network function - test point 2: dynamic set configuration - CI ready: 'Yes' -- ID: MESH_EST_2401 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 1 2 - - - '' - - - SSC SSC1 meshset -O -o 0 -n 0 -t 0 - - - P SSC1 C +MESHSET:SELF_ORG,OK - - - SSC SSC1 sta -S -T - - - P SSC1 C MESH_EVENT_SCAN_DONE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh then set self_organized(0,0) - 2. wifi scan - 2. check MESH_EVENT_SCAN_DONE on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: set self_organized (0,0) and user scan after mesh start - test point 1: manual network function - test point 2: self_organized - CI ready: 'Yes' -- ID: MESH_EST_2402 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - - - SSC SSC1 reboot - - - P SSC1 C !!!ready!!! - - P SSC2 C MESH_EVENT_DISCONNECTE - - - SSC SSC2 meshset -O -o 0 -n 0 -t 0 - - - P SSC2 C +MESHSET:SELF_ORG,OK - - - DELAY 1 - - - P SSC2 C MESH_EVENT_STOP_RECONNECTION - - - SSC SSC2 sta -S -T - - - P SSC2 C MESH_EVENT_SCAN_DONE - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. dut1 set AP, dut2 start mesh and connected with dut1 - 2. reboot dut1, dut2 disconnected with dut1 - 3. set self_organized(0,0) and then use scan (stop scan first) - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: set self_organized (0,0) when root connecting to router - test point 1: manual network function - test point 2: self_organized - CI ready: 'Yes' - # TODO: discussion -- ID: MESH_EST_2403 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -n -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 - - - SSC SSC1 reboot - - - P SSC1 C !!!ready!!! - - P SSC2 C MESH_EVENT_DISCONNECTE - - - SSC SSC2 meshset -O -o 0 -n 1 -t 1 - - - P SSC2 C +MESHSET:SELF_ORG,OK - - - SSC SSC2 meshset -T -o 1 - - - P SSC2 C MESHGET:TYPE,OK,0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. dut1 set AP, dut2 start mesh and connected with dut1 - 2. reboot dut1, dut2 disconnected with dut1 - 3. set dut2 self_organized(1,1) and check it IDLE - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: set self_organized (1,1) to give up root state - test point 1: manual network function - test point 2: self_organized - CI ready: 'Yes' -- ID: MESH_EST_6001 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network - summary: performance test, start all nodes to establish network - test point 1: performance - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6002 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'ie_encrypt = False' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network without mesh ie encrypted - summary: performance test, start all nodes to establish network without mesh ie encrypted - test point 1: performance - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6003 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'map_encrypt = False' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network without mesh ap encrypted - summary: performance test, start all nodes to establish network without mesh ap encrypted - test point 1: performance - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6004 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'map_encrypt = False' - - [''] - - - 'ie_encrypt = False' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network without map/mie encrypted - summary: performance test, start all nodes to establish network without map/mie encrypted - test point 1: performance - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6005 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'default_switch_rssi = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network without default switch rssi - summary: performance test, start all nodes to establish network with default switch rssi - test point 1: performance - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6101 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = ["MNODE(0)"]' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, destroy root after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6102 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = ["MNODE(l2)"]' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, destroy L2 nodes after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6103 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = ["MNODE(l1-l2)"]' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, destroy root and L2 nodes after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6104 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, destroy random 10 nodes after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6105 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "MNODE(0)"' - - [''] - - - 'restart_mesh = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, root restart mesh after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6106 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "MNODE(0)"' - - [''] - - - 'destroy_mode = "power"' - - [''] - - - 'restart_mesh = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, power reset root and restart mesh after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_6107 - <<: *MESH_CASE - category: Performance - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - - - 'destroy_mode = "power"' - - [''] - - - 'restart_mesh = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: performance test, power reset random nodes and restart mesh after network established - test point 1: performance - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 - -- ID: MESH_EST_5001 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'start_number_list = [1,0]' - - [''] - - - 'start_interval_sec = 15' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network without map/mie encrypted - summary: stress test, start one nodes to be root first, then start all others - test point 1: stress - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5002 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'start_number_list = [1,0]' - - [''] - - - 'start_interval_sec = random.uniform(1,10)' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - steps: |- - 1. enable all nodes establish - summary: stress test, start one nodes first, then start others - test point 1: stress - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5002 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'allow_roots = False' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - steps: |- - 1. enable all nodes establish - summary: stress test, start all nodes with allow_roots false - test point 1: stress - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5003 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'start_number_list = [1,1,1,1,1,1,1,1,1,1,0]' - - [''] - - - 'start_interval_sec = random.uniform(1,5)' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - steps: |- - 1. enable all nodes establish network - summary: stress test, start 10 nodes one by one, then start others - test point 1: stress - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5004 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'start_number_list = [1,2,3,4,8,0]' - - [''] - - - 'start_interval_sec = random.uniform(1,5)' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent on mesh network establish - steps: |- - 1. enable all nodes establish network - summary: stress test, start [1,2,3,4,8] nodes with interval , then start others - test point 1: stress - test point 2: mesh network establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5101 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "MNODE(0)"' - - [''] - - - 'establish_fail_time = 1200' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: stress test, destroy root after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5102 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "MNODE(0)"' - - [''] - - - 'establish_fail_time = 1200' - - [''] - - - 'destroy_mode = "power"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: stress test, power reset root after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5103 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "MNODE(0)"' - - [''] - - - 'establish_fail_time = 1200' - - [''] - - - 'destroy_mode = "power"' - - [''] - - - 'restart_mesh = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy root after network established - summary: stress test, power reset root and restart mesh after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5103 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. destroy random 10 nodes after network established - summary: stress test, destroy random 10 nodes after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5104 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - - - 'destroy_mode = "power"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. power reset 10 nodes after network established - summary: stress test, power reset 10 nodes after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5105 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshEstablishTime - - *est_performance_cmd_set - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - - - 'destroy_mode = "power"' - - [''] - - - 'restart_mesh = True' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_DEINIT_STA - steps: |- - 1. enable all nodes establish network - 2. power reset random 10 nodes and restart after network established - summary: stress test, power reset random 10 nodes and restart after network established - test point 1: stress - test point 2: mesh network re-establish - test environment: SSC_T50_MESH1 -- ID: MESH_EST_5106 - <<: *MESH_CASE - category: Stress - cmd set: - - MeshStress/MeshNetworkDestroy - - - 'destroy_nodes = "RANDOM(10)"' - - [''] - execution time: 2.0 - expected result: |- - 1. check the time spent - 1. check the time spent - initial condition: MESH_INIT_SWITCH - steps: |- - 1. enable all nodes establish network - 2. reboot random 10 nodes after network established - summary: multiple router, reboot random 10 nodes after network established - test point 1: stress - test point 2: channel switch test - test environment: SSC_T50_MESH1 diff --git a/components/idf_test/integration_test/TC_IT_MESH_MISC.yml b/components/idf_test/integration_test/TC_IT_MESH_MISC.yml deleted file mode 100644 index eabc76594..000000000 --- a/components/idf_test/integration_test/TC_IT_MESH_MISC.yml +++ /dev/null @@ -1,867 +0,0 @@ -.MESH_CASE: &MESH_CASE - SDK: ESP32_IDF - Test App: SSC_MESH - auto test: 'Yes' - category: Function - test point 1: basic function - initial condition: MESH_DEINIT_STA - test environment: SSC_T50_MESH1 - execution time: 0.0 - module: Mesh - sub module: Misc - version: v1 (2018-08-15) - CI ready: 'No' - level: Integration - allow fail: '' - -.set_softap_dut1: &set_softap_dut1 - LIST_MERGE: - - - 'SSC SSC1 op -S -o 2' - - ['P SSC1 C +MODE:OK'] - - - 'SSC SSC1 ap -S -s -p -n -t ' - - ['P SSC1 C +SAP:OK'] - - - 'SSC SSC1 dhcp -E -o 2' - - ['R SSC1 C +DHCP:AP,OK'] - - - 'SSC SSC1 ip -S -o 2 -i 192.168.123.1' - - ['R SSC1 C +IP:OK'] - - - 'SSC SSC1 dhcp -S -o 2' - - ['R SSC1 C +DHCP:AP,OK'] - -test cases: -- ID: MESH_MISC_0101 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 init/config mesh - 2. dut1 deinit mesh - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: 1 dut mesh deinit after mesh configured - test point 2: mesh deinit/stop test - CI ready: 'Yes' -- ID: MESH_MISC_0102 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 1 5 - - - '' - - - SSC SSC1 mesh -I -o 1 - - - P SSC1 C +MESH:DEINIT,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh - 2. dut1 deinit mesh - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: 1 dut mesh deinit after mesh started - test point 2: mesh deinit/stop test - CI ready: 'Yes' -- ID: MESH_MISC_0103 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -I - - - P SSC[1-] C +MESH:INIT,OK - - - MSSC SSC[1-] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-] C +MESHSET:CFG,OK - - - MSSC SSC[1-] mesh -T - - - P SSC[1-] C +MESH:START,OK - - - DELAY 1 5 - - - '' - - - MSSC SSC[1-] mesh -T -o 1 - - - P SSC[1-] C +MESH:STOP,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh - 2. dut1 stop mesh - initial condition: MESH_DEINIT_STA - test environment: SSC_T6_MESH1 - summary: 6 duts mesh stop after mesh started - test point 2: mesh deinit/stop test - CI ready: 'Yes' -- ID: MESH_MISC_0104 - <<: *MESH_CASE - cmd set: - - '' - - - MSSC SSC[1-] mesh -T -o 2 - - - P SSC[1-] C +MESH:START,OK - - - DELAY - - - '' - - - MSSC SSC[1-] mesh -Q -o 2 - - - P SSC[1-] T topo - - - MESHTREE - - - R PC_COM RE "MESHTREE:%%s"%%() - - - SSC MNODE(0) meshsend -S -d -l 1000 -c 20 -b 20 -f 2 - - - P MNODE(0) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0,-1) C +MESHRXPKT,OK - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 20 -b 20 -f 8 - - - P MNODE(0,-1) C +MESHTXPKT,OK C +MESHSEND,OK - - P MNODE(0) C TODS_PKT,OK - - - SSC MNODE(0) mesh -R -o 1 - - - P MNODE(0) C +MESHRX:STOP,OK - - - SSC MNODE(0,-1) meshsend -S -d -l 1000 -c 100 -b 20 -f 8 - - - '' - - - DELAY 10 - - - P PC_COM C DELAYDONE - - P MNODE(0,-1) C +MESHTXPKT,OK NC +MESHTXPKT,FAIL NC +MESHSEND,OK - - - SSC MNODE(0) mesh -R -o 0 - - - P MNODE(0) C +MESHRX:START,OK C TODS_PKT,OK - - P MNODE(0,-1) C +MESHSEND,OK - expected result: |- - 1. restart mesh and establish network - 2. root send packet to leaf - 3. leaf send packet tods - 4. stop recv task on root - 5. leaf send packet tods, blocked - 5. start recv task on root, leaf send out all packet - steps: |- - 1. dut1 start mesh - 2. dut1 stop mesh - initial condition: MESH_INIT1 - test environment: SSC_T6_MESH1 - summary: mesh restart and send packet test - test point 2: mesh deinit/stop test - CI ready: 'No' - - - -- ID: MESH_MISC_0201 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. start dut1 and connect to router - 2. check MESH_EVENT_ROOT_GOT_IP - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: MESH_EVENT_CHILD_CONNECTED and MESH_EVENT_ROOT_GOT_IP test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0202 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK C MESH_EVENT_CONNECTED,2 - - P SSC1 C MESH_EVENT_CHILD_CONNECTED C MESH_EVENT_ROUTING_TABLE_ADD - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. start dut1 to be root first - 2. start another and check event on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_CHILD_CONNECTED and MESH_EVENT_ROUTING_TABLE_ADD test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0203 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-3] mesh -I - - - P SSC[1-3] C +MESH:INIT,OK - - - SSC SSC[1-3] meshset -G -o 0 -m -s -p -n - -b -t 1 -e -i - - - P SSC[1-3] C +MESHSET:CFG,OK - - - SSC SSC[1-2] mesh -T - - - P SSC[1-2] C +MESH:START,OK - - - DELAY 10 - - - P SSC[1-2] C MESH_EVENT_CONNECTED - - - SSC SSC3 mesh -T - - - P SSC3 C +MESH:START,OK C MESH_EVENT_CONNECTED,3 - - P SSC[1-2] C MESH_EVENT_ROUTING_TABLE_ADD - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set max_connect=1 and two duts start mesh and establish network - 2. start another and check event on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T3_MESH1 - summary: MESH_EVENT_ROUTING_TABLE_ADD test (layer3 join) - test point 2: mesh event test - CI ready: 'Yes' -#TODO: wrong password should not find MESH_EVENT_ROUTING_TABLE_ADD -- ID: MESH_MISC_0205 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) reboot - - - P MNODE(0,0) C !!!ready!!! - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - - P MNODE(0) C MESH_EVENT_ROUTING_TABLE_REMOVE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_CHILD_DISCONNECTED and MESH_EVENT_ROUTING_TABLE_REMOVE test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0206 - <<: *MESH_CASE - cmd set: - - '' - - - FREBOOT MNODE(0,0) - - - P MNODE(0,0) C !!!ready!!! - - - DELAY 10 - - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - - P MNODE(0) C MESH_EVENT_ROUTING_TABLE_REMOVE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_CHILD_DISCONNECTED and MESH_EVENT_ROUTING_TABLE_REMOVE test (power reset) - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0207 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0) mesh -I -o 1 - - - P MNODE(0,0) C MESH:DEINIT,OK - - P MNODE(0) C MESH_EVENT_CHILD_DISCONNECTED - - P MNODE(0) C MESH_EVENT_ROUTING_TABLE_REMOVE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_CHILD_DISCONNECTED and MESH_EVENT_ROUTING_TABLE_REMOVE test (mesh deinit) - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0208 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0,0,0) reboot - - - P MNODE(0,0,0) C !!!ready!!! - - P MNODE(0,0) C MESH_EVENT_ROUTING_TABLE_REMOVE - - P MNODE(0) C MESH_EVENT_ROUTING_TABLE_REMOVE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. reboot root - 2. layer2 disconnected and then become new root - initial condition: MESH_INIT1 - test environment: SSC_T12_MESH1 - summary: MESH_EVENT_ROUTING_TABLE_REMOVE test (layer3 leave) - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0209 - <<: *MESH_CASE - cmd set: - - '' - - - LOOP 2 1 "[1,0]" "[1,0]" - - - '' - - - SSC MNODE(0) mesh -O -t {%d} - - - P MNODE(0) C +MESH_POST_STATE,OK - - P SSC[1-] C MESH_EVENT_TODS_STATE,{%d} - - - SSC MNODE(0) mesh -O -t 0 - - - P MNODE(0) C +MESH_POST_STATE,OK - - - DELAY 5 - - - P PC_COM C DELAYDONE - - P SSC[1-] NC MESH_EVENT_TODS_STATE - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh network - 2. root post toDS state - 3. check MESH_EVENT_TODS_STATE on all dut - initial condition: MESH_INIT1 - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_TODS_STATE test when root post state - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0210 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 mesh -O -t 1 - - - P SSC1 C +MESH_POST_STATE,OK - - P SSC1 C MESH_EVENT_TODS_STATE,1 - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK MESH_EVENT_CONNECTED,2 - - P SSC2 C MESH_EVENT_TODS_STATE,1 - - - SSC SSC1 reboot - - - P SSC2 C MESH_EVENT_DISCONNECTED - - P SSC2 C MESH_EVENT_NETWORK_STATE,1 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh network - 2. root post toDS state - 3. check MESH_EVENT_TODS_STATE on all dut - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_TODS_STATE test when layer2 connected and root disappear - test point 2: mesh event test - CI ready: 'Yes' - # TODO: not work on v3.1 -- ID: MESH_MISC_0211 - <<: *MESH_CASE - cmd set: - - '' - - - LOOP 2 1 "[1,0]" "[1,0]" - - - '' - - - SSC MNODE(0) mesh -O -t {%d} - - - P MNODE(0) C +MESH_POST_STATE,OK - - P SSC[1-] C MESH_EVENT_TODS_STATE,{%d} - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. establish mesh network - 2. root post toDS state - 3. check MESH_EVENT_TODS_STATE on all duts - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, MESH_EVENT_TODS_STATE test - test point 2: mesh event test - CI ready: 'No' -- ID: MESH_MISC_0212 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C MESH_EVENT_STARTED - - - DELAY 5 - - - '' - - - SSC SSC1 mesh -T -o 1 - - - P SSC1 C MESH_EVENT_STOPPED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh - 2. check MESH_EVENT_STARTED on dut1 - 2. dut1 stop mesh - 2. check MESH_EVENT_STOPPED on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: MESH_EVENT_STARTED and MESH_EVENT_STOPPED test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0213 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - DELAY 10 - - - P SSC1 C MESH_EVENT_NO_PARENT_FOUND - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh - 2. check MESH_EVENT_STARTED on dut1 - 2. dut1 stop mesh - 2. check MESH_EVENT_STOPPED on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: MESH_EVENT_NO_PARENT_FOUND test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0214 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 meshset -O -o 0 -n 0 -t 0 - - - P SSC1 C +MESHSET:SELF_ORG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - SSC SSC1 sta -S -n - - - P SSC1 C MESH_EVENT_SCAN_DONE - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh self_organized=false - 2. wifi scan - 2. check MESH_EVENT_SCAN_DONE on dut1 - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: MESH_EVENT_SCAN_DONE test - test point 2: mesh event test - CI ready: 'No' - #TODO: need discussion -- ID: MESH_MISC_0215 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -W -o 1 - - - P MNODE(0) C +MESH:VOTE,OK - - P SSC[1-] C MESH_EVENT_VOTE_STARTED - - - DELAY 10 - - - P SSC[1-] C MESH_EVENT_VOTE_STOPPED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root vote - 2. check all duts start vote - initial condition: MESH_INIT1 - test environment: SSC_T6_MESH1 - summary: MESH_EVENT_VOTE_STARTED and MESH_EVENT_VOTE_STOPPED test - test point 2: mesh event test - CI ready: 'No' -- ID: MESH_MISC_0216 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -W -o 1 - - - P MNODE(0) C +MESH:VOTE,OK - - P SSC[1-] C MESH_EVENT_VOTE_STARTED - - - SSC MNODE(0) reboot - - - P MNODE(0) !!!ready!!! - - - DELAY 30 - - - '' - - - SSC SSC[1-] mesh -W -o 2 - - - P SSC[1-] C VOTE_START_STOP_EQUAL - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. dut1 start mesh self_organized=false - 2. wifi scan - 2. check MESH_EVENT_SCAN_DONE on dut1 - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, MESH_EVENT VOTE_STARTED and VOTE_STOPPED equal test - test point 2: mesh event test - CI ready: 'No' - #TODO: need discussion -- ID: MESH_MISC_0217 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) mesh -W -o 1 - - - P MNODE(0) C +MESH:VOTE,OK - - P SSC[1-] C MESH_EVENT_VOTE_STARTED - - - DELAY 10 - - - P SSC[1-] C MESH_EVENT_VOTE_STOPPED - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root vote - 2. check all duts start vote - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, MESH_EVENT_VOTE_STARTED and MESH_EVENT_VOTE_STOPPED test - test point 2: mesh event test -- ID: MESH_MISC_0218 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) meshset -X -o 0 -i 1 - - - P MNODE(0) C +MESHSET:FIX_ROOT,OK - - P SSC[1-] C MESH_EVENT_ROOT_FIXED,1 - - - SSC MNODE(0) meshset -X -o 0 -i 0 - - - P MNODE(0) C +MESHSET:FIX_ROOT,OK - - P SSC[1-] C MESH_EVENT_ROOT_FIXED,0 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set root fix on root - 2. check all duts MESH_EVENT_ROOT_FIXED - initial condition: MESH_INIT1 - test environment: SSC_T6_MESH1 - summary: stable network, MESH_EVENT_ROOT_FIXED test - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0219 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 meshset -X -o 0 -i 1 - - - P SSC1 C +MESHSET:FIX_ROOT,OK C MESH_EVENT_ROOT_FIXED,1 - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,2 C MESH_EVENT_ROOT_FIXED,1 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. set dut1 fix root first - 2. dut2 connected with dut1 - 3. check MESH_EVENT_ROOT_FIXED on dut2 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: MESH_EVENT_ROOT_FIXED when connected with parent - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0220 - <<: *MESH_CASE - cmd set: - - '' - - - SSC MNODE(0) meshset -X -o 0 -i 1 - - - P MNODE(0) C +MESHSET:FIX_ROOT,OK - - P SSC[1-] C MESH_EVENT_ROOT_FIXED,1 - - - SSC MNODE(0) meshset -X -o 0 -i 0 - - - P MNODE(0) C +MESHSET:FIX_ROOT,OK - - P SSC[1-] C MESH_EVENT_ROOT_FIXED,0 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set root fix on root - 2. check all duts MESH_EVENT_ROOT_FIXED - initial condition: MESH_INIT1 - test environment: SSC_T50_MESH1 - summary: multiple nodes, MESH_EVENT_ROOT_FIXED test - test point 2: mesh event test - CI ready: 'No' -- ID: MESH_MISC_0221 - <<: *MESH_CASE - cmd set: - - '' - - - SSC SSC[1-2] mesh -I - - - P SSC[1-2] C +MESH:INIT,OK - - - SSC SSC[1-2] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-2] C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - P SSC1 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 ap -Q - - - R SSC1 A :\+APCONFIG:(\w+), - - - SSC SSC2 meshset -U -o 0 -m -s -p -n -t 2 -l 2 - - - P SSC2 C +MESHSET:PARENT,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_DISCONNECTED,103 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. mesh init/config - 2. start dut1 and check it connected with router - 3. dut2 parent set to dut1 with wrong mesh_id - 4. start dut2 and check disconnected rason DIFF_ID - test environment: SSC_T2_MESH1 - summary: test MESH_EVENT_DISCONNECTED, reason DIFF_ID(103) - test point 2: mesh event test - CI ready: 'Yes' -- ID: MESH_MISC_0301 - <<: *MESH_CASE - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC MNODE(0) soc -B -t TCP -p - - - P MNODE(0) A :\+BIND:(\d+),OK - - - SSC MNODE(0) soc -C -s -i -p - - - P MNODE(0) RE \+CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC MNODE(0) soc -S -s -l 1460 -n 10 -j 20 - - - P MNODE(0) RE \+SEND:\d+,OK - - - SOC SOC2 SEND 1460 - - - R MNODE(0) SL +1460 - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root connect to pc - 2. root send pecket to pc - initial condition: MESH_INIT1 - test environment: SSC_T1_MESH2 - summary: use socket TCP between root and pc - test point 2: socket after mesh start -- ID: MESH_MISC_0302 - <<: *MESH_CASE - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC MNODE(0) ip -Q - - - P MNODE(0) A :\+STAIP:(\d+.\d+.\d+.\d+) - - - SSC MNODE(0) soc -B -t UDP -i -p - - - P MNODE(0) A :\+BIND:(\d+),OK - - - SSC MNODE(0) soc -S -s -l 1460 -n 10 -i -p -j 20 - - - P MNODE(0) RE \+SEND:\d+,OK - - P SOC1 UL 14600 - - - DELAY 5 - - '' - - - SOC SOC1 SENDTO 1460 - - - R MNODE(0) RE "RECVFROM:%%s,1460,%%s,%%u"%%(,,) - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. root connect to pc - 2. root send pecket to pc - initial condition: MESH_INIT1 - test environment: SSC_T1_MESH2 - summary: use socket UDP between root and pc - test point 2: socket after mesh start - CI ready: 'No' -- ID: MESH_MISC_0303 - <<: *MESH_CASE - cmd set: - - '' - - *set_softap_dut1 - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 ip -Q - - - P SSC1 A :\+APIP:(\d+.\d+.\d+.\d+) - - - SSC SSC[1-2] soc -T - - - P SSC[1-2] C +CLOSEALL - - - SSC SSC1 soc -B -t TCP -p - - - P SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE \+LISTEN:\d+,OK - - - SSC SSC2 soc -B -t TCP - - - P SSC2 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -C -s -i -p - - - P SSC2 RE \+CONNECT:\d+,OK - - P SSC1 A :\+ACCEPT:(\d+) - - - SSC SSC1 soc -S -s -l 1460 -n 10 - - - P SSC1 RE \+SEND:\d+,OK - - - SSC SSC2 soc -S -s -l 1460 -n 10 - - - P SSC2 RE \+SEND:\d+,OK - expected result: |- - 1. succeed - 2. succeed - steps: |- - 1. set dut1 softAP - 2. dut2 start mesh and connect to dut1 - 3. use TCP between dut1 and dut2 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: use socket TCP between root and esp32 softAP - test point 2: socket after mesh start - CI ready: 'Yes' -- ID: MESH_MISC_0304 - <<: *MESH_CASE - cmd set: - - '' - - *set_softap_dut1 - - - SSC SSC2 mesh -I - - - P SSC2 C +MESH:INIT,OK - - - SSC SSC2 meshset -G -o 0 -m -s -p -n - -t -e -i - - - P SSC2 C +MESHSET:CFG,OK - - - SSC SSC2 mesh -T - - - P SSC2 C +MESH:START,OK - - P SSC2 C MESH_EVENT_CONNECTED,1 C MESH_EVENT_ROOT_GOT_IP - - - SSC SSC1 ip -Q - - - P SSC1 A :\+APIP:(\d+.\d+.\d+.\d+) - - - SSC SSC2 ip -Q - - - P SSC2 A :\+STAIP:(\d+.\d+.\d+.\d+) - - - SSC SSC[1-2] soc -T - - - P SSC[1-2] C +CLOSEALL - - - SSC SSC1 soc -B -t UDP -i -p - - - P SSC1 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -B -t UDP -i -p - - - P SSC2 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -S -s -l 1460 -n 10 -i -p - - - P SSC1 RE \+SEND:\d+,OK - - - SSC SSC2 soc -S -s -l 1460 -n 10 -i -p - - - P SSC2 RE \+SEND:\d+,OK - expected result: |- - 1. succeed - 2. succeed - 3. succeed - steps: |- - 1. set dut1 softAP - 2. dut2 start mesh and connect to dut1 - 3. use UDP between dut1 and dut2 - initial condition: MESH_DEINIT_STA - test environment: SSC_T2_MESH1 - summary: use socket UDP between root and esp32 softAP - test point 2: socket after mesh start - CI ready: 'Yes' - -- ID: MESH_MISC_5001 - <<: *MESH_CASE - category: Stress - cmd set: - - '' - - - SSC SSC1 ram - - - R SSC1 C +FREEHEAP - - - LOOP 300 8 - - - '' - - - SSC SSC1 mesh -I - - - P SSC1 C +MESH:INIT,OK - - - SSC SSC1 meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC1 C +MESHSET:CFG,OK - - - SSC SSC1 mesh -T - - - P SSC1 C +MESH:START,OK - - - SSC SSC1 ram - - - R SSC1 C +FREEHEAP - - - DELAY 1 15 - - - '' - - - SSC SSC1 mesh -T -o 1 - - - P SSC1 C +MESH:STOP,OK - - - DELAY 2 - - - '' - - - SSC SSC1 ram - - - R SSC1 C +FREEHEAP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. succeed - steps: |- - 1. mesh init - 2. mesh config - 3. mesh start - 4. check heap size - 5. mesh stop - 6. check heap size - 7. loop - initial condition: MESH_DEINIT_STA - test environment: SSC_T1_MESH1 - summary: cycle calling mesh_stop/mesh_start, check heap size - test point 2: mesh deinit/stop test -- ID: MESH_MISC_5002 - <<: *MESH_CASE - category: Stress - cmd set: - - '' - - - SSC SSC[1-6] ram - - - R SSC[1-6] C +FREEHEAP - - - LOOP 200 8 - - - '' - - - SSC SSC[1-6] mesh -I - - - P SSC[1-6] C +MESH:INIT,OK - - - SSC SSC[1-6] meshset -G -o 0 -m -s -p -n - -b -t -e -i - - - P SSC[1-6] C +MESHSET:CFG,OK - - - SSC SSC[1-6] mesh -T - - - P SSC[1-6] C +MESH:START,OK - - - SSC SSC[1-6] ram - - - R SSC[1-6] C +FREEHEAP - - - DELAY 5 30 - - - '' - - - SSC SSC[1-6] mesh -T -o 1 - - - P SSC[1-6] C +MESH:STOP,OK - - - DELAY 2 - - - '' - - - SSC SSC[1-6] ram - - - R SSC[1-6] C +FREEHEAP - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - steps: |- - 1. all duts start mesh - 2. check heap size - 3. mesh stop and check heap size - 4. loop - initial condition: MESH_DEINIT_STA - test environment: SSC_T6_MESH1 - summary: 6 duts cycle eatablish network and stop mesh, check heap size - test point 2: mesh deinit/stop test diff --git a/components/idf_test/integration_test/TC_IT_SYS_MISC.yml b/components/idf_test/integration_test/TC_IT_SYS_MISC.yml deleted file mode 100644 index c0436a821..000000000 --- a/components/idf_test/integration_test/TC_IT_SYS_MISC.yml +++ /dev/null @@ -1,81 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: SYS_MISC_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 reboot - - - R SSC1 C !!!ready!!! - execution time: 0.0 - expected result: 重启成功 - initial condition: None - level: Integration - module: System - steps: 系统重启 - sub module: Misc - summary: test reboot function - test environment: SSC_T1_4 - test point 1: basic function - test point 2: sw reboot - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: SYS_MISC_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ram -H - - - R SSC1 RE FREEHEAP:\d+\r\n - execution time: 0.0 - expected result: |2 - - 可以查询到一个数值 - initial condition: None - level: Integration - module: System - steps: 查询空闲ram - sub module: Misc - summary: get heap size test - test environment: SSC_T1_4 - test point 1: basic function - test point 2: 'get heap size ' - version: v1 (2016-8-15) -- CI ready: 'No' - ID: SYS_MISC_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: '' - execution time: 12.0 - expected result: 4.target1正常运行,无异常 - initial condition: None - level: Integration - module: System - steps: |- - 1.target1、target2通过UART与PC相连接 - 2.target1的晶振为40MHz晶振,烧录SDK的时候选择26MHz晶振 - 3.target2的GPIO PIN脚通过排线与target1的电源相连接,target1与target2 GND通过排线连接 - 4.PC发送命令控制target2使GPIO不停的拉高拉低 - sub module: Misc - summary: random reboot to confirm default init data bin will not overwrite user - config - test environment: SSC_T1_InitData - test point 1: stress - test point 2: reboot when using user defined init data bin - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_SYS_NVS.yml b/components/idf_test/integration_test/TC_IT_SYS_NVS.yml deleted file mode 100644 index fd7db6d73..000000000 --- a/components/idf_test/integration_test/TC_IT_SYS_NVS.yml +++ /dev/null @@ -1,57 +0,0 @@ -test cases: -- CI ready: SpecialJob - ID: SYS_NVS_01001 - SDK: ESP32_IDF - Test App: SSC_BLE_WIFI - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - NVSTest/NVSCompatibleWiFi - - - nvs_path = "nvs_bin_folder" - - - '' - execution time: 0 - expected result: | - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: None - level: Integration - module: System - steps: | - 1. get NVS data from earlier released branches and last master - 2. download each NVS data to target - 3. check if auto connected to the same AP - 4. check if SoftAP config is correct - sub module: NVS - summary: use old NVS data WIFI function test - test environment: SSC_T1_1 - test point 1: compatiable test - test point 2: test if latest SDK work with pervious version of NVS data - version: v1 (2017-06-01) -- CI ready: 'No' - ID: SYS_NVS_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: Reboot - auto test: 'Yes' - category: Stress - cmd set: '' - execution time: 12.0 - expected result: 3.无异常发生 - initial condition: None - level: Integration - module: System - steps: |- - 1.target1、target2通过UART与PC相连接 - 2.target2的GPIO PIN脚通过排线与target1的电源相连接,target1与target2 GND通过排线连接 - 3.PC发送命令控制target2使GPIO不停的拉高拉低 - sub module: NVS - summary: random reboot when access NVS - test environment: NVS_T1_1 - test point 1: stress - test point 2: reboot when accessing NVS - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_DHCP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_DHCP.yml deleted file mode 100644 index 8412e88bd..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_DHCP.yml +++ /dev/null @@ -1,995 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_DHCP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -i 0.0.0.0 - - - R SSC1 C +IP - - - SSC SSC1 sta -C -s -p - - - '' - - - DELAY 20 - - - P PC_COM C +DELAYDONE - - P SSC1 NC +JAP:CONNECTED - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -Q - - - R SSC1 C +STAIP:0.0.0.0 - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:CONNECTED - - - SSC SSC1 ip -Q - - - R SSC1 RE "\+STAIP:%%s"%%() - execution time: 0.0 - expected result: "1.target1 关闭DHCP OK\n2.target1 设置ip add OK\n3.target1 连接AP fail\n4.target1 - 打开DHCP OK\n5.查询到sta ip \n6.target1 连接AP ok\n7.查询到sta ip 为target_ip" - initial condition: STAM1 - level: Integration - module: TCPIP - steps: "1.target1 关闭DHCP OK\n2.target1 设置ip add OK\n3.target1 连接AP fail\n4.target1 - 打开DHCP OK\n5.查询到sta ip \n6.target1 连接AP ok\n7.查询到sta ip 为target_ip" - sub module: DHCP - summary: dhcp client function test - test environment: SSC_T1_5 - test point 1: basic function - test point 2: DHCP client function test - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 3 - - - R SSC1 C +DHCP:AP,OK C +DHCP:STA,OK - - - SSC SSC1 dhcp -Q -o 3 - - - R SSC1 C +DHCP:STA,STARTED C +DHCP:AP,STARTED - - - SSC SSC1 dhcp -Q -o 1 - - - R SSC1 C +DHCP:STA,STARTED NC +DHCP:AP,STARTED - - - SSC SSC1 dhcp -Q -o 2 - - - R SSC1 NC +DHCP:STA,STARTED C +DHCP:AP,STARTED - - - SSC SSC1 dhcp -E -o 3 - - - R SSC1 C +DHCP:AP,OK C +DHCP:STA,OK - - - SSC SSC1 dhcp -Q -o 3 - - - R SSC1 C +DHCP:STA,STOPPED C +DHCP:AP,STOPPED - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.STA&AP STARTED - 4.STA STARTED - 5.AP STARTED - 6.OK - 7.STA&AP STOPPED - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1.target1 设置mode 为sta+softAP mode - 2.target1 打开DHCP 3 - 3.target1 查询DHCP 状态 - 4.target1 查询sta DHCP 状态 - 5.target1 查询softAP DHCP 状态 - 6.target1 关闭 DHCP 3 - 7.target1 查询 DHCP 状态 - sub module: DHCP - summary: dhcp status query - test environment: SSC_T1_4 - test point 1: basic function - test point 2: DHCP client function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 ip -S -o 2 -i - - - R SSC1 C +IP:OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -L -s 192.168.4.1 -e 192.168.4.10 - - - R SSC1 C +DHCP:LEASE,ERROR - - - SSC SSC1 dhcp -L -s 192.168.4.5 -e 192.168.4.2 - - - R SSC1 C +DHCP:LEASE,ERROR - - - SSC SSC1 dhcp -L -s 192.168.2.2 -e 192.168.2.5 - - - R SSC1 C +DHCP:LEASE,ERROR - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - execution time: 0.0 - expected result: |- - 1.target1 关闭DHCP 2 OK - 2.target1 设置ip 成功 - 3.设置dhcp 地址池 OK - 4.ERROR - 5.ERROR - 6.ERROR - 7.target1 打开DHCP ok - initial condition: APM1 - level: Integration - module: TCPIP - steps: "1.target1 关闭DHCP 2 \n2.target1 设置ip \n3.设置dhcp 地址池\n4.设置dhcp错误的参数\n5.设置dhcp错误的参数\n6.设置dhcp错误的参数\n7.target1 - 打开DHCP ok" - sub module: DHCP - summary: server dhcp lease test - test environment: SSC_T1_4 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - LOOP 3 4 "['01','02','03']" "[2,3,4]" - - - '' - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:{%s} - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.{%s} - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3,4: get IP from dhcp pool with correct sequence - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. config DHCP Server on Target1 - 3. target change mac, connect to Target1 - 4. Loop step3 - sub module: DHCP - summary: dhcp server ip pool - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0203 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.3 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - LOOP 2 4 "['01','02']" "[2,3]" - - - '' - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:{%s} - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.{%s} - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:66 - - - R SSC2 C +MAC:STA,OK - - - DELAY 20 - - - '' - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:0.0.0.0 - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4.1 succeed - 4.2 failed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. config DHCP Server on Target1(.4.2 - .4.3) - 3. target change mac, connect to Target1 - 4. Loop step3 twice - sub module: DHCP - summary: dhcp server ip pool empty - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0204 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.3 -t 1 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.2 - - - DELAY 90 - - - '' - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.2 - - - SSC SSC2 sta -D - - - R SSC2 C +JAP:DISCONNECTED - - - DELAY 60 - - - '' - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:66 - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.2 - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. get IP 192.168.4.2 - 5. succeed - 6. succeed - 8. get IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. config DHCP timeout as 1 minute - 3. target2 connect to target1 - 4. wait 90 seconds - 5. check if target2 IP is same - 6. target2 disconnect - 7. wait 60s - 8. target2 change mac and connect to target1 - sub module: DHCP - summary: dhcp server timeout test - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0205 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.3 -t 1 - - - P SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - P SSC1 C +DHCP:AP,OK - - P SSC2 C +JAP:DISCONNECTED - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. target2 wifi disconnected - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 - 3. disable DHCP server, do config and enable - sub module: DHCP - summary: disconnect STA if config dhcp server - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0206 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - LOOP 4 4 "['01','02','03','01']" "[2,3,4,2]" - - - '' - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:{%s} - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.{%s} - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 4. get IP 192.168.4.2 - 192.168.4.4 - 5. get IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. disable DHCP server, do config and enable - 3. target2 change mac, connect to softap, disconnect - 4. Loop step3 twice - 5. change to first mac, connect to softap - sub module: DHCP - summary: dhcp server assign same IP to same MAC when it's not released - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0207 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - WIFI DISCONN2 - - - R PC_COM NC ERROR C +WIFIDISCONN:OK - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:66 - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.2 - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. get IP 192.168.4.2 - 4. succeed - 5. succeed - 6. get IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. disable DHCP server, do config and enable - 3. PC WIFI NIC connect to target1 softap - 4. target2 connect to target1 softap and disnnect - 5. PC release IP and disconnected - 6. target2 change mac and connect to target1 - sub module: DHCP - summary: dhcp server prefer assign released IP to new client - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0207 - SDK: ESP32_IDF - Test App: SSC - allow fail: '1/2' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - WIFI DISCONN2 - - - R PC_COM NC ERROR C +WIFIDISCONN:OK - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 mac -S -o 1 -m 10:22:33:44:55:66 - - - R SSC2 C +MAC:STA,OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 ip -Q -o 1 - - - R SSC2 C +STAIP:192.168.4.2 - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. get IP 192.168.4.2 - 4. succeed - 5. succeed - 6. succeed - 7. get IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. disable DHCP server, do config and enable - 3. PC WIFI NIC connect to target1 softap - 4. target2 connect to target1 softap and disnnect - 5. PC release IP and disconnected - 6. disable DHCP server and enable - 7. target2 change mac and connect to target1 - sub module: DHCP - summary: dhcp server prefer assign released IP to new client - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0208 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - P SSC1 C +DHCP:AP,OK - - P SSC2 C +JAP:DISCONNECTED - - - SSC SSC2 sta -D - - - R SSC2 C +JAP:DISCONNECTED - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 ap -L - - - R SSC1 C 192.168.4.2 P - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. get IP 192.168.4.2 - 5. can only find target2 with IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 softap - 3. disable DHCP server, do config and enable - 4. PC NIC connect to target1 softap - 5. softap list connected station - sub module: DHCP - summary: dhcp server reconfig and new client able to get first IP in pool - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0208 - SDK: ESP32_IDF - Test App: SSC - allow fail: '2/3' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - P SSC1 C +DHCP:AP,OK - - P SSC2 C +JAP:DISCONNECTED - - - SSC SSC2 sta -D - - - R SSC2 C OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 ap -L - - - R SSC1 C 192.168.4.2 P - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. succeed - 6. succeed - 7. can only find target2 with IP 192.168.4.2 - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 softap - 3. disable DHCP server, do config and enable - 4. target2 disconnect - 5. disable DHCP server and enable - 6. PC NIC connect to target1 softap - 7. softap list connected station - sub module: DHCP - summary: dhcp server reconfig and new client able to get first IP in pool - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0209 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '2/3' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - DELAY 20 - - - '' - - - SSC SSC1 ap -L - - - R SSC1 C 192.168.4.2 C 192.168.4.3 P P - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. find target2 and PC - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 softap - 3. disable DHCP server, do config and enable - 4. PC NIC connect to target1 softap - 5. softap list connected station - sub module: DHCP - summary: dhcp server reconfig, old client and new client able to get IP - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0210 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '1/2' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - WIFI CONN2 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 ap -L - - - R SSC1 C 192.168.4.2 C 192.168.4.3 P P - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. find target2 and PC - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 softap - 3. disable DHCP server, do config and enable - 4. PC NIC connect to target1 softap try to renew IP 192.168.4.2 - 5. softap list connected station - sub module: DHCP - summary: dhcp server reconfig, old client able to get IP (discover with requested - IP) - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0211 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '1/2' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.100 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - WIFI CONN 192.168.4.2 - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - DELAY 30 - - - '' - - - SSC SSC1 ap -L - - - R SSC1 C 192.168.4.2 C 192.168.4.3 P P - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - 5. find target2 and PC - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. config softap to a random ssid - 2. target2 connect to target1 softap - 3. disable DHCP server, do config and enable - 4. PC NIC connect to target1 softap try to renew IP 192.168.4.2 - 5. softap list connected station - sub module: DHCP - summary: dhcp server reconfig, old client able to renew IP (direct send request) - test environment: SSC_T2_2 - test point 1: basic function - test point 2: DHCP server function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0212 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC2 sta -C -s -p - - - '' - - - DELAY 20 - - - P PC_COM C +DELAYDONE - - P SSC2 NC +JAP:CONNECTED - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: "1.target1 set AP OK \n2.target1 关闭DHCP OK\n3.target2 jap target - 1,FAIL \n4.target1 打开DHCP OK\n5.target2 jap target 1,ok" - initial condition: T2_1 - level: Integration - module: TCPIP - steps: "1.target1 set AP OK \n2.target1 关闭DHCP OK\n3.target2 jap target 1,FAIL \n4.target1 - 打开DHCP OK\n5.target2 jap target 1,ok" - sub module: DHCP - summary: dhcp server function test - test environment: SSC_T2_5 - test point 1: basic function - test point 2: DHCP server function test - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -i 192.168.123.123 -o 1 - - - R SSC1 C +IP:OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:CONNECTED - - - SSC SSC1 ip -S -i 0.0.0.0 -o 1 - - - R SSC1 C +IP - - - SSC SSC1 sta -C -s -p - - - '' - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC1 NC +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.JAP CONNETED - 4.OK - 5.等待10s,JAP fail - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1.target1 关闭DHCP 1 - 2.target1 设置sta ip 192.168.123.123 - 4.target1 jap AP - 5.target1 设置sta ip 0.0.0.0 - 6.target1 jap AP - sub module: DHCP - summary: sta dhcp static ip interaction - test environment: SSC_T1_5 - test point 1: interaction - test point 2: static IP and DHCP interaction test - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_DHCP_0302 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 ip -S -i 192.168.123.123 -o 2 - - - R SSC1 C +IP:ERROR - - - SSC SSC1 dhcp -L -s 192.168.2.2 -e 192.168.2.10 - - - R SSC1 C +DHCP:LEASE,ERROR - - - SSC SSC1 ap -S -s -p -t - - - '' - - - SSC SSC2 sta -C -s -p - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 ip -S -i 192.168.4.1 -o 2 - - - R SSC1 C +IP:OK - - - SSC SSC1 dhcp -L -s 192.168.4.2 -e 192.168.4.10 - - - R SSC1 C +DHCP:LEASE,OK - - - SSC SSC2 sta -C -s -p - - - '' - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC2 NC +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.target 1 OK - 2.target1 ERROR - 3.target1 ERROR - 4.target2 jap target1 OK - 5.target1 OK - 6.target1 OK - 7.target1 OK - 8.target2 jap target1 OK - initial condition: T2_1 - level: Integration - module: TCPIP - steps: "1.target1 打开DHCP 2\n2.target1 设置softAP ip 192.168.123.123\n3.target1 设置地址池\n4.target1下设置ssid - 和pwd 加密方式\n5.target2 连接target1 \n6.target1 关闭DHCP 2\n7.target1 设置softAP ip \n8.target1 - 设置正确的地址池\n9.target2 连接target1 " - sub module: DHCP - summary: ap dhcp static ip interaction - test environment: SSC_T2_5 - test point 1: interaction - test point 2: static IP and DHCP interaction test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_DHCP_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/SoftAPNSTA - - - sta_num = 4 - - - dummy - - - max_sta = 3 - - - '' - - - test_time = 300 - - - '' - - - delay1 = [5, 60] - - - '' - - - delay2 = [1, 10] - - - '' - - - change_mac = False - - - '' - - - channel = 11 - - - '' - execution time: 5.0 - expected result: "1. succeed\n2. succeed\n3. JAP succeed except: \nsoftap reach - max connected AP \nor all address in dhcp pool not available" - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. 1 target set to softap mode and rest set to sta mode - 2. set a short dhcp server lease time - 2. all sta set random mac, random join and disconnect from softap - Loop step 2 - sub module: DHCP - summary: max sta connect to SotfAP and disconnect, sta number more than sta allowed - test environment: SSC_T5_1 - test point 1: stress - test point 2: DHCP server stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_DHCP_5101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'No' - category: IOT - cmd set: '' - execution time: 0.1 - expected result: |- - 2. 成功 - 3. 成功 - 4. 断开连接并开始重连 - 5. WIFI连上但无法获取 IP,等大概1分钟后,发生 DHCP TIMEOUT,断开连接并重连,成功获取到 IP - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. 使用小米路由器青春版进行测试 - 2. 设置DHCP timeout(dhcp -T -n 6) - 3. target 连上 AP - 4. 路由器断电 - 5. 路由器上电 - sub module: DHCP - summary: DHCP timeout test on sepcial router - test environment: SSC_T1_IOT1 - test point 1: interoperability - test point 2: DHCP timeout test - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_DNS.yml b/components/idf_test/integration_test/TC_IT_TCPIP_DNS.yml deleted file mode 100644 index f393c771d..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_DNS.yml +++ /dev/null @@ -1,447 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_DNS_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/2 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -H -d gbot.espressif.cn - - - R SSC1 C +HOSTIP:OK,118.31.185.120 - execution time: 0.0 - expected result: 1.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: 1. get host name "gbot.espressif.cn" - sub module: DNS - summary: get host by name test - test environment: SSC_T1_2 - test point 1: basic function - test point 2: DNS function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_DNS_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/2 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -H -d gbot.espressif.cn - - - R SSC1 A :\+HOSTIP:OK,(.+)\r\n - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p 9001 - - - R SSC1 RE \+CONNECT:\d+,OK - - - SSC SSC1 soc -S -s -l 10 - - - P SSC1 RE \+SEND:\d+,OK - - P SSC1 SL +10 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. get host name "gbot.espressif.cn" - 2. connect, send, recv - sub module: DNS - summary: TCP connect to gbot.espressif.cn - test environment: SSC_T1_2 - test point 1: basic function - test point 2: DNS function test - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_DNS_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/2 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -H -d gbot.espressif.cn - - - R SSC1 A :\+HOSTIP:OK,(.+)\r\n - - - SSC SSC1 soc -B -t UDP - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p 9003 -l 10 -n 3 -j 1000 - - - P SSC1 RE \+SEND:\d+,OK - - P SSC1 SL +10 - execution time: 0.0 - expected result: |- - 1.OK - 2.send OK and recv at least one echo - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. get host name "espressif.cn" - 2. sendto echo server 3 times - sub module: DNS - summary: UDP send to gbot.espressif.cn - test environment: SSC_T1_2 - test point 1: basic function - test point 2: DNS function test - version: v2 (2016-10-19) -- CI ready: 'No' - ID: TCPIP_DNS_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: '' - execution time: 0.1 - expected result: 2. failed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP的主、备用DNS server均设置为错误 - 2.target连接上AP 并访问正确的域名 - sub module: DNS - summary: get host name with error DNS server - test environment: SSC_T1_2 - test point 1: abnormal/special use - test point 2: use special DNS server config - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_DNS_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: '' - execution time: 0.1 - expected result: 2. succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP的主DNS server设置为错误,备用DNS server设置为正确 - 2.target连接上AP 并访问正确的域名 - sub module: DNS - summary: get host name with error main DNS server and correct backup DNS server - test environment: SSC_T1_2 - test point 1: abnormal/special use - test point 2: use special DNS server config - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_DNS_0301 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "fallback_main_backup_dns_all_error" - - [''] - - - fallback_dns_option = "error" - - [''] - - - test_option = "main_backup_error" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "1.1.1.1" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 2.mode set ok - 3.connect ap sucess - 4.set fallback dns ok - 5.get dns ip fail - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main,backup DNS all error - 2.set SSC1 to sta mode - 3.SSC1 connect to ap - 4.set SSC1 fallback DNS - 5.SSC1 get website dns IP - sub module: DNS - summary: DNS fallback main backup DNS all error test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0302 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "fallback_dns_error_mian_backup_dns_right" - - [''] - - - fallback_dns_option = "error" - - [''] - - - test_option = "main_backup_right" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "2.2.2.2" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 2.mode set ok - 3.connect ap sucess - 4.set fallback dns ok - 5.get dns ip ok - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main,backup DNS all right - 2.set SSC1 to sta mode - 3.SSC1 connect to ap - 4.set SSC1 fallback DNS - 5.SSC1 get website dns IP - sub module: DNS - summary: DNS fallback DNS error main backup DNS right test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0303 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "fallback_main_dns_error_backup_dns_right" - - [''] - - - fallback_dns_option = "error" - - [''] - - - test_option = "backup_right" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "1.1.1.1" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 2.mode set ok - 3.connect ap sucess - 4.set fallback dns ok - 5.get dns ip ok - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main DNS error,backup DNS right - 2.SSC1 set as sta mode - 3.SSC1 connect to ap - 4.set SSC1 fallback DNS - 5.SSC1 get website dns IP - sub module: DNS - summary: DNS fallback main DNS error backup DNS right test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0304 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "fallback_main_backup_dns_all_right" - - [''] - - - fallback_dns_option = "right" - - [''] - - - test_option = "main_backup_right" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "208.67.222.222" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 2.mode set ok - 3.connect ap sucess - 4.set fallback dns ok - 5.get dns IP ok - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main ,backup DNS right - 2.SSC1 set as sta mode - 3.SSC1 connect to ap - 4.set SSC1 fallback DNS - 5.SSC1 get website dns IP - sub module: DNS - summary: DNS fallback main backup DNS all right test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0305 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "fallback_dns_right_main_backup_error" - - [''] - - - fallback_dns_set = "right" - - [''] - - - fallback_dns_option = "right" - - [''] - - - test_option = "main_backup_error" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "208.67.222.222" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 2.mode set ok - 3.connect ap sucess - 4.set fallback dns ok - 5.get dns IP ok - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main ,backup DNS all error - 2.SSC1 set as mode - 3.SSC1 connect to ap - 4.set SSC1 fallback DNS - 5.SSC1 get website dns IP - sub module: DNS - summary: DNS fallback DNS right main backup error test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0306 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "dns_dhcp_option" - - [''] - - - test_count = 20 - - [dummy] - - - fallback_dns = "208.67.222.222" - - [''] - - - website_dns = "www.baidu.com" - - [''] - execution time: 0.3 - expected result: |- - 1.ap set ok - 2.set sta mode ok - 3.jap ok - 4.disable dhcp ok - 5.set static ip addr suc - 6.set fallback dns suc - 7.get dns ip suc - 8.dhcp start suc - 9.get dns ip ok - 11.jap ok - 12.get dns ip ok - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.AP main ,backup DNS all right - 2.set SSC1 to sta mode - 3.SSC1 connect to ap - 4.SSC1 disable dhcp - 5.SSC1 set static ip addr - 6.SSC1 set fallback dns - 7.SSC1 get website dns IP - 8.SSC1 start dhcp - 9.SSC1 get website dns IP - 10.SSC1 disconnect with ap - 11.SSC1 reconnet ap - 12.SSC1 get website dns IP - sub module: DNS - summary: DNS DHCP option test - test environment: SSC_T1_DNS - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: TCPIP_DNS_0307 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - DNSTest/DNSTest - - - test_mode = "softap_dns_test" - - [''] - - - test_count = 20 - - [dummy] - - - main_dns = "208.67.222.222" - - [''] - execution time: 0.3 - expected result: |- - 1.set mode ok - 2.set mode ok - 3.sta connect softap suc - 4.disable dhcp ok - 5.set dns server suc - 6.set main dns suc - 7.SSC2 main dns must the same as SSC1 - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1.SSC1 set as softap - 2.SSC2 set as sta - 3.SSC2 connected softap - 4.SSC1 disable dhcp - 5.SSC1 dhcp action dns server - 6.SSC1 set main dns - 7.check SSC2 main dns server - sub module: DNS - summary: DNS softap DNS test - test environment: SSC_T2_1 - test point 1: stress + function - test point 2: DNS stress test - version: v2 (2016-10-23) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_ICMP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_ICMP.yml deleted file mode 100644 index fd84f57ea..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_ICMP.yml +++ /dev/null @@ -1,68 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_ICMP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/5 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ping -i - - - R SSC1 C +PING:OK - - - SSC SSC1 ping -i -c 2 - - - R SSC1 C +PING:OK - execution time: 0.0 - expected result: |- - 1.ok - 2.ok - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.ping -i - 2.ping -i -c 2 - sub module: ICMP - summary: ping function test - test environment: SSC_T1_5 - test point 1: basic function - test point 2: ping function test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_ICMP_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPIPStress/PingStress - - - test_time = 300 - - - dummy - - - test_freq = 0.2 - - - '' - - - ping_len = 64 - - - '' - - - target_mode = "STA" - - - '' - execution time: 5.0 - expected result: |- - 1. send succeed - 2. recv ping reply - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. PC send ping request to target - 2. PC check if received ping reply - sub module: ICMP - summary: ping target and check for ping reply - test environment: SSC_T1_1 - test point 1: stress - test point 2: ICMP ping stress test - version: v1 (2016-11-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_IGMP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_IGMP.yml deleted file mode 100644 index 92eea199b..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_IGMP.yml +++ /dev/null @@ -1,719 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_IGMP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -J -h -m 223.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h 192.168.237.77 -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h 192.168.237.77 -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: |- - 1. success - 2. failed - 3. failed - 4. failed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. join group with correct host addr and multicast addr - 2. join group with correct host addr and wrong multicast addr - 3. join group with wrong host addr and correct multicast addr - 4. join group with wrong host addr and wrong multicast addr - sub module: IGMP - summary: station IGMP join group address check - test environment: SSC_T1_5 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -L -h -m 224.1.1.2 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h 192.168.237.77 -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h 192.168.237.77 -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. success - 2. failed - 3. failed - 4. failed - 5. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. join group with correct host addr and multicast addr - 2. leave group with correct host addr and wrong multicast addr - 3. leave group with wrong host addr and correct multicast addr - 4. leave group with wrong host addr and wrong multicast addr - 5. leave group with correct host addr and correct multicast addr - sub module: IGMP - summary: station IGMP leave group address check - test environment: SSC_T1_5 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -J -h -m 223.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h 192.168.237.77 -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -J -h 192.168.237.77 -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: |- - 1. success - 2. failed - 3. failed - 4. failed - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1. join group with correct host addr and multicast addr - 2. join group with correct host addr and wrong multicast addr - 3. join group with wrong host addr and correct multicast addr - 4. join group with wrong host addr and wrong multicast addr - sub module: IGMP - summary: softAP IGMP join group address check - test environment: SSC_T1_8 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 igmp -L -h -m 224.1.1.2 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h 192.168.237.77 -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h 192.168.237.77 -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. success - 2. failed - 3. failed - 4. failed - 5. succeed - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1. join group with correct host addr and multicast addr - 2. leave group with correct host addr and wrong multicast addr - 3. leave group with wrong host addr and correct multicast addr - 4. leave group with wrong host addr and wrong multicast addr - 5. leave group with correct host addr and correct multicast addr - sub module: IGMP - summary: softAP IGMP leave group address check - test environment: SSC_T1_7 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -i 224.1.1.1 -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 SL +1 - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. able to recv packet - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. join group - 2. create UDP socket using multicast addr - 3. PC send UDP packet to multicast addr - sub module: IGMP - summary: station IGMP recv packets - test environment: SSC_T1_6 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -i 224.1.1.1 -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 SL +1 - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. target1 recv multicast packet - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. target2 set to sta mode and join AP - 2. target1 join group and create UDP socket using multicast addr - 3. target2 create UDP socket - 4. target2 send to multicast addr - sub module: IGMP - summary: station send multicast packets - test environment: SSC_T2_4 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0203 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -i 224.1.1.1 -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 SL +1 - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. able to recv packet - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1. join group - 2. create UDP socket using multicast addr - 3. PC send UDP packet to multicast addr - sub module: IGMP - summary: softAP IGMP recv packets - test environment: SSC_T1_8 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0204 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 igmp -J -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -i 224.1.1.1 -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 SL +1 - - - SSC SSC1 igmp -L -h -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. target1 recv multicast packet - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. target2 join SoftAP - 2. target1 join group and create UDP socket using multicast addr - 3. target2 create UDP socket - 4. target2 send to multicast addr - sub module: IGMP - summary: softAP send multicast packets - test environment: SSC_T2_4 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0101 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -J -s -m 223.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 soc -J -s -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. ERROR - 5. ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group with correct multicast addr - 3. leave group with correct multicast addr - 4. join group with wrong multicast addr - 5. join group with wrong multicast addr - sub module: IGMP - summary: station IGMP join group address check - test environment: SSC_T1_6 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0102 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.2 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. OK - 5. OK - 6. ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group with correct multicast addr - 3. leave group with correct multicast addr - 4. create UDP socket - 5. join group with correct multicast addr - 6. leave group with wrong multicast addr - sub module: IGMP - summary: station IGMP leave group address check - test environment: SSC_T1_5 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0103 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -J -s -m 223.1.1.1 - - - R SSC1 C +IGMP:ERROR - - - SSC SSC1 soc -J -s -m 240.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. ERROR - 5. ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group with correct multicast addr - 3. leave group with correct multicast addr - 4. join group with wrong multicast addr - 5. join group with wrong multicast addr - sub module: IGMP - summary: softAP IGMP join group address check - test environment: SSC_T1_8 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0104 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.2 - - - R SSC1 C +IGMP:OK - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:ERROR - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. OK - 5. OK - 6. ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group with correct multicast addr - 3. leave group with correct multicast addr - 4. create UDP socket - 5. join group with correct multicast addr - 6. leave group with wrong multicast addr - sub module: IGMP - summary: softAP IGMP leave group address check - test environment: SSC_T1_7 - test point 1: basic function - test point 2: IGMP API parameter check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0201 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '1/5' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 SL +1 - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 NC +RECVFROM - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. able to recv packet - 5. OK - 6. not able to recv packet - initial condition: STAM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group with correct multicast addr - 3. PC上 SOC1 UDP 传输,bing - 4. PC send UDP packet to multicast addr - 5. leave group with correct multicast addr - 6. PC send UDP packet to multicast addr - sub module: IGMP - summary: station IGMP recv packets - test environment: SSC_T1_6 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0202 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '1/5' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 op -S -o 1 - - - R SSC2 C +MODE:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 soc -T - - - R SSC2 C +CLOSEALL - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 SL +1 - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 NC +RECVFROM - - - SSC SSC2 soc -T -s - - - R SSC2 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: | - 1. OK - 2. target2 connect succeed - 3. CLOSEALL - 4. OK - 5. OK - 6. OK - 7. able to recv packet - 8. OK - 9. not able to recv packet - 10. OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: | - 1. target2 set to sta mode - 2. target2 join AP - 3. target2 close socket - 4. target1 create UDP socket - 5. target1 join group using multicast addr - 6. target2 create UDP socket - 7. target2 send to multicast addr - 8. target1 leave group with correct multicast addr - 9. target2 send to multicast addr - 10. target2 close socket - sub module: IGMP - summary: station send multicast packets - test environment: SSC_T2_4 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0203 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 SL +1 - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SOC SOC1 SENDTO 1 224.1.1.1 - - - R SSC1 NC +RECVFROM - execution time: 0.0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. able to recv packet - 5. OK - 6. not able to recv packet - initial condition: APM2 - level: Integration - module: TCPIP - steps: | - 1. create UDP socket - 2. join group using multicast addr - 3. PC上 SOC1 UDP 传输,bing - 4. PC send UDP packet to multicast addr - 5. leave group with correct multicast addr - 6. PC send UDP packet to multicast addr - sub module: IGMP - summary: softAP IGMP recv packets - test environment: SSC_T1_8 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IGMP_0204 - SDK: 'ESP32_IDF' - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :\+BIND:(\d+),OK - - - SSC SSC1 soc -J -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :\+BIND:(\d+),OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 SL +1 - - - SSC SSC1 soc -G -s -m 224.1.1.1 - - - R SSC1 C +IGMP:OK - - - SSC SSC2 soc -S -s -i 224.1.1.1 -p -l 10 - - - R SSC1 NC +RECVFROM - - - SSC SSC2 soc -T -s - - - R SSC2 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: | - 1. target2 connect succeed - 2. OK - 3. OK - 4. OK - 5. target1 able to recv packet - 6. OK - 7. target1 not able to recv packet - 8. OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: | - 1. target2 join AP - 2. target1 create UDP socket - 3. target1 join group using multicast addr - 4. target2 create UDP socket - 5. target2 send to multicast addr - 6. target1 leave group with correct multicast addr - 7. target2 send to multicast addr - 8. target2 close socket - sub module: IGMP - summary: softAP send multicast packets - test environment: SSC_T2_4 - test point 1: basic function - test point 2: IGMP send/recv test - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_IP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_IP.yml deleted file mode 100644 index 5af600a5e..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_IP.yml +++ /dev/null @@ -1,85 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_IP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.123.123 - - - R SSC1 C +IP:ERROR - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.123.123 - - - R SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 1 - - - R SSC1 C +STAIP:192.168.123.123 - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - 3.OK - 4.OK - 5.STAIP:192.168.123.123 - initial condition: STAM1 - level: Integration - module: TCPIP - steps: "1.target1 打开DHCP 1\n2.target1 设置sta ip 192.168.123.123\n4.target1 关闭DHCP - 1\n5.target1 设置sta ip 192.168.123.123\n6.target1 查询 当前sta ip " - sub module: IP - summary: sta set and query static ip test - test environment: SSC_T1_4 - test point 1: basic function - test point 2: set and query static IP - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_IP_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 dhcp -S -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 ip -S -o 2 -i 192.168.123.123 - - - R SSC1 C +IP:ERROR - - - SSC SSC1 dhcp -E -o 2 - - - R SSC1 C +DHCP:AP,OK - - - SSC SSC1 ip -S -o 2 -i 192.168.123.123 - - - R SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 2 - - - R SSC1 C +APIP:192.168.123.123 - - - SSC SSC1 ip -S -o 2 -i - - - R SSC1 C +IP:OK - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - 3.OK - 4.OK - 5.APIP:192.168.123.123 - 6.OK - initial condition: APM1 - level: Integration - module: TCPIP - steps: "1.target1 打开DHCP 2\n2.target1 设置softAP ip 192.168.123.123\n4.target1 关闭DHCP - 2\n5.target1 设置softAP ip 192.168.123.123\n6.target1 查询 当前sta ip \n7.target1 设置softAP - ip 为target_ap_ip" - sub module: IP - summary: ap set and query static ip test - test environment: SSC_T1_4 - test point 1: basic function - test point 2: set and query static IP - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_TCP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_TCP.yml deleted file mode 100644 index 6caeda062..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_TCP.yml +++ /dev/null @@ -1,4403 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_TCP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - P SOC1 C +ACCEPT - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i 123.456.678.789 -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.ERROR - 6.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket,bind到本地ip 0.0.0.0,本地端口 0 - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.target1上创建TCP socket,bind到本地ip 0.0.0.0,本地端口 0 - 5.target1上使用步骤4创建的socket,去连接不存在的ip,random_port - 6.target1上使用步骤2创建的socket,去连接 PC的ip,远端端口不存在。 - sub module: TCP - summary: STA mode, connect test. use different ip, port - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - P SOC_COM C OK - - - SOC SOC1 CONNECT - - - P SOC_COM C ERROR - - P SSC1 NC ACCEPT - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.PC TCP client accept - 4.error - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind到本地端口 - 2.target1上使用步骤1创建的socket,创建TCP 监听 - 3.PC TCP 连接到target1 , - 4.PC tcp 连接到不存在的port , - sub module: TCP - summary: STA mode, server listen test. use different kinds of port - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 5 - - - SSC SSC1 soc -S -s -l 1460 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 1460 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc上回accept - 4.OK - 5.target收到5 byte - 6.PC收到5 byte - 7.OK,PC 回SOC_RECV=SOC2,RECV_LEN=字节数 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: | - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,test_tcp_port1 - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.PC send 5 bytes to 8266 - 6.8266 send 5 bytes to PC - 7.8266 send 1460 to PC. - sub module: TCP - summary: STA mode, send/recv basic test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h B - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h W - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h R - - - R SSC1 RE SHUTDOWN:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept OK - 4.OK - 5.OK - 6.OK,pc tcp server accept OK - 7.OK - 8.OK - 9.OK,pc tcp server accept OK - 10.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 4.target1 shutdown socket1 B - 5.target1上创建TCP socket - 6.target1上使用步骤5创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 7.target1 shutdown socket2 W - 8.target1上创建TCP socket - 9.target1上使用步骤8创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 10.target1 shutdown socket3 R - sub module: TCP - summary: STA mode, shutdown basic test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0105 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.target1关闭socket1 - 8.target1关闭socket2 - 9.OK - 10.OK,pc tcp server accept成功 - 11.target1关闭socket1 - 12.OK - 13.OK,pc tcp server accept成功 - 14.OK - 15.target1关闭socket1 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1关闭socket1\n4.target1上创建TCP - socket 端口随机\n5.target1上使用步骤4创建的socket1,去监听\n6.PC CONNECT, - ,tcp 连接创建成功,创建socket2 \n7.target1关闭socket1\n8.target1关闭socket2\n9.target1上创建TCP - socket1\n10.target1上使用步骤10创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT\n11.target1关闭socket1\n12.target1上创建TCP - socket1\n13.target1上使用步骤13创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT\n14.target1shutdown - socket1\n15.target1关闭socket1" - sub module: TCP - summary: STA mode, close for different types of TCP sockets test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0106 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4 OK - 5.OK,pc tcp server accept成功 - 6.OK - 7.OK,pc tcp server accept成功 - 8 OK - 9.OK,pc tcp server accept成功 - 10.OK - 11.OK,pc tcp server accept成功 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT - 4.target1上创建TCP socket2 - 5.target1上使用步骤4创建的socket2,去连接 PC的ip,random_port,PC有ACCEPT - 6.target1上创建TCP socket3 - 7.target1上使用步骤6创建的socket3,去连接 PC的ip,random_port,PC有ACCEPT - 8.target1上创建TCP socket4 - 9.target1上使用步骤8创建的socket4,去连接 PC的ip,random_port,PC有ACCEPT - 10.target1上创建TCP socket5 - 11.target1上使用步骤10创建的socket5,去连接 PC的ip,random_port,PC有ACCEPT - sub module: TCP - summary: STA mode, create max TCP sockets test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0107 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC3 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC4 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC5 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC6 CONNECT - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - execution time: 0.0 - expected result: |- - 1.+BIND:0,OK,0.0.0.0 - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK,pc tcp server accept成功 - 5.OK,pc tcp server accept成功 - 6.OK,pc tcp server accept成功 - 7.OK,pc tcp server accept成功 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.target1上创建TCP socket 端口随机\n2.target1上使用步骤4创建的socket1,去监听\n3.PC CONNECT, - ,tcp 连接创建成功,创建socket2 \n4.PC CONNECT, ,tcp 连接创建成功,创建socket3 - \n5.PC CONNECT, ,tcp 连接创建成功,创建socket4 \n6.PC CONNECT, - ,tcp 连接创建成功,创建socket5 \n7.PC CONNECT, ,tcp 连接创建成功,创建socket6 - \ " - sub module: TCP - summary: STA mode, accept max TCP client by server test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0108 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1 - 3.target1 abort socket1 - 4.target1上创建TCP socket 端口随机 - 5.target1上使用步骤4创建的socket1,去监听 - 6.PC CONNECT, ,tcp 连接创建成功,创建socket2 - 7.target1 abort socket1 - 8.target1 abort socket2 - 9.target1上创建TCP socket1 - 10.target1上使用步骤10创建的socket1,去连接 PC的ip,test_tcp_port1,PC有ACCEPT - 11.target1 abort socket1 - sub module: TCP - summary: STA mode, espconn abort test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0110 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - P SOC1 C +ACCEPT - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i 123.456.678.789 -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.ERROR - 6.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket,bind到本地ip 0.0.0.0,本地端口 0 - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.target1上创建TCP socket,bind到本地ip 0.0.0.0,本地端口 0 - 5.target1上使用步骤4创建的socket,去连接不存在的ip,random_port - 6.target1上使用步骤2创建的socket,去连接 PC的ip,远端端口不存在。 - sub module: TCP - summary: AP mode, connect test. use different ip, port - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0111 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - P SOC_COM C OK - - - SOC SOC1 CONNECT 0 - - - P SOC_COM C ERROR - - P SSC1 NC ACCEPT - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.PC TCP client accept - 4.error - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind到本地端口 - 2.target1上使用步骤1创建的socket,创建TCP 监听 - 3.PC TCP 连接到target1 , - 4.PC tcp 连接到不存在的port , - sub module: TCP - summary: AP mode, server listen test. use different kinds of port - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0112 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 5 - - - SSC SSC1 soc -S -s -l 1460 -n 100 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 146000 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.target收到5byte数据 - 6.PC收到5byte数据 - 7.OK,PC 收到146000 byte数据 - initial condition: APM2 - level: Integration - module: TCPIP - steps: | - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接PC的ip,test_tcp_port1 - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.PC send 5 bytes to 8266 - 6.8266 send 5 bytes to PC - 7.8266 send 100 * 1460 to PC. - sub module: TCP - summary: AP mode, send/recv basic test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0113 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h B - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h W - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h R - - - R SSC1 RE SHUTDOWN:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK,pc tcp server accept成功 - 7.OK - 8.OK - 9.OK,pc tcp server accept成功 - 10.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1. PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 4.target1 shutdown socket1 B - 5.target1上创建TCP socket - 6.target1上使用步骤5创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 7.target1 shutdown socket2 W - 8.target1上创建TCP socket - 9.target1上使用步骤8创建的socket,去连接 PC的ip,random_port,PC有ACCEPT - 10.target1 shutdown socket3 R - sub module: TCP - summary: AP mode, shutdown basic test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0114 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT 0 - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK,target1上accept 成功 - 7.target1关闭socket1 - 8.target1关闭socket2 - 9.OK - 10.OK,pc tcp server accept成功 - 11.target1关闭socket1 - 12.OK - 13.OK,pc tcp server accept成功 - 14.OK - 15.target1关闭socket1 - initial condition: APM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1关闭socket1\n4.target1上创建TCP - socket 端口随机\n5.target1上使用步骤4创建的socket1,去监听\n6.PC CONNECT, - ,tcp 连接创建成功,创建socket2 \n7.target1关闭socket1\n8.target1关闭socket2\n9.target1上创建TCP - socket1\n10.target1上使用步骤10创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT\n11.target1关闭socket1\n12.target1上创建TCP - socket1\n13.target1上使用步骤13创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT\n14.target1shutdown - socket1\n15.target1关闭socket1" - sub module: TCP - summary: AP mode, close for different types of TCP sockets test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0115 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4 OK - 5.OK,pc tcp server accept成功 - 6.OK - 7.OK,pc tcp server accept成功 - 8 OK - 9.OK,pc tcp server accept成功 - 10.OK - 11.OK,pc tcp server accept成功 - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port,PC有ACCEPT - 4.target1上创建TCP socket2 - 5.target1上使用步骤4创建的socket2,去连接 PC的ip,random_port,PC有ACCEPT - 6.target1上创建TCP socket3 - 7.target1上使用步骤6创建的socket3,去连接 PC的ip,random_port,PC有ACCEPT - 8.target1上创建TCP socket4 - 9.target1上使用步骤8创建的socket4,去连接 PC的ip,random_port,PC有ACCEPT - 10.target1上创建TCP socket5 - 11.target1上使用步骤10创建的socket5,去连接 PC的ip,random_port,PC有ACCEPT - sub module: TCP - summary: AP mode, create max TCP sockets test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0116 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC3 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC4 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC5 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC6 CONNECT 0 - - - R SSC1 RE ACCEPT:(\d+),\d+,.+,\d+ - execution time: 0.0 - expected result: |- - 1.+BIND:0,OK,0.0.0.0 - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK,pc tcp server accept成功 - 5.OK,pc tcp server accept成功 - 6.OK,pc tcp server accept成功 - 7.OK,pc tcp server accept成功 - initial condition: APM2 - level: Integration - module: TCPIP - steps: "1.target1上创建TCP socket 端口随机\n2.target1上使用步骤4创建的socket1,去监听\n3.PC CONNECT, - ,tcp 连接创建成功,创建socket2 \n4.PC CONNECT, ,tcp 连接创建成功,创建socket3 - \n5.PC CONNECT, ,tcp 连接创建成功,创建socket4 \n6.PC CONNECT, - ,tcp 连接创建成功,创建socket5 \n7.PC CONNECT, ,tcp 连接创建成功,创建socket6 - \ " - sub module: TCP - summary: AP mode, accept max TCP client by server test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -i 0.0.0.0 -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h B - - - P SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSEALL - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.ok - 2.OK - 3.ERROR - 4.OK - 5.OK - 6.ERROR - 7.OK - 8.OK - 9.OK - 10.OK - 11.OK - 12.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建UDP传输socket,bind到本地ip 0.0.0.0, - 3.target1上使用步骤2创建的socket,去连接 PC的ip, - 4.target1上创建TCP socket - 5.target1上使用步骤4创建的socket,创建TCP 监听 - 6.target1上使用步骤4创建的socket,去连接 PC的ip, - 7.target1上创建TCP socket - 8.target1上使用步骤7创建的socket,去连接 PC的ip, - 9.target1上关闭步骤7创建的socket - 10.target1上使用步骤7创建的socket,去连接 PC的ip, - 11.target1上关闭所有创建的socket - 12.target1上使用步骤2创建的socket,去连接 PC的ip, - sub module: TCP - summary: STA mode, connect test. use socket in state that can't connect - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -L -s 1000 - - - R SSC1 RE LISTEN:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.ERROR - 4.OK - 5.OK - 6.ERROR - 7.OK - 8.ERROR - 9.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建UDP传输socket,bind到本地ip 0.0.0.0, - 3.target1上使用步骤2创建的socket,去建立TCP 监听 - 4.target1上创建TCP socket - 5.target1上使用步骤4创建的socket,去连接 PC的ip, - 6.target1上使用步骤4创建的socket,创建TCP 监听 - 7.target1上shutdown 步骤4的socket - 8.target1上使用步骤4创建的socket,创建TCP 监听 - 9.target1上使用不存在socket,创建TCP 监听 - sub module: TCP - summary: STA mode, server listen test. use socket in state that can't listen - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0203 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s - - - R SSC1 RE SEND:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s - - - R SSC1 RE SEND:\d+,ERROR - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -S -s - - - R SSC1 RE SEND:\d+,ERROR - - - SSC SSC1 soc -S -s 1000 - - - R SSC1 RE SEND:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.ERROR - 4.OK - 5.ERROR - 6.OK - 7.OK - 8.ERROR - 9.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建UDP传输socket1, - 3.target1上使用步骤2创建的socket1,去发送数据 - 4.target1上创建TCP socket2 - 5.target1上使用步骤4创建的socket2,去发送数据 - 6.target1上使用步骤4创建的socket2,创建TCP连接,连接成功 - 7.target1上shutdown 步骤4的socket2 - 8.target1往socket2发送错误命令发送数据 - 9.target1上不指定socket往上发送数据 - sub module: TCP - summary: send test. use socket in state that can't send - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0204 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -w 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 146000 - - - P SOC_COM R * - - - SSC SSC1 soc -W -s -o 1 - - - P SSC1 RE WORKTHREAD:\d+,OK - - P SSC1 SL +2920 - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc server accept OK - 4.OK - 5.OK - 6.OK - 7.target收到146000 byte - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.target上不进行recv - 6.PC send 100 * 1460 data to target, - 7.在target上开始recv - sub module: TCP - summary: STA mode, TCP recv buffer test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_TCP_0206 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP -i - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -I - - - P SSC1 RE "SOCINFO:%%s,2,%%s,\d+,%%s,%%d"%%(,,,) - - P SSC1 RE "SOCINFO:%%s,82,.+,%%d"%%(,) - - P SSC1 RE "SOCINFO:%%s,2,%%s,%%d,%%s,\d+"%%(,,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.PC OK, target1 +ACCEPT:3,2,,port - 10.+SOCINFO:,,, - +SOCINFO:,,, - +SOCINFO:, - +SOCINFO:,,, - +SOCINF0ALL - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port,PC有ACCEPT\n4.target1上创建TCP socket2,本地ip target_ip\n5.target1上使用步骤4创建的socket2,去连接 - PC的ip,random_port,PC有ACCEPT\n6.target1 shutdown socket2 \n7.target1上创建TCP socket3,本地端口random_port\n8.target1上使用步骤7创建的socket3,去监听\n9.PC - CONNECT, ,tcp 连接创建成功,创建socket4 \n10.target1 查询the socket - information" - sub module: TCP - summary: STA mode, TCP get active socket info test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0207 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -i 0.0.0.0 -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s -h B - - - P SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSEALL - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.ok - 2 OK - 3.ERROR - 4.OK - 5.OK - 6.ERROR - 7.OK - 8.OK - 9.OK - 10.OK - 11.OK - 12.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建UDP传输socket,bind到本地ip 0.0.0.0, - 3.target1上使用步骤2创建的socket,去连接 PC的ip, - 4.target1上创建TCP socket - 5.target1上使用步骤4创建的socket,创建TCP 监听 - 6.target1上使用步骤4创建的socket,去连接 PC的ip, - 7.target1上创建TCP socket - 8.target1上使用步骤7创建的socket,去连接 PC的ip, - 9.target1上关闭步骤7创建的socket - 10.target1上使用步骤7创建的socket,去连接 PC的ip, - 11.target1上关闭所有创建的socket - 12.target1上使用步骤2创建的socket,去连接 PC的ip, - sub module: TCP - summary: AP mode, connect test. use socket in state that can't connect - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0208 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,ERROR - - - SSC SSC1 soc -L -s 1000 - - - R SSC1 RE LISTEN:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.ERROR - 4 OK - 5.OK - 6.ERROR - 7.OK - 8.ERROR - 9.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建UDP传输socket,bind到本地ip 0.0.0.0, - 3.target1上使用步骤2创建的socket,去建立TCP 监听 - 4.target1上创建TCP socket - 5.target1上使用步骤4创建的socket,去连接 PC的ip, - 6.target1上使用步骤4创建的socket,创建TCP 监听 - 7.target1上shutdown 步骤4的socket - 8.target1上使用步骤4创建的socket,创建TCP 监听 - 9.target1上使用不存在socket,创建TCP 监听 - sub module: TCP - summary: AP mode, server listen test. use socket in state that can't listen - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0210 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -w 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 146000 - - - P SOC_COM R * - - - SSC SSC1 soc -W -s -o 1 - - - P SSC1 RE WORKTHREAD:\d+,OK - - P SSC1 SL +2920 - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 6.OK - 7.收到 146000 数据 - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1. PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.target停止调用recv - 6.PC send 100 * 1460 data to 8266, - 7.target重新调用recv - sub module: TCP - summary: AP mode, TCP recv buffer test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_TCP_0212 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP -i - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -D -s - - - R SSC1 RE SHUTDOWN:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT 0 - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -I - - - P SSC1 RE "SOCINFO:%%s,2,%%s,\d+,%%s,%%d"%%(,,,) - - P SSC1 RE "SOCINFO:%%s,82,.+,%%d"%%(,) - - P SSC1 RE "SOCINFO:%%s,2,%%s,%%d,%%s,\d+"%%(,,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.PC OK, target1 +ACCEPT:3,2,,port - 10.+SOCINFO:,,, - +SOCINFO:,,, - +SOCINFO:, - +SOCINFO:,,, - +SOCINF0ALL - initial condition: APM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port,PC有ACCEPT\n4.target1上创建TCP socket2,本地ip target_ip\n5.target1上使用步骤4创建的socket2,去连接 - PC的ip,random_port,PC有ACCEPT\n6.target1 shutdown socket2 \n7.target1上创建TCP socket3,本地端口random_port\n8.target1上使用步骤7创建的socket3,去监听\n9.PC - CONNECT, ,tcp 连接创建成功,创建socket4 \n10.target1 查询the socket - information" - sub module: TCP - summary: AP mode, TCP get active socket info test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0213 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC2 CONNECT 0 - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -A -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1 - 3.target1 abort socket1 - 4.target1上创建TCP socket 端口随机 - 5.target1上使用步骤4创建的socket1,去监听 - 6.PC CONNECT, ,tcp 连接创建成功,创建socket2 - 7.target1 abort socket1 - 8.target1 abort socket2 - 9.target1上创建TCP socket1 - 10.target1上使用步骤10创建的socket1,去连接 PC的ip,test_tcp_port1,PC有ACCEPT - 11.target1 abort socket1 - sub module: TCP - summary: AP mode, espconn abort test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use TCP SAP (socket/espconn API) in different state - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0301 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 lev -N -t GET - - - R SSC1 RE NUMBER:\d+,OK - execution time: 0.0 - expected result: 1.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: 1.lev -N -t GET - sub module: TCP - summary: STA mode, max connections number query - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0302 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 lev -N -t SET -n 2 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 lev -N -t SET -n 0 - - - R SSC1 C +NUMBER:ERROR - - - SSC SSC1 lev -N -t SET -n 16 - - - R SSC1 C +NUMBER:ERROR - - - SSC SSC1 lev -N -t SET -n 15 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - 3.ERROR - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.lev -N -t SET -n 2 - 2.lev -N -t SET -n 0 - 3.lev -N -t SET -n 15 - 4.lev -N -t SET -n 16 - 5.lev -N -t SET -n 8 - sub module: TCP - summary: STA mode, max connections number set - test environment: SSC_T1_5 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0303 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 lev -N -t SET -n 3 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC3 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC4 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSE - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip的ip,test_tcp_port1,PC有ACCEPT - 4.lev -N -t SET -n 3 - 5.target1上创建TCP socket3,本地端口random_port - 6.target1上使用步骤5创建的socket2,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 7.target1上创建TCP socket3,本地端口random_port - 8.target1上使用步骤7创建的socket3,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 9.target1上创建TCP socket4,本地端口random_port - 10.target1上使用步骤5创建的socket4,去连接 pc_ip_wifi的ip,test_tcp_port1,未连接成功 - sub module: TCP - summary: STA mode, max connections fucntion verify - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0304 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 5 - - - SSC SSC1 lev -N -t SET -n 3 - - - R SSC1 C +NUMBER:OK - - - SOC SOC2 SEND 146000 - - - R SSC1 SL +146000 - - - SSC SSC1 soc -S -s -l 1460 -n 100 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 146000 - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip的ip,test_tcp_port1,PC有ACCEPT - 4.PC 往8266发送数据 - 5.8266往PC 发送数据 - 6.lev -N -t SET -n 3 - 7.PC 往8266发送数据 146000 - 8.8266往PC 发送数据1460*100 - 9.target1上lev -N -t SET -n 8 - sub module: TCP - summary: STA mode, max connections set interact with TCP connect and send - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0305 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - P SOC_COM C OK - - - SSC SSC1 lev -A -s -t GET - - - 'R SSC1 RE ALLOW:' - - - SSC SSC1 lev -A -s -t SET -n 4 - - - R SSC1 RE ALLOW:\d+,OK - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.ERROR - 5.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip的ip,test_tcp_port1,PC有ACCEPT - 4.lev -A -s -t GET - 5.target1上lev -A -s -t SET -n 4 - sub module: TCP - summary: STA mode, max TCP connection allowed by server test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0306 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - P SOC_COM C OK - - - 'SSC SSC1 lev -K -s -t ENABLE ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - 'SSC SSC1 lev -K -s -t GET ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SSC SSC1 lev -K -s -t SET -i 30 -d 3 -c 2 - - - R SSC1 RE KEEPALIVE:\d+,OK - - - DELAY 30 - - - P SOC_COM NC SOC_CLOSED - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.SOC_COM NC SOC_CLOSED - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 test_tcp_port1\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - pc_ip的ip,test_tcp_port1,PC有ACCEPT\n4.lev -K -s -t ENABLE \n5.target1上lev - -K -s -t GET \n6.lev -K -s -t SET -i 30 -d 3 -c 2\n7.等待30s" - sub module: TCP - summary: STA mode, keep alive test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0307 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - R SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - R SOC_COM L OK - - - 'SSC SSC1 lev -K -s -t ENABLE ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - 'SSC SSC1 lev -K -s -t GET ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SSC SSC1 lev -K -s -t SET -i 30 -d 3 -c 2 - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SOC SOC1 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC1 RL 5 - - - SOC SOC1 SEND 146000 - - - R SSC1 SL +146000 - - - SSC SSC1 soc -S -s -l 1460 -n 100 - - - P SSC1 RE SEND:\d+,OK - - P SOC1 RL 146000 - - - DELAY 30 - - - P SOC_COM NC SOC_CLOSED - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.0K - 8.OK - 9.OK - 10.OK - 11.SOC_COM NC SOC_CLOSED - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 test_tcp_port1\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - pc_ip的ip,test_tcp_port1,PC有ACCEPT\n4.lev -K -s -t ENABLE \n5.target1上lev - -K -s -t GET \n6.lev -K -s -t SET -i 30 -d 3 -c 2\n7.PC往8266发送数据\n8.8266往PC上发送数据\n9.PC往8266发送146000数据\n10.8266往PC上发送1460*100数据\n11.等待30s" - sub module: TCP - summary: STA mode, keep alive interact with TCP send - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0308 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 lev -N -t GET - - - R SSC1 RE NUMBER:\d+,OK - execution time: 0.0 - expected result: 1.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: 1.lev -N -t GET - sub module: TCP - summary: AP mode, max connections number query - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0309 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 lev -N -t SET -n 2 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 lev -N -t SET -n 0 - - - R SSC1 C +NUMBER:ERROR - - - SSC SSC1 lev -N -t SET -n 16 - - - R SSC1 C +NUMBER:ERROR - - - SSC SSC1 lev -N -t SET -n 15 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - 3.ERROR - 4.OK - 5.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.lev -N -t SET -n 2 - 2.lev -N -t SET -n 0 - 3.lev -N -t SET -n 15 - 4.lev -N -t SET -n 16 - 5.lev -N -t SET -n 8 - sub module: TCP - summary: AP mode, max connections number set - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0310 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 lev -N -t SET -n 3 - - - R SSC1 C +NUMBER:OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC3 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC4 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -T - - - R SSC1 C +CLOSE - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 4.lev -N -t SET -n 3 - 5.target1上创建TCP socket3,本地端口random_port - 6.target1上使用步骤5创建的socket2,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 7.target1上创建TCP socket3,本地端口random_port - 8.target1上使用步骤7创建的socket3,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 9.target1上创建TCP socket4,本地端口random_port - 10.target1上使用步骤5创建的socket4,去连接 pc_ip_wifi的ip,test_tcp_port1,未连接成功 - sub module: TCP - summary: AP mode, max connections fucntion verify - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0311 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 5 - - - SSC SSC1 lev -N -t SET -n 3 - - - R SSC1 C +NUMBER:OK - - - SOC SOC2 SEND 146000 - - - R SSC1 SL +146000 - - - SSC SSC1 soc -S -s -l 1460 -n 100 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 146000 - - - SSC SSC1 lev -N -t SET -n 8 - - - R SSC1 C +NUMBER:OK - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 4.PC 往8266发送数据 - 5.8266往PC 发送数据 - 6.lev -N -t SET -n 3 - 7.PC 往8266发送数据 146000 - 8.8266往PC 发送数据1460*100 - 9.target1上lev -N -t SET -n 8 - sub module: TCP - summary: AP mode, max connections set interact with TCP connect and send - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0312 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 lev -A -s -t GET - - - R SSC1 RE ALLOW:\d+,ERROR - - - SSC SSC1 lev -A -s -t SET -n 4 - - - R SSC1 RE ALLOW:\d+,ERROR - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.ERROR - 5.ERROR - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.target1上创建TCP socket1,本地ip target_ip - 3.target1上使用步骤2创建的socket1,去连接 pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT - 4.lev -A -s -t GET - 5.target1上lev -A -s -t SET -n 4 - sub module: TCP - summary: AP mode, max TCP connection allowed by server test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0313 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - 'SSC SSC1 lev -K -s -t ENABLE ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - 'SSC SSC1 lev -K -s -t GET ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SSC SSC1 lev -K -s -t SET -i 30 -d 3 -c 2 - - - R SSC1 RE KEEPALIVE:\d+,OK - - - DELAY 30 - - - P SOC_COM NC SOC_CLOSED - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.SOC_COM NC SOC_CLOSED - initial condition: APM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 test_tcp_port1\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT\n4.lev -K -s -t ENABLE \n5.target1上lev - -K -s -t GET \n6.lev -K -s -t SET -i 30 -d 3 -c 2\n7.等待30s" - sub module: TCP - summary: AP mode, keep alive test - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0314 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i 0.0.0.0 -p 0 - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - 'SSC SSC1 lev -K -s -t ENABLE ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - 'SSC SSC1 lev -K -s -t GET ' - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SSC SSC1 lev -K -s -t SET -i 30 -d 3 -c 2 - - - R SSC1 RE KEEPALIVE:\d+,OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 5 - - - SOC SOC2 SEND 146000 - - - R SSC1 SL +146000 - - - SSC SSC1 soc -S -s -l 1460 -n 100 - - - P SSC1 RE SEND:\d+,OK - - P SOC2 RL 146000 - - - DELAY 30 - - - P SOC_COM NC SOC_CLOSED - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK,pc tcp server accept成功 - 4.OK - 5.OK - 6.OK - 7.0K - 8.OK - 9.OK - 10.OK - 11.SOC_COM NC SOC_CLOSED - initial condition: APM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 test_tcp_port1\n2.target1上创建TCP socket1,本地ip target_ip\n3.target1上使用步骤2创建的socket1,去连接 - pc_ip_wifi的ip,test_tcp_port1,PC有ACCEPT\n4.lev -K -s -t ENABLE \n5.target1上lev - -K -s -t GET \n6.lev -K -s -t SET -i 30 -d 3 -c 2\n7.PC往8266发送数据\n8.8266往PC上发送数据\n9.PC往8266发送146000数据\n10.8266往PC上发送1460*100数据\n11.等待30s" - sub module: TCP - summary: AP mode, keep alive interact with TCP send - test environment: SSC_T1_7 - test point 1: basic function - test point 2: socket option test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0401 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 sta -D - - - P SSC1 C +QAP:OK - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port - 4.PC与target1创建好TCP 连接,有ACCEPT - 5.断开与AP 连接 - 6.8266往PC上发送5字节数据 - sub module: TCP - summary: do TCP send after WIFI disconnected - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0402 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 sta -D - - - P SSC1 C +QAP:OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port - 4.PC与target1创建好TCP 连接,有ACCEPT - 5.断开与AP 连接 - 6.关闭建立的socket1连接 - sub module: TCP - summary: "close TCP socket after WIFI \ndisconnected" - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0403 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port\n4.PC与target1创建好TCP 连接,有ACCEPT\n5.修改8266的Mode为softAP mode - \n6.8266往PC上发送5字节数据" - sub module: TCP - summary: do TCP send after mode changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0404 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port\n4.PC与target1创建好TCP 连接,有ACCEPT\n5.修改8266的Mode为softAP mode - \n6.关闭建立的socket1连接" - sub module: TCP - summary: close TCP socket after mode changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0405 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - NIC DISABLED - - - R PC_COM C OK - - - SSC SSC1 soc -S -s -l 1 - - - '' - - - DELAY 5400 - - - P SSC1 RE CLOSED:\d+,0 - execution time: 1.5 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.TCP连接断开 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port - 4.PC与target1创建好TCP 连接,有ACCEPT - 5.PC 网卡 disable - 6.target1上使用socket1发送数据,等待 90 分钟 - sub module: TCP - summary: do TCP send after PC NIC disabled - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0406 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - NIC DISABLED - - - R PC_COM C OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port\n4.PC与target1创建好TCP 连接,有ACCEPT\n5.PC上网卡禁止掉 \n6.关闭建立的socket1连接" - sub module: TCP - summary: close TCP socket after PC NIC disabled - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0407 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.111.210 - - - P SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 1 - - - R SSC1 C +STAIP:192.168.111.210 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port\n4.PC与target1创建好TCP 连接,有ACCEPT\n5.关闭8266的DHCP 1\n6.设置sta - ip \n7.查询sta ip 地址是否生效\n8.8266往PC上发送5字节数据" - sub module: TCP - summary: do TCP send after IP changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0408 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.111.210 - - - P SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 1 - - - R SSC1 C +STAIP:192.168.111.210 - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上建立TCP 监听 random_port\n2.target1上创建TCP socket1\n3.target1上使用步骤2创建的socket1,去连接 - PC的ip,random_port\n4.PC与target1创建好TCP 连接,有ACCEPT\n5.关闭8266的DHCP 1\n6.设置sta - ip \n7.查询sta ip 地址是否生效\n8.关闭建立的socket1连接" - sub module: TCP - summary: close TCP socket after IP changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0411 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,ERROR - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.ERROR - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port - 4.PC与target1创建好TCP 连接,有ACCEPT - 5.target1上创建TCP socket2 - 6.8266往PC socket2上发送5字节数据 - 7.8266往PC socket1上发送5字节数据 - sub module: TCP - summary: do TCP send after socket changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0412 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - R SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket1 - 3.target1上使用步骤2创建的socket1,去连接 PC的ip,random_port - 4.PC与target1创建好TCP 连接,有ACCEPT - 5.target1上创建TCP socket2 - 6.关闭socket1 连接 - 7.关闭socket2连接 - sub module: TCP - summary: close TCP send after socket changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_0501 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - STRING ether%20src%20%%s%20or%20ether%20dst%20%%s - - - - R PC_COM C OK - - - NIC NIC1 START capture+block_ip - - - R PC_COM C +NIC_START:OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - '' - - - DELAY 10 - - - R SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: 2. connect failed, no exception - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. PC do not reply any IP packet on NIC - 2. target try to connect to TCP server with PC NIC IP - sub module: TCP - summary: PC do not reply TCP SYN of target - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: TCP connect and disconnect abnormal case - version: v1 (2015-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0601 - SDK: |- - 8266_RTOS - 8266_NonOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 socopt -S -s -k Keepalive -o 1 - - - R SSC1 C +SETOPTION:Keepalive,OK - - - SSC SSC1 socopt -S -s -k Keepidle -o 20 - - - R SSC1 C +SETOPTION:Keepidle,OK - - - SSC SSC1 socopt -S -s -k Keepintvl -o 1 - - - R SSC1 C +SETOPTION:Keepintvl,OK - - - SSC SSC1 socopt -S -s -k Keepcnt -o 3 - - - R SSC1 C +SETOPTION:Keepcnt,OK - - - NIC DISABLED - - - R PC_COM C OK - - - DELAY 30 - - - R SSC1 C CLOSE - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.等待30s - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上步骤3创建的socket设置so_keepalive属性 - 4.target1上步骤3创建的socket设置so_keepidle参数 - 5.target1上步骤3创建的socket设置so_keepintvl参数 - 6.target1上步骤3创建的socket设置so_keepcnt参数 - 7.target1上使用步骤7具有so_keepalive属性及参数的socket,去连接 PC的ip,random_port - 8.PC上网卡禁止掉 - 9.等待30s - sub module: TCP - summary: Test socket with so_keepalive option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0602 - SDK: |- - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 C +BIND:ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind test_udp_port1 - 2.target1上创建TCP socket,bind test_udp_port1 - sub module: TCP - summary: Test socket with so_reuseaddr option closed on TCP submodule - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0603 - SDK: ESP32_IDF - Test App: SSC_OPTION - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T - - - R SSC1 C CLOSEALL - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE LISTEN:\d+,OK - - - SSC SSC1 soc -T - - - R SSC1 C CLOSEALL - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.CLOSEALL - 5.OK - 6.OK - 7.CLOSEALL - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket,bind test_tcp_port2 - 3.target1上使用步骤4创建的socket,去连接 PC的ip,random_port - 4.关闭socket - 5.target1上创建TCP socket,bind test_tcp_port2 - 6.target1上建立TCP 监听 - 7.关闭socket - sub module: TCP - summary: Test socket with so_reuseaddr option opened that close TCP connection not - react immediately on ESP32 - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0604 - SDK: ESP32_IDF - Test App: SSC_OPTION - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind test_udp_port1 - 2.target1上创建TCP socket,bind test_udp_port1 - sub module: TCP - summary: Test socket with so_reuseaddr option opened that build two tcp sockets - by binding same ip and port on ESP32 - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0605 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - - SSC SSC1 socopt -S -s -k Sndtimeo -o 1 - - - R SSC1 C +SETOPTION:Sndtimeo,OK - - - NIC DISABLED - - - R PC_COM C OK - - - SSC SSC1 soc -S -s -l 5000 - - - P SSC1 RE SEND:\d+,OK - - - SSC SSC1 soc -S -s -l 5000 -n 4 - - - P SSC1 RE SEND:\d+,ERROR,11 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.PC send 5 bytes to target1 - 6.target1 send 5 bytes to PC - 7.target1上对步骤2创建的socket设置so_sndtimeo属性 - 8.PC上网卡禁止掉 - 9.target1 send 5000 bytes to PC - 10.target1 send 5000 bytes to PC - sub module: TCP - summary: Test socket with so_sndtimeo option on ESP32 - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0606 - SDK: |- - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 socopt -S -s -k Rcvtimeo -o 1 - - - R SSC1 C +SETOPTION:Rcvtimeo,OK - - - SOC SOC2 SEND 5 - - - R SSC1 RE CLOSED:\d+,11 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.CLOSED - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤3创建的socket,去连接 PC的ip,random_port - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.PC send 5 bytes to target1 - 6.target1上对步骤3创建的socket设置so_rcvtimeo属性 - 7.PC send 5 bytes to target1 - sub module: TCP - summary: Test socket with so_rcvtimeo option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0607 - SDK: |- - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.target1上使用步骤2创建的socket,去连接 PC的ip,random_port, 获取 error code - sub module: TCP - summary: Test socket with so_error option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0608 - SDK: 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 ram -Q - - - R SSC1 A :\+FREEHEAP:(\d+)\r\n - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 socopt -S -s -k Linger -o 1 - - - R SSC1 C +SETOPTION:Linger,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T - - - P SSC1 RE CLOSE:\d+,OK - - - SSC SSC1 ram -Q - - - R SSC1 P - execution time: 0.0 - expected result: |- - 1.OK - 2.查询空闲ram - 3.OK - 4.OK - 5.OK - 6.OK - 7.查询空闲ram - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.查询空闲ram - 3.target1上创建TCP socket - 4.target1上对步骤3创建的socket设置so_linger属性 - 5.target1上使用步骤4具有so_linger属性的socket,去连接 PC的ip,random_port - 6.关闭 socket - 7.查询空闲ram - sub module: TCP - summary: Test socket with so_linger option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_0609 - SDK: 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T - - - R SSC1 C CLOSEALL - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE LISTEN:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.CLOSEALL - 5.OK - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.find ESP8266_RTOS_SDK/include/lwip/lwip/opt.h file, make "#define SO_REUSE 1" instead of "#define SO_REUSE 0" - 2.switch to ESP8266_RTOS_SDK/third_party, run "./make_lib.sh lwip" risc,then continuely run "ll ../lib" - 3.switch to ESP8266_RTOS_SDK/SSC, run "./gen_misc_rtos.sh SSC", then run the test case normally - 4.PC上建立TCP 监听 random_port - 5.target1上创建TCP socket,bind random_port - 6.target1上使用步骤5创建的socket,去连接 PC的ip,random_port - 7.关闭socket - 8.target1上创建TCP socket,bind random_port - 9.target1上建立TCP 监听 - sub module: TCP - summary: Test socket with so_reuseaddr option opened that close TCP connection not - react immediately on 8266_RTOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_0610 - SDK: 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.find ESP8266_RTOS_SDK/include/lwip/lwip/opt.h file, make "#define SO_REUSE 1" instead of "#define SO_REUSE 0" - 2.switch to ESP8266_RTOS_SDK/third_party, run "./make_lib.sh lwip" risc,then continuely run "ll ../lib" - 3.switch to ESP8266_RTOS_SDK/SSC, run "./gen_misc_rtos.sh SSC", then run the test case normally - 4.target1上创建TCP socket,bind test_tcp_port2 - 5.target1上创建TCP socket,bind test_tcp_port2 - sub module: TCP - summary: Test socket with so_reuseaddr option opened that build two tcp sockets - by binding same ip and port on 8266_RTOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0611 - SDK: 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SOC SOC1 ACCEPT SOC2 - - - R SOC_COM L OK - - - SOC SOC2 SEND 5 - - - R SSC1 SL +5 - - - SSC SSC1 soc -S -s -l 5 - - - P SSC1 RE SEND:\d+,OK - - - SSC SSC1 socopt -S -s -k Sndtimeo -o 1 - - - R SSC1 C +SETOPTION:Sndtimeo,OK - - - NIC DISABLED - - - R PC_COM C OK - - - SSC SSC1 soc -S -s -l 1500 - - - P SSC1 RE SEND:\d+,OK - - - SSC SSC1 soc -S -s -l 1500 - - - P SSC1 RE SEND:\d+,ERROR,11 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - 8.OK - 9.OK - 10.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.PC与target1 创建好TCP 连接,有ACCEPT - 5.PC send 5 bytes to target1 - 6.target1 send 5 bytes to PC - 7.target1上对步骤2创建的socket设置so_sndtimeo属性 - 8.PC上网卡禁止掉 - 9.target1 send 1500 bytes to PC - 10.target1 send 1500 bytes to PC - sub module: TCP - summary: Test socket with so_sndtimeo option on 8266_RTOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0612 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SOC SOC2 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 socopt -S -s -k Maxconnect -o 1 - - - R SSC1 C +SETOPTION:Maxconnect,OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,ERROR - - - SSC SSC1 soc -T - - - R SSC1 C CLOSE - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.ERROR - 8.CLOSE - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 test_tcp_port1 - 2.PC上建立TCP 监听 test_tcp_port2 - 3.target1上创建TCP socket - 4.target1上对步骤3创建的socket设置 Maxconnect属性 - 5.target1上使用步骤4具有Maxconnect属性的socket,去连接 PC的ip,test_tcp_port1 - 6.target1上创建TCP socket - 7.target1上使用步骤6创建的socket,去连接 PC的ip,test_tcp_port2 - 8.关闭socket - sub module: TCP - summary: Test socket with Maxconnect option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0613 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE LISTEN:\d+,OK - - - SSC SSC1 socopt -S -s -k MaxConnectNum -o 1 - - - R SSC1 C +SETOPTION:MaxConnectNum,OK - - - SOC SOC1 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - SOC SOC2 CONNECT - - - P SOC_COM C ERROR - - - SSC SSC1 soc -T - - - R SSC1 C CLOSE - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.PC TCP client accept - 5.ERROR - 6.CLOSE - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind random_port - 2.target1上使用步骤2创建的socket1,建立TCP 监听 - 3.target1上对步骤2创建的socket设置 MaxConnectNum属性 - 4.PC TCP 连接到target1 , - 5.PC TCP 连接到target1 , - 6.关闭socket - sub module: TCP - summary: Test socket with MaxConnectNum option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0614 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 socopt -S -s -k Registtime -o 20 - - - R SSC1 C +SETOPTION:Registtime,OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE LISTEN:\d+,OK - - - SOC SOC1 CONNECT - - - R SSC1 A :ACCEPT:(\d+),\d+,.+,\d+ - - - DELAY 30 - - - P SOC_COM NC SOC_CLOSED - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.PC TCP client accept - 5.等待30s - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind test_tcp_port1 - 2.target1上对步骤2创建的socket设置 Registtime 属性 - 3.target1上使用步骤3具有Registtime属性的socket1,建立TCP 监听 - 4.PC TCP 连接到target1 , - 5.等待30s - sub module: TCP - summary: Test socket with Registtime option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0615 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 socopt -S -s -k Abort - - - R SSC1 C CLOSED - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.CLOSED - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.target1上对步骤2创建的socket设置 Abort 属性 - sub module: TCP - summary: Test socket with Abort option - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0616 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 LISTEN - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -C -s -i -p - - - P SSC1 RE CONNECT:\d+,OK - - - SSC SSC1 soc -T - - - R SSC1 C CLOSEALL - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -L -s - - - P SSC1 RE LISTEN:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.CLOSEALL - 5.OK - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上建立TCP 监听 random_port - 2.target1上创建TCP socket,bind test_tcp_port1 - 3.target1上使用步骤2创建的socket,去连接 PC的ip,random_port - 4.关闭socket - 5.target1上创建TCP socket,bind test_tcp_port1 - 6.target1上建立TCP 监听 - sub module: TCP - summary: Test socket with so_reuseaddr option opened that close TCP connection not - react immediately on 8266_NonOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_0617 - SDK: 8266_NonOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t TCP -i -p - - - R SSC1 A :BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建TCP socket,bind test_tcp_port1 - 2.target1上创建TCP socket,bind test_tcp_port1 - sub module: TCP - summary: Test socket with so_reuseaddr option opened that build two tcp sockets - by binding same ip and port on 8266_NonOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPConnection - - - max_connection = 5 - - - dummy - - - execute_time = 300 - - - '' - - - connect_method = ["C_01", "C_02", "C_05", "C_07"] - - - '' - - - disconnect_method = ["D_01", "D_03", "D_05", "D_06"] - - - '' - - - pc_ip = "pc_ip" - - - '' - - - target_ip = "target_ip" - - - '' - execution time: 5.0 - expected result: 1. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. random choose connect method to do connect, random choose a method to close - Loop executing step 1 - sub module: TCP - summary: test possible TCP connect/disconnect method - test environment: SSC_T1_6 - test point 1: function + stress - test point 2: TCP connect and disconnect test - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - TCPStress/TCPAPNSTA - - - send_len = 1460 - - - dummy - - - test_time = 720 - - - '' - - - server_port = "" - - - '' - - - server_echo = True - - - '' - - - sta_number = 4 - - - '' - - - send_delay = 50 - - - '' - - - ap_ip = "" - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. all TCP connection not disconnected - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. all sta connect to softap - 2. create tcp server on softap - 3. all sta connect to softap tcp server - 4. do bi-direction send on all tcp connections - sub module: TCP - summary: 1 AP 4 STA TCP stable test - test environment: SSC_T5_1 - test point 1: stable - test point 2: TCP stable test - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - TCPStress/TCPRandomSend - - - delay_config = [0, 0.01, 0.1, 0.5, 1] - - - dummy - - - send_count = 1000 - - - '' - - - test_time = 300 - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. PC send random length data to target - sub module: TCP - summary: send random length segment to target - test environment: SSC_T1_6 - test point 1: stable - test point 2: TCP stable test - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - TCPStress/TCPSoftAPSTASendRecv - - - send_len = 1460 - - - dummy - - - test_time = 720 - - - '' - - - test_count = 0xFFFFFF - - - '' - - - server_port = "" - - - '' - - - server_port_2 = "" - - - '' - - - server_echo = True - - - '' - - - sta_number = 3 - - - '' - - - send_delay = 50 - - - '' - - - pass_standard = (4*3600) - - - '' - - - ap_ip = "" - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. verify reciveid data on target and PC succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. send specified pattern on both direction - sub module: TCP - summary: TCP SoftSTA send/recv stress test - test environment: SSC_T5_1 - test point 1: stable - test point 2: TCP stable test - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_TCP_5104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPMultiSTASendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - server_echo = True - - - '' - - - sta_number = 5 - - - '' - - - send_delay = 500 - - - '' - execution time: 5.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. 5 sta connect to softap - 2. create TCP socket on all sta - 3. all sta do TCP send/recv - sub module: TCP - summary: 1 SoftAP 5 STA, create TCP server on one STA, create TCP client on other - STA, do TCP send/recv - test environment: SSC_T6_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5105 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSTAMuitiSockSendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - server_echo = True - - - '' - - - sta_number = 2 - - - '' - - - conn_number = 6 - - - '' - - - send_delay = 500 - - - '' - execution time: 5.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. 2 sta connect to softap - 2. create multi tcp socket on all sta - 3. all sta do tcp send/recv - sub module: TCP - summary: 1 SoftAP 2 STA, create multi TCP socket between STA, do TCP send/recv - test environment: SSC_T3_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5106 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - TCPStress/TCPRandomSend - - - delay_config = [0, 0.01, 0.1, 0.5, 1] - - - dummy - - - send_count = 1000 - - - '' - - - test_time = 300 - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. PC send random length data to target - sub module: TCP - summary: send random length segment to target for Ethernet - test environment: ETH_T1_1 - test point 1: stable - test point 2: TCP stable test - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - duplex = True - - - '' - - - conn_num = 5 - - - '' - - - send_delay = 20 - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. all TCP connection not disconnected - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple tcp connection - 3. do send/recv on all tcp connections - sub module: TCP - summary: TCP send/recv stress test - test environment: SSC_T2_5 - test point 1: stress - test point 2: TCP stress test - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPDataValidation - - - test_time = 1440 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = True - - - '' - - - conn_num = 1 - - - '' - - - send_len = 1024 - - - '' - execution time: 24.0 - expected result: |- - 1. succeed - 2. verify reciveid data on target and PC succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. send specified pattern on both direction - sub module: TCP - summary: TCP send/recv data validation - test environment: SSC_T1_6 - test point 1: stress - test point 2: TCP stress test - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_TCP_5203 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPRandomSend - - - delay_config = [0, 0.01, 0.1, 0.5, 1] - - - dummy - - - send_count = 1000 - - - '' - - - test_time = 300 - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. 不断开 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. ESP8089在同一信道进行iperf测试 - 2. create TCP connection - 3. PC send random length data to target - sub module: TCP - summary: TCP 信道竞争测试 - test environment: SSC_T1_8089 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5204 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPDataValidation - - - test_time = 1440 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = True - - - '' - - - conn_num = 1 - - - '' - - - send_len = 1024 - - - '' - execution time: 24.0 - expected result: |- - 1. succeed - 2. verify reciveid data on target and PC succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. send specified pattern on both direction - sub module: TCP - summary: TCP send/recv data validation for Ethernet - test environment: ETH_T1_1 - test point 1: stress - test point 2: TCP stress test - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_TCP_5301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 5 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. config attenuator (0-59) - 2. scan AP to get AP RSSI - 3. create TCP connection and send data for several seconds - Loop step 1 - 3 - sub module: TCP - summary: TCP throughput Tx in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: TCP throughput - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5302 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 5 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. config attenuator (0-59) - 2. scan AP to get AP RSSI - 3. create TCP connection and recv data for several seconds - Loop step 1 - 3 - sub module: TCP - summary: TCP throughput Rx in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: TCP throughput - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5401 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/EthTCPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 30 - - - '' - - - test_count = 5 - - - '' - execution time: 0.5 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. DUT band socket and send packet to PC for several secends - Loop for step 1-2 - sub module: TCP - summary: TCP throughput Tx for Ethernet - test environment: ETH_T1_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5402 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/EthTCPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 30 - - - '' - - - test_count = 5 - - - '' - execution time: 0.5 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. DUT band socket and PC send packet to DUT for several secends - Loop for step 1-2 - sub module: TCP - summary: TCP throughput Rx for Ethernet - test environment: ETH_T1_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5501 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/EthTCPSocketTest - - - send_len = 1460 - - - dummy - - - test_count = 1000 - - - '' - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. PC bind socket and send packet to DUT for several secends - 3. DUT close eth randomly - Loop for step 1-3 - sub module: TCP - summary: Eth random close while sending packets - test environment: ETH_T1_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_5601 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSoftAPSTAThroughput - - - send_len = 1460 - - - dummy - - - sta_rx_enable = False - - - '' - - - sta_tx_enable = True - - - '' - - - measure_period = 15 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. STA connect softAP - 2. create TCP socket connect - 3. send TCP packet - 4. calculate the troughput - sub module: TCP - summary: STA TCP throughput Tx while connected with softAP - test environment: SSC_T2_ShieldBox2 - test point 1: Performance test - test point 2: TCP throughput - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_TCP_5602 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSoftAPSTAThroughput - - - send_len = 1460 - - - dummy - - - sta_rx_enable = True - - - '' - - - sta_tx_enable = False - - - '' - - - measure_period = 15 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. STA connect softAP - 2. create TCP socket connect - 3. send TCP packet - 4. calculate the troughput - sub module: TCP - summary: STA TCP throughput Rx while connected with softAP - test environment: SSC_T2_ShieldBox2 - test point 1: Performance test - test point 2: TCP throughput - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_TCP_5701 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - StableTest/EthGetIP - - - test_count = 5000 - - [dummy] - comment: '' - execution time: 5.0 - expected result: '1. succeed - - 2. succeed - - 3. succeed - - 4. succeed' - initial condition: None - initial condition description (auto): none - level: Integration - module: TCPIP - steps: |- - 1. reboot - - 2. open eth - - 3. delay 10s - - 4. ip query - sub module: TCP - summary: Eth get ip test - test environment: ETH_T1_1 - test point 1: stress - test point 2: TCP stress test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5801 - SDK: 'ESP32_IDF' - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSendRecvIPv6 - - - send_len = 1460 - - [dummy] - - - test_time = 300 - - [''] - - - duplex = True - - [''] - - - conn_num = 5 - - [''] - - - send_delay = 20 - - [''] - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. all TCP connection not disconnected - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple tcp connection - 3. do send/recv on all tcp connections - sub module: TCP - summary: TCP send/recv stress test with TCPSendRecvIPv6 - test environment: SSC_T2_5 - test point 1: stress - test point 2: TCP stress test(IPv6) - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5802 - SDK: 'ESP32_IDF' - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPSoftAPSTASendRecvIPv6 - - - send_len = 1460 - - [dummy] - - - test_time = 300 - - [''] - - - conn_num = 5 - - [''] - - - duplex = True - - [''] - - - send_delay = 20 - - [''] - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. all TCP connection not disconnected - initial condition: T3_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple tcp connection - 3. do send/recv on all tcp connections - sub module: TCP - summary: TCP send/recv stress test with TCPSoftAPSTASendRecvIPv6 - test environment: SSC_T3_1 - test point 1: stress - test point 2: TCP stress test(IPv6) - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_TCP_5803 - SDK: 'ESP32_IDF' - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPDataValidationIPv6 - - - test_time = 300 - - [dummy] - - - tx_enable = True - - [''] - - - rx_enable = True - - [''] - - - conn_num = 5 - - [''] - - - send_len = 1024 - - [''] - execution time: 24.0 - expected result: |- - 1. succeed - 2. verify reciveid data on target and PC succeed - initial condition: STAAP2 - level: Integration - module: TCPIP - steps: |- - 1. create TCP connection - 2. send specified pattern on both direction - sub module: TCP - summary: TCP send/recv data validation with TCPDataValidationIPv6 - test environment: SSC_T1_6 - test point 1: stress - test point 2: TCP stress test(IPv6) - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_TCP_6001 - SDK: ESP32_IDF, 8266_NonOS, 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Stable - cmd set: - - StableTest/TCPStable - - - send_delay = 5 - - - '' - - - timeout = 20 - - - '' - - - test_time = 7*24*60 - - - '' - - - conn_num = 1 - - - '' - - - send_len = 100 - - - '' - execution time: 168 - expected result: 1. succeed 2. DUT1 receive PC echo in timeout 3. succeed 4. succeed - initial condition: STAO2 - level: Integration - module: TCPIP - steps: 1. create TCP connection 2. DUT send data to PC, PC do echo 3. delay for - send_delay 4. repeat step 2-3 - sub module: TCP - summary: TCP send receive delay stable test - test environment: SSC_T1_6 - test point 1: Stable - test point 2: TCP send receive stable test - version: v1 (2017-04-21) -- CI ready: 'No' - ID: TCPIP_TCP_9901 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - TCPStress/TCPThroughputCompatibility - - - send_len = 1460 - - - dummy - - - test_times = 10 - - - '' - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create TCP connection and send data for several seconds - 3. calculate the throughput - Loop step 1 - 3 - sub module: TCP - summary: TCP throughput Tx Compatibility test in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: TCP throughput Compatibility test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_TCP_9902 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - TCPStress/TCPThroughputCompatibility - - - send_len = 1460 - - - dummy - - - test_times = 10 - - - '' - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create TCP connection and send data for several seconds - 3. calculate the throughput - Loop step 1 - 3 - sub module: TCP - summary: TCP throughput Rx Compatibility test in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: TCP throughput Compatibility test - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_TCPIP_UDP.yml b/components/idf_test/integration_test/TC_IT_TCPIP_UDP.yml deleted file mode 100644 index 6f3c7f71b..000000000 --- a/components/idf_test/integration_test/TC_IT_TCPIP_UDP.yml +++ /dev/null @@ -1,2052 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: TCPIP_UDP_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -i 0.0.0.0 -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 C BIND:ERROR - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 RE BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.ERROR - 4.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上UDP传输,Bind socket2,本地ip 0.0.0.0 target_udp_port2 - 3.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 4.target1上创建TCP socket3, target_udp_port1 - sub module: UDP - summary: STA mode, udp bind test. use different ip, port - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 2/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SOC SOC2 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 10 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 10 - - - SSC SSC1 soc -S -s -i -p -l 10 - - - P SSC1 RE SEND:(\d+),OK - - P SOC2 UL 10 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.PC上SOC2 UDP传输,bing - 3.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 4.target1上使用步骤3创建的socket1,往pc_ip,test_tcp_port1上发送10字节数据 - 5.target1上使用步骤3创建的socket1,往pc_ip2,test_tcp_port2上发送10字节数据 - sub module: UDP - summary: STA mode, sendto test. use different ip, port - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 1 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1 - - - SSC SSC1 soc -S -s -i -p -l 1472 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1472 - - - SSC SSC1 soc -S -s -i -p -l 1473 - - - P SSC1 RE SEND:(\d+),OK - - P SOC_COM NC SOC_RECVFROM - - - SSC SSC1 soc -S -s -i -p -l 1472 -n 10 -j 20 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 14720 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK,没有到UDP包 - 6.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1字节数据 - 4.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472字节数据 - 5.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1473字节数据 - 6.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472*10字节数据 - sub module: UDP - summary: STA mode, sendto test with different length - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0103 - SDK: ESP32_IDF - Test App: SSC - allow fail: 1/5 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 1 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1 - - - SSC SSC1 soc -S -s -i -p -l 1472 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1472 - - - SSC SSC1 soc -S -s -i -p -l 1473 - - - P SSC1 RE SEND:(\d+),OK - - P SOC_COM NC SOC_RECVFROM - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1字节数据 - 4.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472字节数据 - 5.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1473字节数据 - sub module: UDP - summary: STA mode, sendto test with different length - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 1 - - - R SSC1 SL +1 - - - SOC SOC1 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - - - SOC SOC1 SENDTO 1473 - - - P SSC1 NC +RECVFROM - - P SOC_COM C OK - - - SOC SOC2 BIND - - - R SOC_COM L OK - - - SOC SOC2 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK,没收到UDP包 - 6.OK - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.PC往8266上发送1字节数据 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1473字节数据 - 6.PC上SOC2 UDP传输,bing - 7.PC往8266上发送1472字节数据 - sub module: UDP - summary: (special case)STA mode, recvfrom basic test with STAM2 - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0104_02 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND_v6 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDPv6 -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 1 - - - R SSC1 SL +1 - - - SOC SOC1 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - - - SOC SOC1 SENDTO 1473 - - - P SSC1 C +RECVFROM - - P SOC_COM C OK - - - SOC SOC2 BIND_v6 - - - R SOC_COM L OK - - - SOC SOC2 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.PC往8266上发送1字节数据 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1473字节数据 - 6.PC上SOC2 UDP传输,bing - 7.PC往8266上发送1472字节数据 - sub module: UDP - summary: (special case)STA mode, recvfrom basic test with STAM2(IPv6) - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0104_01_02 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND_v6 - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDPv6 -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 1 - - - R SSC1 SL +1 - - - SOC SOC1 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - - - SOC SOC1 SENDTO 1473 - - - P SSC1 C +RECVFROM - - P SOC_COM C OK - - - SOC SOC2 BIND_v6 - - - R SOC_COM L OK - - - SOC SOC2 SENDTO 1472 - - - R SSC1 RE "RECVFROM:%%s,1472,%%s,%%u"%%(,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - 6.OK - 7.OK - initial condition: STAAP2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.PC往8266上发送1字节数据 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1473字节数据 - 6.PC上SOC2 UDP传输,bing - 7.PC往8266上发送1472字节数据 - sub module: UDP - summary: (special case)STA mode, recvfrom basic test with STAAP2(IPv6) - test environment: SSC_T1_9 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0105 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+ - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.关闭socket1 - sub module: UDP - summary: STA mode, close UDP sockets test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0106 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.ok - 2.ok - 3.ok - 4.ok - 5.ok - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上UDP传输,Bind socket2,本地ip target_udp_port2 - 3.target1上UDP传输,Bind socket3,本地ip target_udp_port3 - 4.target1上UDP传输,Bind socket4,本地ip target_udp_port4 - 5.target1上UDP传输,Bind socket5,本地ip target_udp_port5 - sub module: UDP - summary: STA mode, create max udp socket test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0107 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -I - - - P SSC1 RE "SOCINFO:%%s,1,.+,%%d"%%(,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上查询创建socket信息 - sub module: UDP - summary: STA mode, UDP get active socket info test - test environment: SSC_T1_6 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0108 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -i 0.0.0.0 -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 C BIND:ERROR - - - SSC SSC1 soc -B -t TCP -p - - - R SSC1 RE BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.ERROR - 4.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上UDP传输,Bind socket2,本地ip 0.0.0.0 target_udp_port2 - 3.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 4.target1上创建TCP socket3, target_udp_port1 - sub module: UDP - summary: AP mode, udp bind test. use different ip, port - test environment: SSC_T1_8 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0109 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC2 ip - - - R SSC2 A :STAIP:(.+)\r\n - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - R SOC1 UL 5 - - - SSC SSC1 soc -S -s -i -p -l 5 - - - R SSC2 RE "RECVFROM:%%s,5,%%s,%%u"%%(,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: T2O_1 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.PC上SOC2 UDP传输,bing - 3.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 4.target1上使用步骤3创建的socket1,往pc_ip,test_tcp_port1上发送10字节数据 - 5.target1上使用步骤3创建的socket1,往pc_ip2,test_tcp_port2上发送10字节数据 - sub module: UDP - summary: (special case)AP mode, sendto test. use different ip, port - test environment: SSC_T2_2 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0110 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 1 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1 - - - SSC SSC1 soc -S -s -i -p -l 1472 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1472 - - - SSC SSC1 soc -S -s -i -p -l 1473 - - - P SSC1 RE SEND:(\d+),OK - - P SOC_COM NC SOC_RECVFROM - - - SSC SSC1 soc -S -s -i -p -l 1472 -n 10 - -j 20 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 14720 - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK,没收到UDP包 - 6.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1字节数据 - 4.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472字节数据 - 5.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1473字节数据 - 6.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472*10字节数据 - sub module: UDP - summary: AP mode, sendto test with different length - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0110 - SDK: ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 1 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1 - - - SSC SSC1 soc -S -s -i -p -l 1472 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 1472 - - - SSC SSC1 soc -S -s -i -p -l 1473 - - - P SSC1 RE SEND:(\d+),OK - - P SOC_COM C SOC_RECVFROM - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1字节数据 - 4.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1472字节数据 - 5.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送1473字节数据 - sub module: UDP - summary: AP mode, sendto test with different length - test environment: SSC_T1_7 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0111 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC2 ip - - - R SSC2 A :STAIP:(.+)\r\n - - - SSC SSC2 soc -B -t UDP -p - - - R SSC2 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 5 - - - R SSC1 RE "RECVFROM:%%s,5,%%s,%%u"%%(,,) - - - SSC SSC2 soc -S -s -i -p -l 5 - - - R SSC1 RE "RECVFROM:%%s,5,%%s,%%u"%%(,,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK,没收到UDP包 - 6.OK - 7.OK - initial condition: T2O_1 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.PC往8266上发送1字节数据 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1473字节数据 - 6.PC上SOC2 UDP传输,bing - 7.PC往8266上发送1472字节数据 - sub module: UDP - summary: (special case)AP mode, recvfrom basic test - test environment: SSC_T2_2 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0112 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+ - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.关闭socket1 - sub module: UDP - summary: AP mode, close UDP sockets test - test environment: SSC_T1_8 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0113 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 RE BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.ok - 2.ok - 3.ok - 4.ok - 5.ok - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上UDP传输,Bind socket2,本地ip target_udp_port2 - 3.target1上UDP传输,Bind socket3,本地ip target_udp_port3 - 4.target1上UDP传输,Bind socket4,本地ip target_udp_port4 - 5.target1上UDP传输,Bind socket5,本地ip target_udp_port5 - sub module: UDP - summary: AP mode, create max udp socket test - test environment: SSC_T1_8 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0114 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -I - - - P SSC1 RE "SOCINFO:%%s,1,.+,%%d"%%(,) - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 2.target1上查询创建socket信息 - sub module: UDP - summary: AP mode, UDP get active socket info test - test environment: SSC_T1_8 - test point 1: basic function - test point 2: use UDP SAP (socket/espconn API) with different parameter - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p -w 0 - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.PC OK - 5.PC OK - 6.PC OK - 7.PC OK - 8.PC OK SOC_CLOSE=SOC1 - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上关闭工作线程 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1472字节数据 - 6.PC往8266上发送1472字节数据 - 7.PC往8266上发送1472字节数据 - 8.PC往8266上发送1472字节数据 - sub module: UDP - summary: STA mode, UDP recv buffer test - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: use UDP SAP (socket/espconn API) in different state - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_UDP_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - - - SOC SOC1 SENDTO 1472 - - - '' - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.PC OK - 5.PC OK - 6.PC OK - 7.PC OK - 8.PC OK SOC_CLOSE=SOC1 - initial condition: APM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上关闭工作线程 - 4.PC往8266上发送1472字节数据 - 5.PC往8266上发送1472字节数据 - 6.PC往8266上发送1472字节数据 - 7.PC往8266上发送1472字节数据 - 8.PC往8266上发送1472字节数据 - sub module: UDP - summary: AP mode, UDP recv buffer test - test environment: SSC_T1_7 - test point 1: abnormal/special use - test point 2: use UDP SAP (socket/espconn API) in different state - version: v2 (2016-10-19) -- CI ready: 'Yes' - ID: TCPIP_UDP_0301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 sta -D - - - P SSC1 C +QAP:OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:\d+,ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据 - 4.断开与AP 连接 - 5.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据 - sub module: UDP - summary: do UDP send after WIFI disconnected - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0302 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 2/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 sta -D - - - P SSC1 C +QAP:OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: | - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.PC上SOC1 UDP传输,bing - 2.target1上UDP传输,Bind socket1,本地ip target_udp_port1 - 3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据 - 4.断开与AP 连接 - 5.关闭建立的socket1连接 - sub module: UDP - summary: "close UDP socket after WIFI \ndisconnected" - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0303 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -i -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上SOC1 UDP传输,bing \n2.target1上UDP传输,Bind socket1,本地ip - target_udp_port1\n3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据\n4.修改8266的Mode为softAP - mode \n5.8266往PC上发送5字节数据" - sub module: UDP - summary: do UDP send after mode changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0304 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 op -S -o 2 - - - P SSC1 C +MODE:OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上SOC1 UDP传输,bing \n2.target1上UDP传输,Bind socket1,本地ip - target_udp_port1\n3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据\n4.修改8266的Mode为softAP - mode \n5.关闭建立的socket1连接" - sub module: UDP - summary: close UDP socket after mode changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0305 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - NIC DISABLED - - - R PC_COM C OK - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK - 4.OK - 5.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上SOC1 UDP传输,bing \n2.target1上UDP传输,Bind socket1,本地ip - target_udp_port1\n3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据\n4.PC上网卡禁止掉 - \n5.关闭建立的socket1连接" - sub module: UDP - summary: close UDP socket after PC NIC disabled - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0306 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.111.210 - - - P SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 1 - - - R SSC1 C +STAIP:192.168.111.210 - - - SSC SSC1 soc -S -s -i -p -l 1 - - - P SSC1 RE SEND:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上SOC1 UDP传输,bing \n2.target1上UDP传输,Bind socket1,本地ip - target_udp_port1\n3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据\n4.关闭8266的DHCP - 1\n5.设置sta ip \n6.查询sta ip 地址是否生效\n7.8266往PC上发送5字节数据" - sub module: UDP - summary: do UDP send after IP changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0307 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: 1/3 - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SOC SOC1 BIND - - - R SOC_COM L OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -l 5 - - - P SSC1 RE SEND:(\d+),OK - - P SOC1 UL 5 - - - SSC SSC1 dhcp -E -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 ip -S -o 1 -i 192.168.111.210 - - - P SSC1 C +IP:OK - - - SSC SSC1 ip -Q -o 1 - - - R SSC1 C +STAIP:192.168.111.210 - - - SSC SSC1 soc -T -s - - - R SSC1 RE CLOSE:\d+,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - 3.OK; PC TCP server accept 成功 - 4.OK - 5.OK - 6.OK - 7.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: "1.PC上SOC1 UDP传输,bing \n2.target1上UDP传输,Bind socket1,本地ip - target_udp_port1\n3.target1上使用步骤2创建的socket1,往pc_ip,test_tcp_port1上发送5字节数据\n4.关闭8266的DHCP - 1\n5.设置sta ip \n6.查询sta ip 地址是否生效\n7.关闭建立的socket1连接" - sub module: UDP - summary: close UDP socket after IP changed - test environment: SSC_T1_6 - test point 1: abnormal/special use - test point 2: UDP handling abnormal event - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0401 - SDK: |- - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 C +BIND:ERROR - execution time: 0.0 - expected result: |- - 1.OK - 2.ERROR - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.target1上创建UDP socket,bind test_udp_port1 - 2.target1上创建UDP socket,bind test_udp_port1 - sub module: UDP - summary: Test socket with so_reuseaddr option closed on UDP submodule - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_0402 - SDK: ESP32_IDF - Test App: SSC_OPTION - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.find esp-idf/components/lwip/include/lwip/lwip/opt.h file, make "#define SO_REUSE 1" instead of "#define SO_REUSE 0" - 2.switch to esp-idf/SSC, run "./gen_misc_ng.sh SSC_OPTION" and "make flash", then run the test case normally - 3.target1上创建UDP socket,bind test_udp_port1 - 4.target1上创建UDP socket,bind test_udp_port1 - sub module: UDP - summary: Test socket with so_reuseaddr option opened that build two udp sockets - by binding same port on ESP32 - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_0403 - SDK: 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: - - '' - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - execution time: 0.0 - expected result: |- - 1.OK - 2.OK - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1.find ESP8266_RTOS_SDK/include/lwip/lwip/opt.h file, make "#define SO_REUSE 1" instead of "#define SO_REUSE 0" - 2.switch to ESP8266_RTOS_SDK/third_party, run "./make_lib.sh lwip" risc,then continuely run "ll ../lib" - 3.switch to ESP8266_RTOS_SDK/SSC, run "./gen_misc_rtos.sh SSC", then run the test case normally - 4.target1上创建UDP socket,bind test_udp_port1 - 5.target1上创建UDP socket,bind test_udp_port1 - sub module: UDP - summary: Test socket with so_reuseaddr option opened that build two udp sockets - by binding same port on 8266_RTOS - test environment: SSC_T1_6 - test point 1: basic function - test point 2: socket test with different option - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPSendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - duplex = True - - - '' - - - conn_num = 5 - - - '' - - - send_delay = 20 - - - '' - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple udp - 3. do send/recv on all udp - sub module: UDP - summary: UDP send/recv stress test - test environment: SSC_T2_5 - test point 1: stress - test point 2: UDP stress test - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_UDP_5002 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPPacketLose - - - test_time = 5 - - - dummy - - - send_len = 1460 - - - '' - - - pc_send = True - - - '' - - - target_send = False - - - '' - - - delay = 10 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create UDP and recv data for several seconds - sub module: UDP - summary: UDP loss rate on DUT Rx - test environment: SSC_T1_6 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5003 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPPacketLose - - - test_time = 5 - - - dummy - - - send_len = 1460 - - - '' - - - pc_send = False - - - '' - - - target_send = True - - - '' - - - delay = 10 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create UDP and recv data for several seconds - sub module: UDP - summary: UDP loss rate on DUT Tx - test environment: SSC_T1_6 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5004 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPBroadcast - - - test_time = 30 - - - dummy - - - send_len = 20 - - - '' - - - pc_send = True - - - '' - - - target_send = False - - - '' - - - delay = 10 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - initial condition: STAM2 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create UDP and recv data for several seconds - sub module: UDP - summary: UDP broadcase loss rate on DUT Rx - test environment: SSC_T1_6 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5005 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPMultiSTASendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - server_echo = True - - - '' - - - sta_number = 5 - - - '' - - - send_delay = 500 - - - '' - execution time: 5.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. 5 sta connect to softap - 2. create udp socket on all sta - 3. all sta do udp send/recv - sub module: UDP - summary: 1 SoftAP 5 STA, create UDP server on one STA, create UDP client on other - STA, do UDP send/recv - test environment: SSC_T6_1 - test point 1: stress - test point 2: UDP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5006 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPSTAMultiSocketSendRecv - - - send_len = 1460 - - - dummy - - - test_time = 300 - - - '' - - - server_echo = True - - - '' - - - sta_number = 2 - - - '' - - - conn_number = 6 - - - '' - - - send_delay = 500 - - - '' - execution time: 5.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: None - level: Integration - module: TCPIP - steps: |- - 1. 2 sta connect to softap - 2. create multi udp socket on all sta - 3. all sta do udp send/recv - sub module: UDP - summary: 1 SoftAP 2 STA, create multi UDP socket on STA, do UDP send/recv - test environment: SSC_T3_1 - test point 1: stress - test point 2: UDP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5007 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/SoftAPSTAUDPLose - - - test_time = 60 - - - dummy - - - send_len = 1460 - - - '' - - - softap_send = False - - - '' - - - sta_send = True - - - '' - - - delay = 10 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1.sta connect to softAP - 2.sta softAP bind UPD socket - 3.sta send UDP to softAP, softAP calculate the packet lose - sub module: UDP - summary: STA connect to softAP, STA send UDP to softAP, calculate the UDP lose on - softAP - test environment: SSC_T2_5 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5008 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/SoftAPSTAUDPLose - - - test_time = 60 - - - dummy - - - send_len = 1460 - - - '' - - - softap_send = True - - - '' - - - sta_send = False - - - '' - - - delay = 10 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1.sta connect to softAP - 2.sta softAP bind UPD socket - 3.softAP send UDP to STA, STA calculate the packet lose - sub module: UDP - summary: STA connect to softAP, softAP send UDP to STA, calculate the UDP lose on - STA - test environment: SSC_T2_5 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Performance - cmd set: - - UDPStress/UDPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. config attenuator (0-59) - 2. scan AP to get AP RSSI - 3. create UDP and send data for several seconds - Loop step 1 - 3 - sub module: UDP - summary: UDP throughput Tx in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: UDP throughput - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Performance - cmd set: - - UDPStress/UDPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. config attenuator (0-59) - 2. scan AP to get AP RSSI - 3. create UDP and recv data for several seconds - Loop step 1 - 3 - sub module: UDP - summary: UDP throughput Rx in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: UDP throughput - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/EthUDPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 30 - - - '' - - - test_count = 5 - - - '' - execution time: 0.5 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. DUT band socket and send packet to PC for several secends - Loop for step 1-2 - sub module: UDP - summary: UDP throughput Tx for Ethernet - test environment: ETH_T1_1 - test point 1: stress - test point 2: UDP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/EthUDPThroughput - - - send_len = 1460 - - - dummy - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 30 - - - '' - - - test_count = 5 - - - '' - execution time: 0.5 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. DUT band socket and PC send packet to DUT for several secends - Loop for step 1-2 - sub module: UDP - summary: UDP throughput Rx for Ethernet - test environment: ETH_T1_1 - test point 1: stress - test point 2: UDP stress test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_5301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/EthUDPPacketLose - - - test_time = 30 - - - dummy - - - send_len = 1460 - - - '' - - - pc_send = True - - - '' - - - target_send = False - - - '' - - - delay = 10 - - - '' - execution time: 0.5 - expected result: |- - 1. succeed - 2. succeed - initial condition: T1_ETH - level: Integration - module: TCPIP - steps: |- - 1. DUT open eth and get ip - 2. DUT band socket,PC send packet to DUT for several secends - 3. DUT calculate the packet lose rate - sub module: UDP - summary: UDP loss rate on DUT Rx for Eth - test environment: ETH_T1_1 - test point 1: Performance test - test point 2: UDP stress test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5401 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPSoftAPSTAThroughput - - - send_len = 1460 - - - dummy - - - sta_rx_enable = False - - - '' - - - sta_tx_enable = True - - - '' - - - measure_period = 15 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. STA connect softAP - 2. bind UDP socket - 3. send UDP packet - 4. calculate the troughput - sub module: UDP - summary: STA UDP throughput Tx while connected with softAP - test environment: SSC_T2_ShieldBox2 - test point 1: Performance test - test point 2: UDP throughput - version: v1 (2016-10-18) -- CI ready: 'No' - ID: TCPIP_UDP_5402 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPSoftAPSTAThroughput - - - send_len = 1460 - - - dummy - - - sta_rx_enable = True - - - '' - - - sta_tx_enable = False - - - '' - - - measure_period = 15 - - - '' - execution time: 1.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - 4. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. STA connect softAP - 2. bind UDP socket - 3. send UDP packet - 4. calculate the troughput - sub module: UDP - summary: STA UDP throughput Rx while connected with softAP - test environment: SSC_T2_ShieldBox2 - test point 1: Performance test - test point 2: UDP throughput - version: v1 (2016-10-18) -- CI ready: 'Yes' - ID: TCPIP_UDP_5501 - SDK: 'ESP32_IDF' - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPSendRecvIPv6 - - - send_len = 1460 - - [dummy] - - - test_time = 300 - - [''] - - - duplex = True - - [''] - - - conn_num = 5 - - [''] - - - send_delay = 20 - - [''] - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T2_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple udp - 3. do send/recv on all udp - sub module: UDP - summary: UDP send/recv stress test with UDPSendRecvIPv6(IPv6) - test environment: SSC_T2_5 - test point 1: stress - test point 2: UDP stress test(IPv6) - version: v2 (2016-11-15) -- CI ready: 'Yes' - ID: TCPIP_UDP_5502 - SDK: 'ESP32_IDF' - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - UDPStress/UDPAPSTASendRecvIPv6 - - - send_len = 1460 - - [dummy] - - - test_time = 300 - - [''] - - - duplex = True - - [''] - - - conn_num = 5 - - [''] - - - send_delay = 20 - - [''] - execution time: 12.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: T3_1 - level: Integration - module: TCPIP - steps: |- - 1. sta connect to softap - 2. create multiple udp - 3. do send/recv on all udp - sub module: UDP - summary: UDP send/recv stress test with UDPAPSTASendRecvIPv6(IPv6) - test environment: SSC_T3_1 - test point 1: stress - test point 2: UDP stress test(IPv6) - version: v2 (2016-11-15) -- CI ready: 'No' - ID: TCPIP_UDP_9901 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - UDPStress/UDPThroughputCompatibility - - - send_len = 1460 - - - dummy - - - test_times = 10 - - - '' - - - tx_enable = True - - - '' - - - rx_enable = False - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create TCP connection and send data for several seconds - 3. calculate the throughput - Loop step 1 - 3 - sub module: UDP - summary: UDP throughput Tx Compatibility test in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: UDP throughput Compatibility test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: TCPIP_UDP_9902 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - UDPStress/UDPThroughputCompatibility - - - send_len = 1460 - - - dummy - - - test_times = 10 - - - '' - - - tx_enable = False - - - '' - - - rx_enable = True - - - '' - - - measure_period = 30 - - - '' - execution time: 2.0 - expected result: |- - 1. succeed - 2. succeed - 3. succeed - initial condition: STAM1 - level: Integration - module: TCPIP - steps: |- - 1. scan AP to get AP RSSI - 2. create TCP connection and send data for several seconds - 3. calculate the throughput - Loop step 1 - 3 - sub module: UDP - summary: UDP throughput Rx Compatibility test in shield box - test environment: SSC_T1_ShieldBox - test point 1: performance - test point 2: UDP throughput Compatibility test - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_ADDR.yml b/components/idf_test/integration_test/TC_IT_WIFI_ADDR.yml deleted file mode 100644 index 98aeb1c26..000000000 --- a/components/idf_test/integration_test/TC_IT_WIFI_ADDR.yml +++ /dev/null @@ -1,99 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: WIFI_ADDR_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 1 -m 44:55:66:77:88:99 - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 mac -S -o 2 -m 22:33:44:55:66:77 - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 mac -Q -o 3 - - - R SSC1 C +STAMAC:44:55:66:77:88:99 C +APMAC:22:33:44:55:66:77 - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.ok - 3.ok - 4.ok - 5.ok - 6.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: "1.target1 设置mode 为sta+softAP mode\n2.target1 设置sta mode 下的mac \n3.target1 - 设置softAP mode 下的mac\n4.target1 查询softAP+sta 下的mac\n5.target1 设置sta mode 下的mac - 为target1_mac\n6.target1 设置softAP mode 下的mac 为target1_ap_mac\n" - sub module: MAC Address - summary: set mac, query mac - test environment: SSC_T2_5 - test point 1: basic function - test point 2: mac address function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_ADDR_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 mac -S -o 2 -m 44:55:66:77:88:99 - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 ap -S -s -p -t - - - '' - - - SSC SSC2 sta -S -b 44:55:66:77:88:99 - - - R SSC2 RE \+SCAN:.+,44:55:66:77:88:99, - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC2 mac -Q -o 1 - - - R SSC2 A :\+STAMAC:(.+)\r\n - - - SSC SSC2 mac -S -o 1 -m 22:33:44:55:66:77 - - - R SSC2 C +MAC:STA,OK - - - SSC SSC2 sta -C -s -p - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC1 ap -L - - - R SSC1 C +LSTA:22:33:44:55:66:77 - - - SSC SSC2 mac -S -o 1 -m - - - R SSC2 C +MAC:STA,OK - execution time: 0.0 - expected result: |- - 1.OK - 2.ok - 3.ok - 4.ok - 5.ok - 6.ok - 7.ok - 8.ok - 9.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: "1.target1 设置sta mode下的mac 44:55:66:77:88:99\n2.target1下设置ssid 和pwd 加密方式\n3.target2 - 查询mac为44:55:66:77:88:99的ssid\n4.target1 设置sta mode下的mac target_ap_mac\n5.target2 - 查询sta mode 下的mac 为target2_mac_tmp\n6.target2 设置sta mode 下的mac 为22:33:44:55:66:77\n7.target2 - jap target1\n8.target1 查询连接到的sta \n9.target2 设置sta mode 下的mac 为 target2_mac\n" - sub module: MAC Address - summary: set mac and do scan/JAP/SAP - test environment: SSC_T2_5 - test point 1: basic function - test point 2: mac address function test - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_AMSDU.yml b/components/idf_test/integration_test/TC_IT_WIFI_AMSDU.yml deleted file mode 100644 index b411380be..000000000 --- a/components/idf_test/integration_test/TC_IT_WIFI_AMSDU.yml +++ /dev/null @@ -1,29 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: WIFI_AMSDU_5001 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - TCPStress/TCPAMSDUsendrecv - - - delay_config = [0, 0.01, 0.1, 0.5, 1] - - - dummy - - - send_count = 1000 - - - '' - - - test_time = 300 - - - '' - execution time: 12.0 - expected result: 1. do not disconnect - initial condition: STAM2 - level: Integration - module: WIFI MAC - steps: |- - 1. PC and SSC1 connected to 天猫魔盒,do TCP pkts send/recv for a long time. - 2.Loop executing step 1 - sub module: A-MSDU - summary: test AMSDU send/rev - test environment: SSC_T1_AMSDU - test point 1: function + stress - test point 2: AMSDU send recv - version: v2 (2016-11-15) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml b/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml deleted file mode 100644 index 8a9c23683..000000000 --- a/components/idf_test/integration_test/TC_IT_WIFI_CONN.yml +++ /dev/null @@ -1,2074 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: WIFI_CONN_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -t 0 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -p -t 2 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -p -t 3 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -p -t 4 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -p -t 1 - - - R SSC1 C +SAP:ERROR - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 sta -S - - - R SSC2 RE "\+SCAN:%%s,.+,0,\d+"%%() C +SCANDONE - - - SSC SSC1 ap -S -s -p -t 5 - - - R SSC1 C +SAP:ERROR - - - SSC SSC2 sta -S - - - R SSC2 RE "\+SCAN:%%s,.+,0,\d+"%%() C +SCANDONE - execution time: 0.0 - expected result: "1.target1 set AP,open, \n2.target 2 jap succeed\n3.target1 set - AP,wpa_psk \n4.target 2 jap succeed\n5.target1 set AP, wpa2_psk \n6.target 2 jap - succeed\n7.target1 set AP,wap_wpa2_psk\n8.target 2 jap succeed\n9.target1 set - AP,加密方式为t 1\n10.target 2 上查询到target_ssid\n11.target1 set AP,加密方式为t 5\n12.target - 2 上查询到target_ssid" - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: "1.target1下设置ssid 和pwd,加密方式 open\n2.target2 jap target1\n3.target1下设置ssid - 和pwd,加密方式 wpa_psk \n4.target2 jap target1\n5.target1下设置ssid 和pwd,加密方式 wpa2_psk - \n6.target 2 jap target1\n7.target1下设置ssid 和pwd,加密方式 wap_wpa2_psk\n8.target2 jap - target1\n9.target1下设置ssid 和pwd,加密方式 wep \n10.target2上查询target_ssid\n11.target1下设置ssid - 和pwd,加密方式 t 5 错误的加密方式\n12.target2上查询 target_ssid" - sub module: WIFI Connect - summary: station SAP+JAP test, different encryption - test environment: SSC_T2_5 - test point 1: basic function - test point 2: SAP/JAP with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -t 0 -n 1 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -t 0 -n 13 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 ap -S -s -n 15 - - - R SSC1 C +SAP:ERROR - - - SSC SSC2 sta -C -s - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC2 sta -S - - - R SSC2 RE "\+SCAN:%%s,.+,\d+,1"%%() - execution time: 0.0 - expected result: |- - 1. target1 set AP,set channel 1 - 2.target 2 jap succeed - 3.target1 set AP,set channel 10 - 4.target 2 jap succeed - 5.target1 set AP,set channel 15 - 6.target 2 上查询到target_ssid - initial condition: T2O_1 - level: Integration - module: WIFI MAC - steps: |- - 1. target1下设置ssid 和pwd 加密方式,set channel 1 - 2.target2 jap target 1 - 3.target1下设置ssid 和pwd 加密方式,set channel 10 - 4.target2 jap target 1 - 5.target1下设置ssid 和pwd 加密方式,set channel 15 - 6.target 2 上查询target_ssid - sub module: WIFI Connect - summary: station SAP+JAP test, different channel - test environment: SSC_T2_5 - test point 1: basic function - test point 2: SAP/JAP with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t -h - 0 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S -h 0 - - - R SSC2 P - - R SSC2 C +SCANDONE - - - SSC SSC1 ap -S -s -p -t -h - 1 - - - R SSC1 C +SAP:OK - - - DELAY 3 - - - '' - - - SSC SSC2 sta -S -h 0 - - - R SSC2 C +SCANDONE - - - DELAY 3 - - - '' - - - SSC SSC2 sta -S -h 0 - - - R SSC2 NP C +SCANDONE - execution time: 0.0 - expected result: |- - 1.target1 set AP,set ssid broad cast - 2.target 2上scan target_ap_mac - 3.target1 set AP,set ssid hidden, - 4.target 2上不能scan target_ap_mac - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1. target1下设置ssid 和pwd 加密方式,set ssid broad cast - 2.target 2上scan target_ap_mac - 3. target1下设置ssid 和pwd 加密方式,set ssid hidden, - 4.target 2上scan target_ap_mac - sub module: WIFI Connect - summary: station SAP+JAP test, ssid hidden - test environment: SSC_T2_5 - test point 1: basic function - test point 2: SAP/JAP with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '1/2' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t -m - 1 - - - R SSC1 C +SAP:OK - - - WIFI DISCONN - - - R PC_COM C +WIFIDISCONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - WIFI CONN - - - - R PC_COM C +WIFICONN:ERROR - execution time: 0.0 - expected result: |- - 1. target1 set AP,set max allowed sta as 1 - 2. use PC disconnect, - 3.target 2 jap succeed - 4.PC WIFI can not CONN - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式,set max allowed sta as 1 - 2.use PC disconnect target1 - 3.target 2 jap target1 - 4.PC WIFI CONNECT target1 - sub module: WIFI Connect - summary: station SAP test, max allowed sta - test environment: SSC_T2_2 - test point 1: basic function - test point 2: SAP/JAP with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 sta -Q - - - R SSC1 RE "\+JAP:CONNECTED,%%s,%%s"%%(,) - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:OK - - - SSC SSC1 sta -Q - - - R SSC1 C +JAP:DISCONNECTED - execution time: 0.0 - expected result: |- - 1.target1 jion AP 成功 - 2.查询JAP的状态 - 3.target1 断开AP - 4.查询target1 JAP 是DISCONN - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1 jion AP 成功 - 2.查询JAP的状态 - 3.target1 断开AP - 4.查询target1 JAP 是DISCONN - sub module: WIFI Connect - summary: JAP query test - test environment: SSC_T1_5 - test point 1: basic function - test point 2: query JAP status - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t -h - 0 -m 8 - - - R SSC1 C +SAP:OK - - - SSC SSC1 ap -Q - - - R SSC1 RE "\+APCONFIG:%%s,%%s,\d+,3,0,8,\d+"%%(,) - execution time: 0.0 - expected result: | - 1. target1 set AP - 2.target 1上查询到跟设置AP时一致 - initial condition: APM1 - level: Integration - module: WIFI MAC - steps: | - 1. target1 set AP - 2.target 1上查询到跟设置AP时一致 - sub module: WIFI Connect - summary: AP config query test - test environment: SSC_T1_4 - test point 1: basic function - test point 2: query AP config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0302 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -S - - - R SSC1 C +SCAN_DONE:OK - - - SSC SSC1 sta -C -s -p - - - P SSC1 C +JAP:CONNECTED - - P SSC1 C +SCANDONE - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:OK - - - SSC SSC1 sta -C -s -p - - - '' - - - SSC SSC1 sta -S - - - P SSC1 C +JAP:CONNECTED - - P SSC1 C +SCANDONE - execution time: 0.0 - expected result: | - 2. scan succeed, JAP succeed - 5. JAP succeed, scan succeed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: | - 1. target 1 STA join AP - 2. target 1 STA scan before JAP succeed - 3. target 1 quite AP - 4. target 1 scan - 5. target 1 JAP before scan succeed - sub module: WIFI Connect - summary: JAP during scan - test environment: SSC_T1_5 - test point 1: interaction - test point 2: Conn interact with other WiFi operation - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0302 - SDK: |- - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -S - - - R SSC1 C +SCAN_DONE:OK - - - SSC SSC1 sta -C -s -p - - - P SSC1 C +JAP:CONNECTED - - P SSC1 C +SCANFAIL - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:OK - - - SSC SSC1 sta -C -s -p - - - '' - - - SSC SSC1 sta -S - - - P SSC1 C +JAP:CONNECTED - - P SSC1 C +SCAN:ERROR - execution time: 0.0 - expected result: | - 2. scan failed, JAP succeed - 5. JAP succeed, scan failed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: | - 1. target 1 STA join AP - 2. target 1 STA scan before JAP succeed - 3. target 1 quite AP - 4. target 1 scan - 5. target 1 JAP before scan succeed - sub module: WIFI Connect - summary: JAP during scan - test environment: SSC_T1_5 - test point 1: interaction - test point 2: Conn interact with other WiFi operation - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0401 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -R -a 0 - - - R SSC1 C +AUTORECONN:OK - - - SSC SSC1 sta -R -a 2 - - - R SSC1 C +AUTORECONN:0 - - - SSC SSC1 reboot - - - '' - - - DELAY 15 - - - '' - - - SSC SSC1 sta -Q - - - R SSC1 C JAP:DISCONNECTED - - - SSC SSC1 sta -R -a 1 - - - R SSC1 C +AUTORECONN:OK - - - SSC SSC1 sta -R -a 2 - - - R SSC1 C +AUTORECONN:1 - - - SSC SSC1 reboot - - - R SSC1 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.设置autoreconn,关闭 - 2.查询当前autoreconn状态是否关闭 - 3.重启系统,等待15s - 4.查询target1 未自动重连AP - 5.设置autoreconn,开启 - 6.查询当前autoreconn状态是否开启 - 7.系统重启后target1 自动重连AP - initial condition: STAM2 - level: Integration - module: WIFI MAC - steps: |- - 1.设置autoreconn,关闭 - 2.查询当前autoreconn状态是否关闭 - 3.重启系统,等待15s - 4.查询target1 未自动重连AP - 5.设置autoreconn,开启 - 6.查询当前autoreconn状态是否开启 - 7.系统重启后target1 自动重连AP - sub module: WIFI Connect - summary: auto reconnect test - test environment: SSC_T1_5 - test point 1: basic function - test point 2: power on auto reconnect test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0501 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 sta -R -r 1 - - - R SSC2 C +RECONN:OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - DELAY 10 - - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - DELAY 15 - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -R -r 0 - - - R SSC2 C +RECONN:OK - - - SSC SSC2 sta -R -r 2 - - - R SSC2 C +RECONN:0 - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - DELAY 10 - - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - DELAY 15 - - - P PC_COM C +DELAYDONE - - P SSC2 NC +JAP:CONNECTED - - - SSC SSC2 sta -R -r 1 - - - R SSC2 C +RECONN:OK - execution time: 0.0 - expected result: |- - 1.设置reconn,开启(此功能不需要重启系统) - 2.target1 set AP - 3.target2 JAP target1 成功 - 4.target2 断开target1 连接 - 5.等待10s,target2 自动重连target1 - 6.成功 - 7.查询reconn状态,关闭 - 8.修改mode 成功 - 9.等待15s,target2 不会自动重连target1 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: "1.设置reconn,开启(此功能不需要重启系统)\n2.target1下设置ssid 和pwd 加密方式\n3.target2 JAP target1 - \n4.target1 修改mode 为sta mode\n5.等待10s,target1 修改mode 为softAP mode\n6.设置reconn,关闭\n7.查询reconn状态,关闭\n8.target1 - 修改mode 为sta mode\n9.等待15s,target1 修改mode 为softAP mode" - sub module: WIFI Connect - summary: reconnect policy test - test environment: SSC_T2_5 - test point 1: basic function - test point 2: reconnect policy test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0502 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -R -r 1 - - - R SSC2 C +RECONN:OK - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - DELAY 5 - - - R SSC2 C +JAP:DISCONNECTED - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - DELAY 10 - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - DELAY 10 - - - P PC_COM C +DELAYDONE - - P SSC2 NC +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.target1 set AP - 2.target2 jap target 1 - 3.设置reconn,开启(此功能不需要重启系统) - 4.target2 断开target1 连接 - 5.等待10s,target2 自动重连target1 - 6.target2 断开target1 连接 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target2 jap target 1 - 3.设置reconn,开启(此功能不需要重启系统) - 4.target2 断开target1 连接 - 5.等待10s,target2 自动重连target1 - 6.target2 断开target1 连接 - sub module: WIFI Connect - summary: will not do reconnect after manually disconnected - test environment: SSC_T2_5 - test point 1: abnormal/special use - test point 2: reconnect policy test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0503 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -R -r 0 - - - R SSC1 C OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - R SSC1 NC +JAP:DISCONNECTED,1 C +JAP:DISCONNECTED,3 - - - DELAY 5 - - - R SSC1 NC +JAP:DISCONNECTED - - P PC_COM C +DELAYDONE - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - R SSC1 NC +JAP:DISCONNECTED,1 C +JAP:DISCONNECTED,2 - - - DELAY 5 - - - R SSC1 NC +JAP:DISCONNECTED - - P PC_COM C +DELAYDONE - - - SSC SSC1 sta -R -r 1 - - - SSC SSC1 C OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. not reconnect when connect failed, status when recv disconnect event is correct - 3. not reconnect when connect failed, status when recv disconnect event is correct - 4. succeed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: | - 1. set sta reconnect policy as not reconnect - 2. sta connect to ap not exist - 3. sta connect to ap with wrong password - 4. reset sta reconnect policy as auto reconnect - sub module: WIFI Connect - summary: reconnect policy interact with failed STA connect/reconnect - test environment: SSC_T1_1 - test point 1: basic function - test point 2: reconnect policy test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0601 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - WIFI CONN - - - - R PC_COM C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 ap -L - - - 'R SSC1 C +LSTA:' - - 'R SSC1 C +LSTA:' - - R SSC1 C +LSTADONE - execution time: 0.0 - expected result: |- - 1.target1 set AP - 2.PC WIFI CONNECTED - 3.target2 jap target 1 - 4.查询到两个sta 连接到target1 上 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1. target1下设置ssid 和pwd 加密方式 - 2.PC WIFI CONNECTED target1 - 3.target2 jap target 1 - 4.查询到两个sta 连接到target1 上 - sub module: WIFI Connect - summary: list stations connected to soft ap test - test environment: SSC_T2_2 - test point 1: basic function - test point 2: list SoftAP connected station - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0701 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -D - - - R SSC1 C QAP - - - SSC SSC1 sta -Q - - - R SSC1 C +STA_STATUS:0 - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - - SSC SSC1 sta -Q - - - R SSC1 C +STA_STATUS:1 - - R SSC1 C +JAP:CONNECTED - - - SSC SSC1 sta -Q - - - R SSC1 C +STA_STATUS:5 - - - APC OFF - - - P PC_COM L OK - - P SSC1 C bcn_timout - - - SSC SSC1 sta -Q - - - R SSC1 C +STA_STATUS:4 - - - APC ON - - - P PC_COM L OK - execution time: 0.0 - expected result: |- - 1. idle state - 2. connecting state - 3. got IP state - 4. connect fail state - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. sta disconnected, query status - 2. sta connect to AP, query status - 3. got IP, query status - 4. AP power off, query status when beacon timeout - sub module: WIFI Connect - summary: check wifi status idle, connecting, got ip and connect fail - test environment: SSC_T1_APC - test point 1: basic function - test point 2: wifi connect status check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0702 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - R SSC1 C +JAP:DISCONNECTED,3 - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - R SSC1 C +JAP:DISCONNECTED,2 - execution time: 0.0 - expected result: |- - 1. get status AP not exist in disconnect event - 2. get status wrong password in disconnect event - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: | - 1. sta connect to ap not exist - 2. sta connect to ap with wrong password - sub module: WIFI Connect - summary: check wifi status wrong password, no ap found - test environment: SSC_T1_1 - test point 1: basic function - test point 2: wifi connect status check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0703 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p bacfd - - - R SSC1 C +JAP:DISCONNECTED,4,2 - execution time: 0.0 - expected result: 1. connect status connect fail in disconnect evnet - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: 1. connect WEP ap with error password (valid wep password) - sub module: WIFI Connect - summary: check wifi status connect fail - test environment: SSC_T1_WEP - test point 1: basic function - test point 2: wifi connect status check - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0801 - SDK: |- - 8266_NonOS - 8266_RTOS - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 0 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:CONNECTED - - - SSC SSC1 ap -S -s -p -t 2 - - - P SSC1 C +SAP:OK - - P SSC2 C +JAP:AUTHCHANGED,2,0 - - - SSC SSC1 ap -S -s -p -t 3 - - - P SSC1 C +SAP:OK - - P SSC2 C +JAP:AUTHCHANGED,3,2 - - - SSC SSC1 ap -S -s -p -t 4 - - - P SSC1 C +SAP:OK - - P SSC2 C +JAP:AUTHCHANGED,4,3 - - - SSC SSC1 ap -S -s -p -t 0 - - - P SSC1 C +SAP:OK - - P SSC2 C +JAP:AUTHCHANGED,0,4 - execution time: 0.0 - expected result: |- - 1. succeed - 2. succeed - 3. auth change event old mode 0 new mode 2 - 4. auth change event old mode 2 new mode 3 - 5. auth change event old mode 3 new mode 4 - 6. auth change event old mode 4 new mode 0 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1. set target1 softap auth mode 0 - 2. target2 connect to target1 - 3. set target1 softap auth mode 2, wait sta connected - 4. set target1 softap auth mode 3, wait sta connected - 5. set target1 softap auth mode 4, wait sta connected - 6. set target1 softap auth mode 0, wait sta connected - sub module: WIFI Connect - summary: test auth change event - test environment: SSC_T2_5 - test point 1: basic function - test point 2: wifi auth changed event test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0901 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: basic function - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:CONNECTED - - - SSC SSC1 sta -D - - - R SSC1 RE JAP:DISCONNECTED,\d+,8 - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE JAP:DISCONNECTED,\d+,201 - execution time: 0.0 - expected result: |- - 1. disconnect event reason REASON_ASSOC_LEAVE - 2. disconnect event reason REASON_NO_AP_FOUND - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. sta connect to AP, and disconnect - 2. connect to AP not exist - sub module: WIFI Connect - summary: test wifi disconnect reason REASON_ASSOC_LEAVE, REASON_NO_AP_FOUND - test environment: SSC_T1_1 - test point 1: basic function - test point 2: wifi disconnect reason test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0902 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - APC OFF - - - P PC_COM L OK - - R SSC1 RE JAP:DISCONNECTED,\d+,200 - - - APC ON - - - P PC_COM L OK - execution time: 0.0 - expected result: |- - 1. succeed - 2. disconnect event REASON_BEACON_TIMEOUT - initial condition: STAM2 - level: Integration - module: WIFI MAC - steps: |- - 1. connect to AP - 2. AP power off - sub module: WIFI Connect - summary: test wifi disconnect reason REASON_BEACON_TIMEOUT - test environment: SSC_T1_APC - test point 1: basic function - test point 2: wifi disconnect reason test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_0903 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '1/2' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p bacfd - - - R SSC1 RE JAP:DISCONNECTED,\d+,2 - execution time: 0.0 - expected result: 1. disconect event reason REASON_AUTH_EXPIRE - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: 1. connect WEP ap with error password (valid wep password) - sub module: WIFI Connect - summary: test wifi disconnect reason REASON_AUTH_EXPIRE - test environment: SSC_T1_WEP - test point 1: basic function - test point 2: wifi disconnect reason test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_0904 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '2/3' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 3 -m 1 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p 1234567890 - - - R SSC2 RE JAP:DISCONNECTED,\d+,15 - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - WIFI CONN - - - R PC_COM NC ERROR C +WIFICONN:OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 RE JAP:DISCONNECTED,\d+,5 - execution time: 0.0 - expected result: |- - 1. succeed - 2. disconnect event REASON_4WAY_HANDSHAKE_TIMEOUT - 3. succeed - 4. succeed - 5. disconnect event REASON_ASSOC_TOOMANY - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1. config target1 softap max sta allowed 1 - 2. target2 connect to target1 with wrong password - 3. target2 disconnect - 4. PC WIFI NIC connect to target1 - 5. target2 connect to target1 with correct password - sub module: WIFI Connect - summary: test wifi disconnect reason REASON_ASSOC_TOOMANY, REASON_4WAY_HANDSHAKE_TIMEOUT - test environment: SSC_T2_2 - test point 1: basic function - test point 2: wifi disconnect reason test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_1001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'No' - category: Function - cmd set: '' - execution time: 1.0 - expected result: 4.平均beacon delay时间小于10ms - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1.target设置成AP 模式 - 2.PC 端启动wireshark 抓包工具抓取target beacon包 - 3.停止抓包将抓取的beacon 包以txt格式导出 - 4.利用脚本计算beacon delay时间 - sub module: WIFI Connect - summary: beacon delay - test environment: SSC_T1_1 - test point 1: basic function - test point 2: beacon delay - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_1201 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:ERROR - execution time: 0 - expected result: | - 1. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. sta connect - sub module: WIFI Connect - summary: sta connect after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1202 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -R -a 1 - - - R SSC1 C +AUTORECONN:OK - - - SSC SSC1 sta -Q - - - R SSC1 C +JAP:DISCONNECTED - execution time: 0 - expected result: | - 1. OK - 2. DISCONNECTED - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. sta reconnect start - 2. query sta state - sub module: WIFI Connect - summary: sta reconnect start and connect fail after WiFi stop - test environment: SSC_T1_5 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1203 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:ERROR - execution time: 0 - expected result: | - 1. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. sta disconnect - sub module: WIFI Connect - summary: station disconnect after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1204 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -Q - - - R SSC1 C +JAP:DISCONNECTED - execution time: 0 - expected result: | - 1. DISCONNECTED - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. query sta state - sub module: WIFI Connect - summary: query sta state after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1205 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -S -s - - - R SSC1 C +SCAN:ERROR,1 - execution time: 0 - expected result: | - 1. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. sta scan ssid and pwd - sub module: WIFI Connect - summary: sta scan after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1206 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:ERROR - execution time: 0 - expected result: | - 1. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. ap connect ssid and pwd - sub module: WIFI Connect - summary: ap connect after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1207 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -D - - - R SSC1 C +QAP:ERROR - execution time: 0 - expected result: | - 1. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. ap disconnect - sub module: WIFI Connect - summary: ap disconnect after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1208 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -L - - - R SSC1 C +LSTADONE - execution time: 0 - expected result: | - 1. +LSTADONE - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. ap list station - sub module: WIFI Connect - summary: ap list station after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1209 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -Q - - - 'R SSC1 C +APCONFIG:' - execution time: 0 - expected result: | - 1. +APCONFIG:ssid and pwd - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. query ap config - sub module: WIFI Connect - summary: query ap config after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1210 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p - - - R SSC1 C +SAP:OK - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p - - - R SSC1 C +SAP:ERROR - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set ap mode - 2. ap set ssid and pwd - 3. set station mode - 4. ap set ssid and pwd - sub module: WIFI Connect - summary: ap set ssid and pwd after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1211 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 mac -Q - - - 'R SSC1 C MAC:' - execution time: 0 - expected result: | - 1. MAC: - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. query mac - sub module: WIFI Connect - summary: query mac after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1212 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,OK - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,ERROR - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set ap mode - 2. set ap mac - 3. set station mac - sub module: WIFI Connect - summary: enable AP mode after WiFi stop and set AP mac - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1213 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 mac -Q -o 1 - - - 'R SSC1 C +STAMAC:' - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. get station mac - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set station mode - 2. set station mac - 3. query station mac - sub module: WIFI Connect - summary: enable STA mode after WiFi stop and set STA mac - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1214 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 mac -S -o 1 -m - - - R SSC1 C +MAC:STA,OK - - - SSC SSC1 mac -S -o 2 -m - - - R SSC1 C +MAC:AP,ERROR - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set station mode - 2. set station mac - 3. set ap mac - sub module: WIFI Connect - summary: enable STA mode after WiFi stop and set AP mac - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1215 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 channel -S -c 13 - - - R SSC1 C +CHANNEL:ERROR - execution time: 0 - expected result: | - 1. +CHANNEL:ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set channel - sub module: WIFI Connect - summary: set channel after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1216 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 channel -S -c 13 - - - R SSC1 C +CHANNEL:ERROR - - - SSC SSC1 channel -G - - - R SSC1 C +CHANNEL - execution time: 0 - expected result: | - 1. +CHANNEL:ERROR - 2. +CHANNEL - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set channel - 2. query channel - sub module: WIFI Connect - summary: query channel after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1217 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -Q - - - R SSC1 C +MODE:OK - execution time: 0 - expected result: | - 1. +CURMODE:2 - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. query current mode - sub module: WIFI Connect - summary: be AP mode after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1218 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - execution time: 0 - expected result: | - 1. OK - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set STA mode - sub module: WIFI Connect - summary: set STA mode after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1219 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 2 - - - R SSC1 C +MODE:OK - execution time: 0 - expected result: | - 1. OK - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. set AP mode - sub module: WIFI Connect - summary: set ap mode after WiFi stop - test environment: SSC_T1_4 - test point 1: basic function - test point 2: use WiFi API after WiFi stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1301 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:ERROR - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. ERROR - 4. OK - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. wifi init - 2. wifi start - 3. wifi deinit - 4. wifi stop - sub module: WIFI Connect - summary: incorrect deinit stop flow - test environment: SSC_T1_4 - test point 1: basic function - test point 2: WiFi deinit and stop - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1302 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:ERROR - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:ERROR - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. ERROR - 4. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. wifi init - 2. wifi deinit - 3. wifi start - 4. wifi stop - sub module: WIFI Connect - summary: incorrect deinit start flow - test environment: SSC_T1_4 - test point 1: basic function - test point 2: WiFi deinit and start - version: v1 (2016-12-31) -- CI ready: 'Yes' - ID: WIFI_CONN_1303 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a init - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:ERROR - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:ERROR - - - SSC SSC1 op -W -a stop - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a deinit - - - R SSC1 C +MODE:OK - - - SSC SSC1 op -W -a start - - - R SSC1 C +MODE:ERROR - execution time: 0 - expected result: | - 1. OK - 2. OK - 3. OK - 4. ERROR - 5. ERROR - 6. OK - 7. OK - 8. ERROR - initial condition: WIFISTO - level: Integration - module: WIFI MAC - steps: | - 1. wifi init - 2. wifi init - 3. wifi start - 4. wifi deinit - 5. wifi deinit - 6. wifi stop - 7. wifi deinit - 8. wifi start - sub module: WIFI Connect - summary: incorrect init start flow - test environment: SSC_T1_4 - test point 1: basic function - test point 2: WiFi deinit and stop - version: v1 (2016-12-31) -- CI ready: 'No' - ID: WIFI_CONN_5001 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiJAP - - - target_ap_num = 10 - - - '["TENDA123456", 11, "1234567890", 10, 10, 3, 2]' - - - test_count = 500 - - - '["not_pig_head", 12, "", 0, 10, 0, 3]' - - - join_test_method = ["Normal", "OFF_ON"] - - - '["MW300R_T", 8, "12345", 5, 9, 0, 5]' - - - join_delay = [[0, 4], [0, 5]] - - - '["AC750", 5, "1234567890", 10, 1, 0, 8]' - - - step_config = [0x0B, 0x07, 0x02] - - - '["AUF", 3, "1234567890", 10, 9, 0, 1]' - - - reconnect_test_method = ["OFF_ON"] - - - '' - - - reconnect_delay = [[0, 10], [2, 10]] - - - '' - execution time: 5.0 - expected result: |- - 1. SAP succeed - 2. JAP succeed - 3. reconnect succeed - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. random generate test parameter (ssid, password, auth type, ssid hidden/broadcast), SAP and JAP - 2. power off AP during JAP, power on AP - 3. power off AP after JAP succeed, power on AP - Loop step 1-3 - sub module: WIFI Connect - summary: 使用各种可能的 ssid+password+auth type 组合进行SAP和JAP;JAP过程中AP随机断电或更改设置;AP随机断电后重连 - test environment: SSC_T2_JAP - test point 1: function + performance + stress - test point 2: JAP stress test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_5101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/SoftAPNSTA - - - sta_num = 4 - - - dummy - - - max_sta = 4 - - - '' - - - test_time = 300 - - - '' - - - delay1 = [0, 1] - - - '' - - - delay2 = [0, 1] - - - '' - - - change_mac = True - - - '' - - - channel = 1 - - - '' - execution time: 5.0 - expected result: |- - 1. succeed - 2. JAP succeed - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. 1 target set to softap mode and rest set to sta mode - 2. all sta random join and disconnect from softap - Loop step 2 - sub module: WIFI Connect - summary: max sta connect to SotfAP and disconnect - test environment: SSC_T5_1 - test point 1: stress - test point 2: SoftAP WIFI connect/disconnect stress test - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_CONN_5102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiJAPAtt - - - test_count = 5 - - - dummy - execution time: 5.0 - expected result: |- - 2. Scan succeed with RSSI > -90 - 3. Join succeed with RSSI > -90 - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. config attenuator (0-59) - 2. scan AP to get AP RSSI - 3. try to join AP - Loop step 1 - 3 - sub module: WIFI Connect - summary: connect AP with rssi from -50 to -100 - test environment: SSC_T1_ShieldBox - test point 1: stress - test point 2: JAP with different RSSI - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_5103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiJAPAtt - - - test_count = 5 - - - dummy - - - att_test_list = range(30, 50) - - - '' - execution time: 5.0 - expected result: |- - 2. Scan succeed with RSSI > -90 - 3. Join succeed with RSSI > -90 - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. config attenuator (30-59) - 2. scan AP to get AP RSSI - 3. try to join AP - Loop step 1 - 3 - sub module: WIFI Connect - summary: connect AP with rssi from -80 to -100 - test environment: SSC_T1_ShieldBox - test point 1: stress - test point 2: JAP with different RSSI - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_5104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiJAPScanSpecified - - - target_ap_num = 6 - - [] - - - test_count = 50 - - [] - - - test_times = 2 - - [] - execution time: 5.0 - expected result: |- - 1. JAP succeed - 2. reconnect succeed and connection time less than 1.5s - 3. connect succeed, and connection time less than 1.5s - initial condition: None - level: Integration - module: WIFI MAC - steps: 1. SSC target connect the first five AP, first 5 AP which will be stored - to connected AP cached of DUT. 2. SSC target reconnect ap. 3. SSC target connect - the last AP, last AP will not be stored in AP cache and DUT do not know the channel - of this AP. Loop step 1-3 - sub module: WIFI Connect - summary: 1 STA 6 AP, count connect AP requires time by scanning the specified channel. - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + performance + stress - test point 2: JAP stress test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_CONN_5105 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiJAPCSA - - - test_count = 2 - - - '' - - - test_times = 10 - - - '' - execution time: 5.0 - expected result: 3. connect success 4. PC stay connected - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. 1 SSC target connect PC by Uart. - 2. SSC target set as softap+sta mode. - 3. PC wireless NIC connect softap. - 4. sta connect AP ,softap and AP should in different channel - sub module: WIFI Connect - summary: channel switch announcements verify - test environment: SSC_T1_1 - test point 1: function + stress - test point 2: channel switch announcements - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_CONN_5106 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - WiFiStress/WifiConnStable - - - check_count = 1440 - - - dummy - - - check_time = 60 - - - '' - - - sleep_mode = "NoneSleep" - - - '' - execution time: 24.0 - expected result: 3. no disconnected - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. set SSC as sta mode and disable sleep function - 2. 1 SSC connect with AP - 3. check connection status within 24 hours - sub module: WIFI Connect - summary: WiFi STA connection stable test - test environment: SSC_T1_1 - test point 1: stress + function - test point 2: connection keep alive stress test - version: v2 (2016-10-23) -- CI ready: 'No' - ID: WIFI_CONN_5107 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stable - cmd set: - - WiFiStress/WifiSendpktSwitchChan - - - test_count = 1000 - - - dummy - - - test_time = 20 - - - '' - - - send_len = 1000 - - - '' - - - send_count = 1000 - - - '' - - - send_delay = 20 - - - '' - execution time: 24.0 - expected result: 4. connect suc - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. set SSC as sta mode send UDP broadcast pkt - 2. switch SSC send pkt channel - 3. SSC stop send pkt - 4. SSC connect ap - sub module: WIFI Connect - summary: Switch channel when sending WiFi packets - test environment: SSC_T1_1 - test point 1: stress - test point 2: connect ap - version: v2 (2016-10-23) -- CI ready: 'No' - ID: WIFI_CONN_5201 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - execution time: TBD - expected result: |- - 1. 配置成功,如有需要就重启路由 - 2. target 连接AP成功 - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. 将每个需要测试的AP手动配置为该AP所有可能的模式(bgn),带宽,加密模式的组合 - 2. 控制 target 连接 AP - sub module: WIFI Connect - summary: basic join ap - test environment: SSC_T1_IOT1 - test point 1: interoperability - test point 2: JAP inter operablity test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_5202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: IOT - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - DELAY 60 - - - P PC_COM C +DELAYDONE - - P SSC1 NC +JAP:DISCONNECTED - execution time: TBD - expected result: |- - 1. 配置成功,如有需要就重启路由 - 2. target 连接AP成功 - 3. target 没有从AP断开 - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. 将每个需要测试的AP手动配置为该AP所有可能的模式(bgn),带宽,加密模式的组合 - 2. 控制 target 连接 AP - 3. 等待60s - sub module: WIFI Connect - summary: join ap not disconnected in 60 seconds - test environment: SSC_T1_IOT1 - test point 1: interoperability - test point 2: JAP inter operablity test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_5203 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'No' - category: IOT - cmd set: '' - execution time: TBD - expected result: |- - 1. 配置成功,如有需要就重启路由 - 2. 开始连接AP - 3. target 最终连接AP成功 - 4. target 从 AP 断开 - 5. target 重连AP成功 - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. 将每个需要测试的AP手动配置为该AP所有可能的模式(bgn),带宽,加密模式的组合 - 2. 控制 target 连接 AP - 3. 快速在连接AP过程中对AP断电上电 - 4. AP断电后再上电 - 5. 等待 target 重连 AP - sub module: WIFI Connect - summary: power off and power on AP during JAP, reconnect after AP power off and - power on - test environment: SSC_T1_IOT1 - test point 1: interoperability - test point 2: JAP inter operablity test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_CONN_5301 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'No' - category: IOT - cmd set: '' - execution time: TBD - expected result: 3. get test result form smart phone APK - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. setup a few SoftAP with different configs (special character in ssid/passwd, differnt auth type) - 2. install and config APK on all smart phones - 3. use APK to test WiFi connect - sub module: WIFI Connect - summary: connect to softap IOT test - test environment: SSC_T5_IOT1 - test point 1: interoperability - test point 2: Connect to SoftAP inter operablity test - version: v1 (2016-10-18) -- CI ready: 'No' - ID: WIFI_CONN_9901 - SDK: All - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Performance - cmd set: - - WiFiStress/WifiJAPCompatibility - - - test_count = 10 - - - '' - - - retry_count = 1 - - - '' - execution time: 1 - expected result: 1. set succeed 2. disconnect succeed 3. connect succeed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: 1. set sta mode 2. disconnect sta 3. sta connect ap - sub module: WIFI Connect - summary: STA connect to AP compatibility test - test environment: SSC_T1_IOT1 - test point 1: Compatibility Test test point - test point 2: WIFI compatibility test - version: v1 (2016-10-23) -- CI ready: 'No' - ID: WIFI_CONN_0704 - SDK: All - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - R SSC1 NC +JAPAUTHCHANGED C +JAP:CONNECTED - execution time: 0 - expected result: 1. sta connect ap suc and no +JAPAUTHCHANGED found - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: 1. sta JAP - sub module: WIFI Connect - summary: sta connect wep encrypt ap - test environment: SSC_T1_WEP - test point 1: basic function - test point 2: ap connect test - version: v1 (2016-10-23) -- CI ready: 'No' - ID: WIFI_CONN_9902 - SDK: All - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Performance - cmd set: - - WiFiStress/WifiStaConnectionHolder - - - test_count = 10 - - - '' - - - retry_count = 1 - - - '' - execution time: 1 - expected result: |- - 1. set SSC1 AP+STA mode, SSC2 AP mode, SSC3 STA mode - 2. SSC3 connect SSC1 - 3. SSC2 random set ap channel - 4. SSC1 connect SSC2 - initial condition: T3_1 - level: Integration - module: WIFI MAC - steps: |- - 1. set mode suc - 2. connect suc - 3. set channel suc - 4. connect suc - sub module: WIFI Connect - summary: STA keep connected with AP stable test - test environment: SSC_T3_1 - test point 1: AP switch channel dut Connection holder Test test point - test point 2: WIFI Connection holder test - version: v1 (2016-10-23) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_MODE.yml b/components/idf_test/integration_test/TC_IT_WIFI_MODE.yml deleted file mode 100644 index 67a2abadc..000000000 --- a/components/idf_test/integration_test/TC_IT_WIFI_MODE.yml +++ /dev/null @@ -1,135 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: WIFI_MODE_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC1 op -S -o 1 - - - R SSC1 C +MODE:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 sta -S - - - R SSC2 NP C +SCANDONE - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:OK - execution time: 0.0 - expected result: |- - 1.target1下设置ssid 和pwd 、加密方式成功 - 2.修改target 1的mode 为sta mode - 3.target1的dhcp打开 - 4.target1成功连接上AP - 5.target2上不能查询到target_ssid - 6.target1断开AP - initial condition: T2O_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.修改target1的mode 为sta mode - 3.target1的dhcp打开 - 4.target1连接AP - 5.target2查询target_ssid - 6.target1断开AP - sub module: WIFI Mode - summary: mode switch test (sta mode) - test environment: SSC_T2_3 - test point 1: basic function - test point 2: wifi mode fucntion - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_MODE_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S - - - R SSC2 P - - R SSC2 C +SCANDONE - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:ERROR - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:ERROR - execution time: 0.0 - expected result: |- - 1. target1 set AP - 2.target 2 上查询到target_ssid - 3. target1 can't join AP - 4. target1 can't QAP - initial condition: T2O_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target 2 上查询target_ssid - 3.target1 join AP - 4.target1 DISCONN AP - sub module: WIFI Mode - summary: mode switch test (AP mode) - test environment: SSC_T2_3 - test point 1: basic function - test point 2: wifi mode fucntion - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_MODE_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 3 - - - R SSC1 C +MODE:OK - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC1 dhcp -S -o 1 - - - R SSC1 C +DHCP:STA,OK - - - SSC SSC1 sta -C -s -p - - - R SSC1 RE "\+JAP:CONNECTED,%%s"%%() - - - SSC SSC2 sta -S - - - R SSC2 P - - R SSC2 C +SCANDONE - execution time: 0.0 - expected result: |- - 1.target1 change to AP mode - 2.target1 set AP - 3.target 1 的dhcp 打开 - 4.target 1 成功连接上AP - 5.target 2 上查询到target_ssid - initial condition: T2O_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1 change to AP mode - 2.target1下设置ssid 和pwd 加密方式 - 3.target1 的dhcp 打开 - 4.target1 连接AP - 5.target2 上查询target_ssid - sub module: WIFI Mode - summary: mode switch test (STA+AP mode) - test environment: SSC_T2_3 - test point 1: basic function - test point 2: wifi mode fucntion - version: v1 (2016-8-15) diff --git a/components/idf_test/integration_test/TC_IT_WIFI_SCAN.yml b/components/idf_test/integration_test/TC_IT_WIFI_SCAN.yml deleted file mode 100644 index f6c1cd83a..000000000 --- a/components/idf_test/integration_test/TC_IT_WIFI_SCAN.yml +++ /dev/null @@ -1,931 +0,0 @@ -test cases: -- CI ready: 'Yes' - ID: WIFI_SCAN_0101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 sta -S -s .,juhg123 - - - 'R SSC2 NC +SCAN: C +SCANDONE' - - - SSC SSC1 ap -S -s -p 123456789 -t 3 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S -s - - - 'R SSC2 C +SCAN:' - - R SSC2 P - - 'R SSC2 NC +SCAN: C +SCANDONE' - execution time: 0.0 - expected result: |- - 1.target 2上不能scan .,juhg123 - 2.target1 set AP - 3.target2上查询到 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target 2 scan .,juhg123 - 2.target1下设置ssid 和pwd 加密方式 - 3.target2 scan - sub module: WIFI Scan - summary: scan with scan config ssid - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0102 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC2 sta -S -b ff:ff:ff:ff:ff:11 - - - 'R SSC2 NC +SCAN: C +SCANDONE' - - - SSC SSC2 sta -S -b - - - R SSC2 RE "\+SCAN:.+,%%s"%%() - - 'R SSC2 NC +SCAN: C +SCANDONE' - execution time: 0.0 - expected result: |- - 1.target2 上不能查询到此mac - 2.target2上查询到 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target2 上查询此macff:ff:ff:ff:ff:11 - 2.target2上查询 - sub module: WIFI Scan - summary: scan with scan config bssid - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0103 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 ap -S -s -p 123456789 -t 3 -n 6 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S -n 5 - - - R SSC2 NP C +SCANDONE - - - SSC SSC2 sta -S -n 6 - - - 'R SSC2 C +SCAN:' - - R SSC2 P - execution time: 0.0 - expected result: |- - 1.target1 QAP - 2. target1 set AP,set channel 6 - 3.target2 上scan不到 channel 5 - 4.target2 上查询channel 6的 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1 断开连接AP - 2.target1下设置ssid 和pwd 加密方式,set channel 6 - 3.target2 上scan channel 5 - 4.target2 上查询channel 6的 - sub module: WIFI Scan - summary: scan with scan config channel - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0104 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p 123456789 -t 3 -h 0 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -D - - - R SSC2 C OK - - - SSC SSC2 sta -S -h 0 - - - R SSC2 P C +SCANDONE - - - SSC SSC2 sta -S -h 1 - - - R SSC2 P C +SCANDONE - - - SSC SSC1 ap -S -s -p 123456789 -h 1 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S -h 0 - - - R SSC2 NP C +SCANDONE - - - SSC SSC2 sta -S -h 1 - - - R SSC2 P C +SCANDONE - execution time: 0.0 - expected result: |- - 1.target1 set AP,set ssid broad cast - 2.target 2上scan - 3.target 2上scan - 4.target1 set AP,set ssid hidden, - 5.target 2上不能查询到 - 6.target 2上查询到 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式,set ssid broad cast - 2.target 2上scan - 3.target 2上scan - 4.target1下设置ssid 和pwd 加密方式,set ssid hidden, - 5.target 2上查询 - 6.target 2上查询 - sub module: WIFI Scan - summary: scan with scan config show hidden - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan with different config - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0105 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -D - - - 'R SSC1 C +QAP:' - - - SSC SSC1 ap -S -s -p 123456789 -t 3 -h 0 -n 11 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -S -s -b -n 11 - - - R SSC2 P C +SCANDONE - - - SSC SSC2 sta -S -s -b -n 11 - - - R SSC2 NP C +SCANDONE - - - SSC SSC2 sta -S -s -b ff:ff:ff:ff:ff:11 -n 11 - - - R SSC2 P - - R SSC2 NP C +SCANDONE - - - SSC SSC2 sta -S -s -b -n 10 - - - R SSC2 P - - R SSC2 NP C +SCANDONE - execution time: 0.0 - expected result: |- - 1.target1 QAP - 2. target1 set AP,set ssid broad cast,set channel 11 - 3.target2 上查询到 - 4.target2 上查询不到 - 5.target2 上查询不到 - 6.target2 上查询不到 - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1 QAP - 2. target1 set AP,set ssid broad cast,set channel 11 - 3.target2 上查询到 - 4.target2 上查询不到 - 5.target2 上查询不到 - 6.target2 上查询不到 - sub module: WIFI Scan - summary: scan with several configs - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan with different config - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0201 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 phy -S -o 1 -m b - - - R SSC1 C +SPHY:protocol - - - SSC SSC1 sta -S - - - R SSC1 P P P P - - - SSC SSC1 phy -S -o 1 -m g - - - R SSC1 C +SPHY:protocol - - - SSC SSC1 sta -S - - - R SSC1 P P P P - - - SSC SSC1 phy -S -o 1 -m n -b 20 - - - R SSC1 C +SPHY:protocol - - - SSC SSC1 sta -S - - - R SSC1 P P P P - - - SSC SSC1 phy -S -o 1 -m n -b 40 - - - R SSC1 C +SPHY:protocol - - - SSC SSC1 sta -S - - - R SSC1 P P P P - execution time: 0.0 - expected result: |- - 3. find all 3 ext APs - 5. find all 3 ext APs - 7. find all 3 ext APs - 9. find all 3 ext APs - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. 3 ext APs in 11b, 11g, 11n mode - 2. STA in 11b mode - 3. do all channel scan - 4. STA in 11g mode - 5. do all channel scan - 6. STA in 11n ht20 mode - 7. do all channel scan - 8. STA in 11n ht40 mode - 9. do all channel scan - sub module: WIFI Scan - summary: STA in differnt PHY mode to scan AP in different PHY mode - test environment: SSC_T2_PhyMode - test point 1: basic function - test point 2: Scan in different mode and channel - version: v1 (2015-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0202 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p -d 0 -b - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -d 1 -b - - - P SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.OK - 2.ok - 3.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target2 jap - 3.target2 conn target1 by bssid - sub module: WIFI Scan - summary: do scan/JAP/SAP with bssid set config - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan function test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0203 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 3 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p -f 0 -j 0 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 0 -j 1 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 0 -j 2 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 0 -j 3 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 0 -j 5 - - - '' - - - SSC SSC2 sta -C -s -p -f 1 -j 1 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -j 2 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -j 3 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -j 0 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -j 4 - - - '' - - - SSC SSC2 sta -C -s -p -f 3 -j 0 - - - P SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.OK 2.ok - 3.ok - 4.ok - 5.ok - 7.ok - 8.ok - 9.ok - 10.ok - 12.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target2 fast scan and jap target1 - 3.target2 jap target1 except open encrypt - 4.target2 jap target1 except open and wep encrypt - 5.target2 jap target1 only wpa2 encrypt can be connect - 6.target2 scan all channel jap target1 except open encrypt - 7.target2 scan all channel jap target1 except open encrypt - 8.target2 scan all channel jap target1 except open and wep encrypt - 9.target2 scan all channel jap target1 only wpa2 encrypt can be connected - 10.target2 scan all channel jap target1 - 11.target2 scan all channel jap target1 - 12.target2 jap target1 - sub module: WIFI Scan - summary: do scan/JAP/SAP with scan method and weakest auth mode - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan function test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0204 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 2 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p -f 0 -q 0 - - - '' - - - SSC SSC2 sta -C -s -p -f 0 -q 128 - - - '' - - - SSC SSC2 sta -C -s -p -f 0 -q 80 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -q 128 - - - '' - - - SSC SSC2 sta -C -s -p -f 1 -q 0 - - - '' - - - SSC SSC2 sta -C -s -p -f 1 -q 80 - - - P SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.OK - 2.no exception - 3.no exception - 4.ok - 5.no exception - 6.no exception - 7.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target2 fast scan and jap target1 rssi>-1 - 3.target2 fast scan and jap rssi>-127 - 4.target2 scan all channel and jap target1 rssi>-80 - 5.target2 scan all channel and jap rssi > -127 - 6.target2 scan all channel and jap rssi > -1 - 7.target2 scan all channel and jap target1 rssi > -80 - sub module: WIFI Scan - summary: do scan/JAP/SAP with scan method and weakest rssi - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan function test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0205 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t 3 - - - R SSC1 C +SAP:OK - - - SSC SSC2 sta -C -s -p -f 1 -x 0 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -x 1 - - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -C -s -p -f 1 -x 2 - - - P SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 1.OK - 2.ok - 3.ok - 4.ok - initial condition: T2_1 - level: Integration - module: WIFI MAC - steps: |- - 1.target1下设置ssid 和pwd 加密方式 - 2.target2 scan ap all channel and jap target1 by rssi sort - 3.target2 scan ap all channel and jap target1 by auth - 4.target2 scan ap all channel jap target1 by auth - sub module: WIFI Scan - summary: do scan/JAP/SAP with scan method and sort method - test environment: SSC_T2_5 - test point 1: basic function - test point 2: scan function test - version: v1 (2016-8-15) -- CI ready: 'No' - ID: WIFI_SCAN_0206 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 op -S -o 1 - - - P SSC1 C +MODE:OK - - - SSC SSC1 op -Q - - - P SSC1 C +CURMODE:1 - - - SSC SSC1 sta -S -t 0 -l 0 -m 0 - - - 'R SSC1 C +SCAN: C +SCANDONE' - - - SSC SSC1 sta -S -t 0 -l 1000 -m 100 - - - 'R SSC1 C +SCAN: C +SCANDONE' - - - SSC SSC1 sta -S -t 1 -k 0 - - - 'R SSC1 C +SCAN: C +SCANDONE' - - - SSC SSC1 sta -S -t 1 -k 2000 - - - 'R SSC1 C +SCAN: C +SCANDONE' - - - SSC SSC1 sta -S -t 5 -k 100 - - - 'R SSC1 C +SCAN: C +SCANDONE' - execution time: 0.0 - expected result: |- - 1.OK - 2.ok - 3.scan ok - 4.scan ok - 5.scan ok - 6.scan ok - 7.scan ok - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1.target set as sta - 2.check target1 work mode - 3.target1 active scan max and min time set to 0ms - 4.target1 active scan max time 1000ms min time 100ms - 5.target1 passive scan scan time 0ms - 6.target passive scan scan time 10000ms - 7.target1 scan type set to 5 - sub module: WIFI Scan - summary: do active/passive scan - test environment: SSC_T1_4 - test point 1: basic function - test point 2: scan function test - version: v1 (2016-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0301 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -S - - - '' - - - SSC SSC1 sta -S - - - P SSC1 C +SCANFAIL - - 'P SSC1 C +SCAN:' - - R SSC1 C +SCANDONE - execution time: 0.0 - expected result: |- - 1. second scan failed - 2. first scan succeed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. do all channel scan - 2. do scan before scan finished - sub module: WIFI Scan - summary: reject scan request before scan finished - test environment: SSC_T1_5 - test point 1: interaction - test point 2: Scan interact with other WiFi operation - version: v1 (2015-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0302 - SDK: ESP32_IDF - Test App: SSC - allow fail: '2/3' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:CONNECTED - - - SSC SSC1 soc -B -t UDP -p - - - R SSC1 A :BIND:(\d+),OK - - - SSC SSC1 soc -S -s -i -p -n 1000000 -j 5 - - - '' - - - SSC SSC2 phy -S -o 1 -m b - - - R SSC2 C +SPHY:protocol - - - SSC SSC2 sta -S -n - - - R SSC2 P - - - SSC SSC2 phy -S -o 1 -m g - - - R SSC2 C +SPHY:protocol - - - SSC SSC2 sta -S -n - - - R SSC2 P - - - SSC SSC2 phy -S -o 1 -m n -b 20 - - - R SSC2 C +SPHY:protocol - - - SSC SSC2 sta -S -n - - - R SSC2 P - - - SSC SSC2 phy -S -o 1 -m n -b 40 - - - R SSC2 C +SPHY:protocol - - - SSC SSC2 sta -S -n - - - R SSC2 P - execution time: 0.0 - expected result: 3. target 2 able to scan AP - initial condition: T2_2 - level: Integration - module: WIFI MAC - steps: |- - 1. target 1 connect to AP - 2. target 1 start sending UDP packets - 3. target 2 scan in AP channel in 11b.g,n,ht40 mode - sub module: WIFI Scan - summary: scan in congest channel - test environment: SSC_T2_4 - test point 1: interaction - test point 2: Scan interact with other WiFi operation - version: v1 (2015-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0303 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 sta -C -s -p - - - R SSC1 C +JAP:OK - - - SSC SSC1 sta -S - - - P SSC1 C +SCANDONE - - P SSC1 C +JAP:CONNECTED - - - SSC SSC1 sta -D - - - R SSC1 C +QAP:OK - - - SSC SSC1 sta -S - - - '' - - - SSC SSC1 sta -C -s -p - - - P SSC1 C +SCANDONE - - P SSC1 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 2. scan succeed, JAP succeed - 5. JAP succeed, scan succeed - initial condition: STAM1 - level: Integration - module: WIFI MAC - steps: |- - 1. target 1 STA join AP - 2. target 1 STA scan before JAP succeed - 3. target 1 quite AP - 4. target 1 scan - 5. target 1 JAP before scan succeed - sub module: WIFI Scan - summary: scan during JAP - test environment: SSC_T1_5 - test point 1: interaction - test point 2: Scan interact with other WiFi operation - version: v1 (2015-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_0304 - SDK: ESP32_IDF - Test App: SSC - allow fail: '' - auto test: 'Yes' - category: Function - cmd set: - - '' - - - SSC SSC1 ap -S -s -p -t - - - R SSC1 C +SAP:OK - - - SSC SSC1 sta -D - - - R SSC1 C OK - - - SSC SSC2 sta -C -s -p - - - R SSC2 C +JAP:OK - - - SSC SSC1 sta -S - - - P SSC1 C +SCANDONE - - P SSC2 C +JAP:CONNECTED - - - SSC SSC2 sta -D - - - R SSC2 C +QAP:OK - - - SSC SSC1 sta -S - - - '' - - - SSC SSC2 sta -C -s -p - - - P SSC1 C +SCANDONE - - P SSC2 C +JAP:CONNECTED - execution time: 0.0 - expected result: |- - 2. scan succeed, JAP succeed - 5. JAP succeed, scan succeed - initial condition: T2_2 - level: Integration - module: WIFI MAC - steps: |- - 1. target 2 STA join target 1 SoftAP - 2. target 1 STA scan before target 2 JAP succeed - 3. target 2 STA QAP - 4. target 1 STA scan - 5. target 2 STA JAP before target 1 STA scan succeed - sub module: WIFI Scan - summary: scan during ext STA join SoftAP - test environment: SSC_T2_5 - test point 1: interaction - test point 2: Scan interact with other WiFi operation - version: v1 (2015-8-15) -- CI ready: 'Yes' - ID: WIFI_SCAN_5101 - SDK: |- - 8266_NonOS - 8266_RTOS - ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiSCANTime - - - test_time = 300 - - - '' - - - active_scan_max_time = 120 - - - '' - - - active_scan_min_time = 20 - - - '' - - - passive_scan_max_time = 100 - - - '' - - - scan_mode_list = ["active_scan","passive_scan"] - - - '' - execution time: 5.0 - expected result: "1. succeed\n3. scan time less than 1.15 test time " - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. 1 target set to sta mode - 2. set scan mode - 3. start scan ap and check scan time - sub module: WIFI Scan - summary: test differnt scan mode scan time - test environment: SSC_T1_1 - test point 1: stress - test point 2: Sta active/passive scan stress test - version: v2 (2017-05-10) -- CI ready: 'No' - ID: WIFI_SCAN_5201 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "conn_by_bssid" - - - '' - execution time: 0.2 - expected result: |- - 1. all routers configure correctly - 3. connect success - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. Manually configure the two routers with the same ssid ,password and security mode - 2. SSC1 target connect PC by Uart. - 3. SSC target connect ap by the specified bssid - sub module: WIFI Scan - summary: connect specify ap test - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: connect ap by bssid - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5202 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "conn_max_rssi_ap" - - - '' - execution time: 0.2 - expected result: |- - 1. configure ap right - 3. connect success - 4. rssi value is the largest of the four routers - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. Manually configure the four routers with the same ssid ,password and security mode - 2. 1 SSC target connect PC by Uart. - 3. SSC connect max rssi ap. - 4. check connection ap's rssi value - sub module: WIFI Scan - summary: connect max rssi ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: connect max rssi ap - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5203 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "conn_most_security_ap" - - - '' - execution time: 0.2 - expected result: |- - 1. the routers are configured correctly - 3. connect success - 4. encryption mode is the highest in four routers - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. Manually configure the four routers with the same ssid ,password and different security mode - 2. target1 connect PC by Uart. - 3. target1 connect the highest encryption mode ap - 4. check connection ap's security mode - sub module: WIFI Scan - summary: connect most security ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: connect most security ap - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5204 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "conn_setting_ap" - - - '' - execution time: 0.2 - expected result: |- - 1. the routers are configured correctly - 3. connect success - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. Manually configure the four routers with the same ssid different password - 2. target1 connect PC by Uart. - 3. target1 connect setting ap - sub module: WIFI Scan - summary: connect setting ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: connect setting ap - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5205 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "reconn_same_ssid_ap" - - - '' - - - apc_num_list = [1,3] - - - '' - execution time: 0.5 - expected result: |- - 1. the routers are configured correctly - 3. ap1 power on - 4. connect success - 5. ap2 power on and ap1 power off - 6. connect success - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. Manually configure the two routers with the same ssid ,password different security mode - 2. target1 connect PC by Uart. - 3. ap1 power on by apc - 4. atrget1 connect ap - 5. ap1 power off and ap2 power on - 6. atrget1 auto connect ap2. - sub module: WIFI Scan - summary: reconnect same ssid ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: reconnect same ssid ap - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5206 - SDK: ESP32_IDF - Test App: SSC - auto test: 'Yes' - category: Stress - cmd set: - - WiFiStress/WifiScanOptimize - - - test_times = 10 - - - '' - - - test_mode = "quick_conn_ap" - - - '' - - - rssi_threshold = 60 - - - '' - - - low_rssi_num = 1 - - - '' - execution time: 0.3 - expected result: |- - 1. the routers are configured correctly - 3. connect success - 4. connect to the correct ap - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. manuall configure two routers with the same ssid password and below rssi_threshold ap's channel at the front - 2. target1 connect PC by Uart. - 3. atrget1 connect ap - 4. check connection ap's bssid - sub module: WIFI Scan - summary: quick connect ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function + stress - test point 2: quick connect ap - version: v2 (2016-11-15) -- CI ready: 'No' - ID: WIFI_SCAN_5207 - SDK: ESP32_IDF - Test App: SSC - auto test: 'No' - category: Stress - cmd set: '' - execution time: 0.3 - expected result: |- - 1. the routers are configured correctly - 3. set suc - 5. burn suc - 6. set mode ok and SSC connected to the open security mode ap auto - initial condition: None - level: Integration - module: WIFI MAC - steps: |- - 1. configure four router with the same ssid and one of them security mode is open - 2. target1 connect PC by Uart. - 3. set the ssid of the router in the manuconfig but not the password - 4. save the setting and compile - 5. burn bin files - 6. set target1 to sta mode - 7. loop 1,2,3,4 ten times - sub module: WIFI Scan - summary: connect open security ap - test environment: SSC_T1_SCANSPECIFIED - test point 1: function - test point 2: connect open security mode ap - version: v2 (2016-11-15) diff --git a/components/idf_test/integration_test/TEST_ENV_SSC.yml b/components/idf_test/integration_test/TEST_ENV_SSC.yml deleted file mode 100644 index c38164938..000000000 --- a/components/idf_test/integration_test/TEST_ENV_SSC.yml +++ /dev/null @@ -1,474 +0,0 @@ -.TEST_ENV: &TEST_ENV - PC OS: '' - Special: N - test script: EnvBase - -test environment: -- tag: SSC_T1_1 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC has 2 wired NIC connected to AP. - PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. -- tag: ETH_T1_1 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC connected to AP by wired NIC. - 1 ETH DUT connect with PC by UART, connect to AP by wired NIC. -- tag: SSC_T1_2 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - Able to access WAN after connect to AP. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_3 - <<: *TEST_ENV - Target Count: 1 - test environment detail: PC has one BT adapter (dongle). 1 SSC DUT connect with - PC by UART. -- tag: SSC_T1_4 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_5 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - AP placed near DUT. -- tag: SSC_T1_6 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - AP placed near DUT. - PC has 1 wired NIC connected to AP. -- tag: SSC_T1_7 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - PC has 1 WiFi NIC. - AP placed near DUT and PC. -- tag: SSC_T1_8 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - AP placed near DUT and PC. - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. -- tag: SSC_T1_9 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC has 2 wired NIC connected to AP. - 1 SSC DUT connected to AP. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_10 - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_ARP - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC (linux) has 1 wired NIC connected to AP. - AP is configured as update group key every 30s. - PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_8089 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - PC has 1 wired NIC connected to AP. - 1 8089 tablet able to run iperf test placed near SSC1. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_ADC - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - PC has 1 wired NIC connected to AP. - Analog input connect to SSC1 TOUT. - Multimeter connect to input, able to measure input voltage. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_AMSDU - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect PC by UART. - PC 无线网卡和 SSC DUT 均连接到天猫魔盒AP. -- tag: SSC_T1_APC - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 wired NIC connected to APC (static IP within the same subnet with APC). - APC control AP power supply. - PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_Enterprise - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: "AP use WPA2-Etherprise is placed near SSC1. \n1 SSC DUT - connect with PC by UART." -- tag: SSC_T1_IOT1 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. - AP todo IOT test are placed near SSC1. -- tag: SSC_T1_MESH1 - Special: Y - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T1_MESH2 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - 1 SSC target connect with PC by UART. - PC has 1 wired NIC connected to a fixed channel Router. -- tag: SSC_T1_InitData - <<: *TEST_ENV - Special: Y - Target Count: 2 - test environment detail: |- - 2 SSC DUT connect with PC by UART. - SSC1 use 40M crystal oscillator. - SSC2 use normal 26M crystal oscillator. - SSC2 GPIO connect to SSC1 power control pin. -- tag: SSC_T1_SCANSPECIFIED - <<: *TEST_ENV - Special: N - Target Count: 1 - test environment detail: 1 SSC DUT connect with PC by UART. All APs power on. -- tag: SSC_T1_ShieldBox - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - refer to figure. - All APs and APC should be set to the same IP subnet. - PC wired NIC should set static IP address within the same subnet with AP. - Must use onboard wired NIC. -- tag: SSC_T1_Sleep1 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - AP support DTIM placed with AT DUT. - SSC DUT connect with Raspberry Pi by UART. - Multimeter connect with Raspberry Pi via GPIB. - Series multimeter between GND and VCC of SSC1. - SSC1's light sleep wakeup pin and wakeup indication connect with Raspberry Pi's GPIO. - SSC1's XPD connect with RSTB. -- tag: SSC_T1_Sleep2 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - AP support DTIM placed with AT DUT. - SSC DUT connect with Raspberry Pi by UART. - Multimeter connect with Raspberry Pi via GPIB. - Series multimeter between GND and VCC of SSC1. - SSC1's RSTB pin connect with Raspberry Pi's GPIO. -- tag: SSC_T1_Sleep3 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - AP support DTIM placed with AT DUT. - SSC DUT connect with Raspberry Pi by UART. - Multimeter connect with Raspberry Pi via GPIB. - Series multimeter between GND and VCC of SSC1. -- tag: SSC_T1_Sniffer - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - PC has 1 wired NIC connected to AP. PC has 1 WiFi NIC. - 1 SSC DUT connect with PC by UART. -- tag: SSC_T1_TempBox - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - Put SSC DUT to temperature box. -- tag: SSC_T1_VDD33 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - Multimeter connect to VDD33, able to measure voltage. -- tag: SSC_T1_WEP - <<: *TEST_ENV - Target Count: 1 - test environment detail: |- - 1 SSC DUT connect with PC by UART. - One WEP share key AP placed near SSC1. -- tag: SSC_T2_1 - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 2 SSC DUTs connect with PC by UART. -- tag: SSC_T2_2 - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - PC has 1 WiFi NIC. - 2 SSC DUTs connect with PC by UART. -- tag: SSC_T2_3 - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - 2 SSC DUTs connect with PC by UART. - AP placed near SSC DUTs -- tag: SSC_T2_4 - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - PC has 1 wired NIC connected to AP. - AP placed near SSC DUTs and PC. - 2 SSC DUTs connect with PC by UART. -- tag: SSC_T2_5 - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - 2 SSC DUTs connect with PC by UART. -- tag: SSC_T2_JAP - <<: *TEST_ENV - Target Count: 2 - test environment detail: |- - PC has 1 wired NIC connected to APC. - APC control the power supply of multiple APs. - 2 SSC DUT connect with PC by UART. -- tag: SSC_T2_PhyMode - <<: *TEST_ENV - PC OS: 'linux' - Target Count: 2 - test environment detail: |- - 2 SSC DUT connect with PC by UART. - PC has one WiFi NIC support capture wlan packet using libpcap. - Set 4 AP with phy mode 11b, 11g, 11n HT20, 11n HT40. - Put 4 APs near SSC DUTs. -- tag: SSC_T2_ShieldBox - <<: *TEST_ENV - Special: Y - Target Count: 2 - test environment detail: |- - 2 SSC DUT connect with PC by UART. - Put them to Shield box. -- tag: SSC_T2_ShieldBox2 - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: | - refer to figure. - 2 SSC DUT connect with PC by UART. Put DUT board to different Shield boxes. - 2 shield boxes are connected with programmable attenuator. -- tag: SSC_T2_Sniffer - <<: *TEST_ENV - PC OS: 'linux' - Special: N - Target Count: 2 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 2 SSC DUT connect with PC by UART. -- tag: SSC_T2_TempBox - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: | - refer to figure. - 2 SSC DUT connect with PC by UART. Put 1 DUT board to temperature box. -- tag: SSC_T2_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 2 - test environment detail: |- - 2 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T3_1 - <<: *TEST_ENV - Special: N - Target Count: 1 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 3 SSC DUT connect with PC by UART. -- tag: SSC_T3_2 - <<: *TEST_ENV - Special: N - Target Count: 3 - test environment detail: |- - 3 SSC DUT connect with PC by UART. -- tag: SSC_T3_PhyMode - <<: *TEST_ENV - PC OS: 'linux' - Target Count: 3 - test environment detail: |- - 3 SSC DUT connect with PC by UART. - PC has one WiFi NIC support capture wlan packet using libpcap. - Set 4 AP with (HT20, channel1), (HT20, channel2), (HT40, channel1), (HT40, channel2). - Put 4 APs near SSC DUTs. -- tag: SSC_T3_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 3 - test environment detail: |- - 3 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T3_MESH2 - <<: *TEST_ENV - Special: Y - Target Count: 3 - test environment detail: |- - 3 SSC target connect with PC by UART. - PC has 1 wired NIC connected to a fixed channel Router. -- tag: SSC_T5_1 - <<: *TEST_ENV - Target Count: 5 - test environment detail: 5 SSC DUT connect with PC by UART. -- tag: SSC_T5_IOT1 - <<: *TEST_ENV - Special: Y - Target Count: 5 - test environment detail: |- - 5 SSC DUTs connect with PC by UART. - some Android smart phone are placed near SSC DUTs. -- tag: SSC_T6_1 - <<: *TEST_ENV - Special: Y - Target Count: 6 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 6 SSC DUT connect with PC by UART. -- tag: SSC_T6_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 6 - test environment detail: |- - 6 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T6_MESH2 - <<: *TEST_ENV - Special: Y - Target Count: 6 - test environment detail: |- - 6 SSC target connect with PC by UART. - PC has 1 wired NIC connected to a fixed channel Router. -- tag: SSC_T1_DNS - <<: *TEST_ENV - Target Count: 1 - test environment detail: 1 SSC DUT connect with PC by UART,AP should Access to the Internet. -- tag: SSC_T1_SmartConfigIOT - <<: *TEST_ENV - Special: Y - Target Count: 1 - test environment detail: | - 1 SSC DUT connect with PC by UART. - PC has 1 wired NIC connect to Common AP. - Several AP are placed near AT DUT. - Several smart phone installed test APK are placed near SSC DUT. -- tag: SSC_T12_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 12 - test environment detail: |- - 12 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T12_MESH2 - <<: *TEST_ENV - Special: Y - Target Count: 12 - test environment detail: |- - 12 SSC target connect with PC by UART. - PC has 1 wired NIC connected to a fixed channel Router. -- tag: SSC_T20_1 - <<: *TEST_ENV - Special: Y - Target Count: 20 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 20 SSC DUT connect with PC by UART. -- tag: SSC_T35_1 - <<: *TEST_ENV - Special: Y - Target Count: 35 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 37 SSC DUT connect with PC by UART. -- tag: SSC_T50_1 - <<: *TEST_ENV - Special: Y - Target Count: 50 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 50 SSC DUT connect with PC by UART. -- tag: SSC_T50_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 50 - test environment detail: |- - 50 SSC target connect with PC by UART. - A router with fixed channel nearby -- tag: SSC_T60_1 - <<: *TEST_ENV - Special: Y - Target Count: 60 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 60 SSC DUT connect with PC by UART. -- tag: SSC_T80_1 - <<: *TEST_ENV - Special: Y - Target Count: 80 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 80 SSC DUT connect with PC by UART. -- tag: SSC_T100_1 - <<: *TEST_ENV - Special: Y - Target Count: 100 - test environment detail: |- - PC has 1 wired NIC connected to AP. - PC has 1 WiFi NIC. - 100 SSC DUT connect with PC by UART. -- tag: SSC_T50_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 50 - test environment detail: |- - 50 SSC target connect with PC by UART. -- tag: SSC_T100_MESH1 - <<: *TEST_ENV - Special: Y - Target Count: 100 - test environment detail: |- - 100 SSC target connect with PC by UART. diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index 632d866ed..826d7f1e5 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -5,6 +5,7 @@ set(COMPONENT_ADD_INCLUDEDIRS port/esp32/include port/esp32/include/arch include_compat + port/esp32/tcp_isn ) set(COMPONENT_SRCS "apps/dhcpserver/dhcpserver.c" @@ -123,6 +124,10 @@ if(CONFIG_PPP_SUPPORT) "lwip/src/netif/ppp/polarssl/sha1.c") endif() +if(CONFIG_LWIP_TCP_ISN_HOOK) + list(APPEND COMPONENT_SRCS "port/esp32/tcp_isn/tcp_isn.c") +endif() + set(COMPONENT_REQUIRES vfs) set(COMPONENT_PRIV_REQUIRES ethernet tcpip_adapter nvs_flash) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index b352985e5..7ad19499c 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -106,18 +106,31 @@ menu "LWIP" help Enabling this option allows checking for available data on a netconn. - config LWIP_IP_FRAG - bool "Enable fragment outgoing IP packets" + config LWIP_IP4_FRAG + bool "Enable fragment outgoing IP4 packets" default y help - Enabling this option allows fragmenting outgoing IP packets if their size + Enabling this option allows fragmenting outgoing IP4 packets if their size exceeds MTU. - config LWIP_IP_REASSEMBLY - bool "Enable reassembly incoming fragmented IP packets" + config LWIP_IP6_FRAG + bool "Enable fragment outgoing IP6 packets" + default y + help + Enabling this option allows fragmenting outgoing IP6 packets if their size + exceeds MTU. + + config LWIP_IP4_REASSEMBLY + bool "Enable reassembly incoming fragmented IP4 packets" default n help - Enabling this option allows reassemblying incoming fragmented IP packets. + Enabling this option allows reassemblying incoming fragmented IP4 packets. + + config LWIP_IP6_REASSEMBLY + bool "Enable reassembly incoming fragmented IP6 packets" + default n + help + Enabling this option allows reassemblying incoming fragmented IP6 packets. config LWIP_STATS bool "Enable LWIP statistics" @@ -283,6 +296,17 @@ menu "LWIP" menu "TCP" + config LWIP_TCP_ISN_HOOK + bool "Enable TCP ISN Hook" + default y + help + Enables custom TCP ISN hook to randomize initial sequence + number in TCP connection. This is recommended as default + lwIP implementation (`tcp_next_iss`) is not very strong, + as it does not take into consideration any platform + specific entropy source. + + config LWIP_MAX_ACTIVE_TCP int "Maximum active TCP Connections" range 1 1024 @@ -451,6 +475,13 @@ menu "LWIP" help Enable this feature to support TCP window scaling. + config LWIP_TCP_RTO_TIME + int "Default TCP rto time" + default 3000 + help + Set default TCP rto time for a reasonable initial rto. + In bad network environment, recommend set value of rto time to 1500. + endmenu # TCP menu "UDP" @@ -519,6 +550,19 @@ menu "LWIP" default 0x0 if TCPIP_TASK_AFFINITY_CPU0 default 0x1 if TCPIP_TASK_AFFINITY_CPU1 + config LWIP_IPV6_MEMP_NUM_ND6_QUEUE + int "Max number of IPv6 packets to queue during MAC resolution" + range 3 20 + default 3 + help + Config max number of IPv6 packets to queue during MAC resolution. + + config LWIP_IPV6_ND6_NUM_NEIGHBORS + int "Max number of entries in IPv6 neighbor cache" + range 3 10 + default 5 + help + Config max number of entries in IPv6 neighbor cache. menuconfig PPP_SUPPORT bool "Enable PPP support (new/experimental)" diff --git a/components/lwip/component.mk b/components/lwip/component.mk index f43250baa..dca378477 100644 --- a/components/lwip/component.mk +++ b/components/lwip/component.mk @@ -9,7 +9,8 @@ COMPONENT_ADD_INCLUDEDIRS := \ lwip/src/include \ port/esp32/include \ port/esp32/include/arch \ - include_compat + include_compat \ + port/esp32/tcp_isn COMPONENT_SRCDIRS := \ apps/dhcpserver \ @@ -30,6 +31,10 @@ ifdef CONFIG_PPP_SUPPORT COMPONENT_SRCDIRS += lwip/src/netif/ppp lwip/src/netif/ppp/polarssl endif +ifdef CONFIG_LWIP_TCP_ISN_HOOK + COMPONENT_SRCDIRS += port/esp32/tcp_isn +endif + CFLAGS += -Wno-address # lots of LWIP source files evaluate macros that check address of stack variables ifeq ($(GCC_NOT_5_2_0), 1) diff --git a/components/lwip/lwip b/components/lwip/lwip index 453b291c4..95710c427 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 453b291c4c0752e05b585a62d32d8bb23e1538d7 +Subproject commit 95710c4276b4429ca50cd23a1007e381a0dd48f3 diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index a458fc487..f213aeef1 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -157,18 +157,32 @@ -------------------------------- */ /** - * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that + * IP_REASSEMBLY==1: Reassemble incoming fragmented IP4 packets. Note that * this option does not affect outgoing packet sizes, which can be controlled * via IP_FRAG. */ -#define IP_REASSEMBLY CONFIG_LWIP_IP_REASSEMBLY +#define IP_REASSEMBLY CONFIG_LWIP_IP4_REASSEMBLY /** - * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note + * LWIP_IPV6_REASS==1: reassemble incoming IP6 packets that fragmented. Note that + * this option does not affect outgoing packet sizes, which can be controlled + * via LWIP_IPV6_FRAG. + */ +#define LWIP_IPV6_REASS CONFIG_LWIP_IP6_REASSEMBLY + +/** + * IP_FRAG==1: Fragment outgoing IP4 packets if their size exceeds MTU. Note * that this option does not affect incoming packet sizes, which can be * controlled via IP_REASSEMBLY. */ -#define IP_FRAG CONFIG_LWIP_IP_FRAG +#define IP_FRAG CONFIG_LWIP_IP4_FRAG + +/** + * LWIP_IPV6_FRAG==1: Fragment outgoing IP6 packets if their size exceeds MTU. Note + * that this option does not affect incoming packet sizes, which can be + * controlled via IP_REASSEMBLY. + */ +#define LWIP_IPV6_FRAG CONFIG_LWIP_IP6_FRAG /** * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) @@ -376,6 +390,23 @@ #define TCP_RCV_SCALE CONFIG_TCP_RCV_SCALE #endif +/** + * LWIP_TCP_RTO_TIME: TCP rto time. + * Default is 3 second. + */ +#define LWIP_TCP_RTO_TIME CONFIG_LWIP_TCP_RTO_TIME + +/** + * Set TCP hook for Initial Sequence Number (ISN) + */ +#ifdef CONFIG_LWIP_TCP_ISN_HOOK +#include +struct ip_addr; +u32_t lwip_hook_tcp_isn(const struct ip_addr *local_ip, u16_t local_port, + const struct ip_addr *remote_ip, u16_t remote_port); +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#endif + /* ---------------------------------- ---------- Pbuf options ---------- @@ -671,6 +702,15 @@ */ #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 +/** + * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution. + */ +#define MEMP_NUM_ND6_QUEUE CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE + +/** + * LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache + */ +#define LWIP_ND6_NUM_NEIGHBORS CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS /* --------------------------------------- diff --git a/components/lwip/port/esp32/include/netdb.h b/components/lwip/port/esp32/include/netdb.h index 363154f68..7f5d67a46 100644 --- a/components/lwip/port/esp32/include/netdb.h +++ b/components/lwip/port/esp32/include/netdb.h @@ -32,9 +32,17 @@ #include "lwip/netdb.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifdef ESP_PLATFORM int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags); #endif + +#ifdef __cplusplus +} +#endif diff --git a/components/lwip/port/esp32/tcp_isn/tcp_isn.c b/components/lwip/port/esp32/tcp_isn/tcp_isn.c new file mode 100644 index 000000000..87fddbf1a --- /dev/null +++ b/components/lwip/port/esp32/tcp_isn/tcp_isn.c @@ -0,0 +1,186 @@ +/** + * @file + * + * Reference implementation of the TCP ISN algorithm standardized in RFC 6528. + * Produce TCP Initial Sequence Numbers by combining an MD5-generated hash + * based on the new TCP connection's identity and a stable secret, with the + * current time at 4-microsecond granularity. + * + * Specifically, the implementation uses MD5 to compute a hash of the input + * buffer, which contains both the four-tuple of the new TCP connection (local + * and remote IP address and port), as well as a 16-byte secret to make the + * results unpredictable to external parties. The secret must be given at + * initialization time and should ideally remain the same across system + * reboots. To be sure: the spoofing-resistance of the resulting ISN depends + * mainly on the strength of the supplied secret! + * + * The implementation takes 32 bits from the computed hash, and adds to it the + * current time, in 4-microsecond units. The current time is computed from a + * boot time given at initialization, and the current uptime as provided by + * sys_now(). Thus, it assumes that sys_now() returns a time value that is + * relative to the boot time, i.e., that it starts at 0 at system boot, and + * only ever increases monotonically. + * + * For efficiency reasons, a single MD5 input buffer is used, and partially + * filled in at initialization time. Specifically, of this 64-byte buffer, the + * first 36 bytes are used for the four-way TCP tuple data, followed by the + * 16-byte secret, followed by 12-byte zero padding. The 64-byte size of the + * buffer should achieve the best performance for the actual MD5 computation. + * + * Basic usage: + * + * 1. in your lwipopts.h, add the following lines: + * + * #include + * struct ip_addr; + * u32_t lwip_hook_tcp_isn(const struct ip_addr *local_ip, u16_t local_port, + * const struct ip_addr *remote_ip, u16_t remote_port); + * "#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn"; + * + * 2. from your own code, call lwip_init_tcp_isn() at initialization time, with + * appropriate parameters. + */ + +/* + * Copyright (c) 2016 The MINIX 3 Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: David van Moolenbroek + */ + +#include "tcp_isn.h" +#include "lwip/ip_addr.h" +#include "lwip/sys.h" +#include +#include "rom/md5_hash.h" +#include "soc/soc_memory_layout.h" + +#ifdef LWIP_HOOK_TCP_ISN + +static u8_t input[64]; +static u32_t base_time; + +/** + * Initialize the TCP ISN module, with the boot time and a secret. + * + * @param boot_time Wall clock boot time of the system, in seconds. + * @param secret_16_bytes A 16-byte secret used to randomize the TCP ISNs. + */ +void +lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes) +{ + /* Initialize the input buffer with the secret and trailing zeroes. */ + memset(input, 0, sizeof(input)); + + MEMCPY(&input[36], secret_16_bytes, 16); + + /* Save the boot time in 4-us units. Overflow is no problem here. */ + base_time = boot_time * 250000; +} + +/** + * Hook to generate an Initial Sequence Number (ISN) for a new TCP connection. + * + * @param local_ip The local IP address. + * @param local_port The local port number, in host-byte order. + * @param remote_ip The remote IP address. + * @param remote_port The remote port number, in host-byte order. + * @return The ISN to use for the new TCP connection. + */ +u32_t +lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port, + const ip_addr_t *remote_ip, u16_t remote_port) +{ + u8_t output[16]; + u32_t isn; + +#if LWIP_IPV4 && LWIP_IPV6 + if (IP_IS_V6(local_ip)) +#endif /* LWIP_IPV4 && LWIP_IPV6 */ +#if LWIP_IPV6 + { + const ip6_addr_t *local_ip6, *remote_ip6; + + local_ip6 = ip_2_ip6(local_ip); + remote_ip6 = ip_2_ip6(remote_ip); + + SMEMCPY(&input[0], &local_ip6->addr, 16); + SMEMCPY(&input[16], &remote_ip6->addr, 16); + } +#endif /* LWIP_IPV6 */ +#if LWIP_IPV4 && LWIP_IPV6 + else +#endif /* LWIP_IPV4 && LWIP_IPV6 */ +#if LWIP_IPV4 + { + const ip4_addr_t *local_ip4, *remote_ip4; + + local_ip4 = ip_2_ip4(local_ip); + remote_ip4 = ip_2_ip4(remote_ip); + + /* Represent IPv4 addresses as IPv4-mapped IPv6 addresses, to ensure that + * the IPv4 and IPv6 address spaces are completely disjoint. */ + memset(&input[0], 0, 10); + input[10] = 0xff; + input[11] = 0xff; + SMEMCPY(&input[12], &local_ip4->addr, 4); + memset(&input[16], 0, 10); + input[26] = 0xff; + input[27] = 0xff; + SMEMCPY(&input[28], &remote_ip4->addr, 4); + } +#endif /* LWIP_IPV4 */ + + input[32] = (u8_t)(local_port >> 8); + input[33] = (u8_t)(local_port & 0xff); + input[34] = (u8_t)(remote_port >> 8); + input[35] = (u8_t)(remote_port & 0xff); + + /* The secret and padding are already filled in. */ + + /* + * Generate the hash using ROM MD5 APIs + * This hook is invoked in the context of TCP/IP (tiT) task and + * it is unlikely that its stack would be placed in SPIRAM. Hence + * even with SPIRAM enabled case and ESP32 revision < 3, using ROM + * APIs should not create any issues. + */ +#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY + assert(!esp_ptr_external_ram(get_sp())); +#endif + + struct MD5Context ctx; + MD5Init(&ctx); + MD5Update(&ctx, input, sizeof(input)); + MD5Final(output, &ctx); + + /* Arbitrarily take the first 32 bits from the generated hash. */ + MEMCPY(&isn, output, sizeof(isn)); + + /* Add the current time in 4-microsecond units. */ + return isn + base_time + sys_now() * 250; +} + +#endif /* LWIP_HOOK_TCP_ISN */ diff --git a/components/lwip/port/esp32/tcp_isn/tcp_isn.h b/components/lwip/port/esp32/tcp_isn/tcp_isn.h new file mode 100644 index 000000000..a40c4a1ad --- /dev/null +++ b/components/lwip/port/esp32/tcp_isn/tcp_isn.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 The MINIX 3 Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: David van Moolenbroek + */ + +#ifndef LWIP_TCP_ISN_H +#define LWIP_TCP_ISN_H + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes); +u32_t lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port, + const ip_addr_t *remote_ip, u16_t remote_port); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TCP_ISN_H */ diff --git a/components/mbedtls/mbedtls b/components/mbedtls/mbedtls index 9ef92c551..90f46c8b1 160000 --- a/components/mbedtls/mbedtls +++ b/components/mbedtls/mbedtls @@ -1 +1 @@ -Subproject commit 9ef92c551eb8d92677034c3ec8078a8076febf41 +Subproject commit 90f46c8b17bc1219a82d4ddf81520d40c5ac5ebf diff --git a/components/mqtt/esp-mqtt b/components/mqtt/esp-mqtt index 6bc94add8..01594bf11 160000 --- a/components/mqtt/esp-mqtt +++ b/components/mqtt/esp-mqtt @@ -1 +1 @@ -Subproject commit 6bc94add892437d0fd50f26bfabe78c646648c13 +Subproject commit 01594bf118ae502b5a0ead040446f2be75d26223 diff --git a/components/newlib/lib/libc-psram-workaround.a b/components/newlib/lib/libc-psram-workaround.a index 27557575a..a0bbafd9a 100644 Binary files a/components/newlib/lib/libc-psram-workaround.a and b/components/newlib/lib/libc-psram-workaround.a differ diff --git a/components/newlib/lib/libg-psram-workaround.a b/components/newlib/lib/libg-psram-workaround.a index cddebee59..cc0c03aa3 100644 Binary files a/components/newlib/lib/libg-psram-workaround.a and b/components/newlib/lib/libg-psram-workaround.a differ diff --git a/components/newlib/lib/libm-psram-workaround.a b/components/newlib/lib/libm-psram-workaround.a index 74a876516..a361baa3e 100644 Binary files a/components/newlib/lib/libm-psram-workaround.a and b/components/newlib/lib/libm-psram-workaround.a differ diff --git a/components/newlib/pthread.c b/components/newlib/pthread.c index 71e50d9e5..c917a22ab 100644 --- a/components/newlib/pthread.c +++ b/components/newlib/pthread.c @@ -8,3 +8,8 @@ int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) ESP_LOGW(TAG, "%s: not yet supported!", __FUNCTION__); return 0; } + +int pthread_setcancelstate(int state, int *oldstate) +{ + return 0; +} diff --git a/components/nimble/esp-hci/src/esp_nimble_hci.c b/components/nimble/esp-hci/src/esp_nimble_hci.c index 92acaf6a0..3220c2271 100644 --- a/components/nimble/esp-hci/src/esp_nimble_hci.c +++ b/components/nimble/esp-hci/src/esp_nimble_hci.c @@ -341,6 +341,13 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len) totlen = BLE_HCI_EVENT_HDR_LEN + data[2]; assert(totlen <= UINT8_MAX + BLE_HCI_EVENT_HDR_LEN); + if (totlen > MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)) { + ESP_LOGE(TAG, "Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).", + totlen, MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE)); + ble_hs_sched_reset(BLE_HS_ECONTROLLER); + return 0; + } + if (data[1] == BLE_HCI_EVCODE_HW_ERROR) { assert(0); } diff --git a/components/nimble/nimble b/components/nimble/nimble index a9239c6ca..e7f0c530b 160000 --- a/components/nimble/nimble +++ b/components/nimble/nimble @@ -1 +1 @@ -Subproject commit a9239c6ca5e8f6dc72792ac716a8fe3ffad08b1e +Subproject commit e7f0c530b6816e156292163f7d07b7375292a1af diff --git a/components/nvs_flash/src/nvs_api.cpp b/components/nvs_flash/src/nvs_api.cpp index e993c9637..f6cf33d5e 100644 --- a/components/nvs_flash/src/nvs_api.cpp +++ b/components/nvs_flash/src/nvs_api.cpp @@ -105,7 +105,10 @@ extern "C" esp_err_t nvs_flash_init_custom(const char *partName, uint32_t baseSe nvs::Storage* new_storage = NULL; nvs::Storage* storage = lookup_storage_from_name(partName); if (storage == NULL) { - new_storage = new nvs::Storage((const char *)partName); + new_storage = new (std::nothrow) nvs::Storage((const char *)partName); + + if (!new_storage) return ESP_ERR_NO_MEM; + storage = new_storage; } @@ -127,6 +130,9 @@ extern "C" esp_err_t nvs_flash_secure_init_custom(const char *partName, uint32_t if(cfg) { auto encrMgr = EncrMgr::getInstance(); + + if (!encrMgr) return ESP_ERR_NO_MEM; + auto err = encrMgr->setSecurityContext(baseSector, sectorCount, cfg); if(err != ESP_OK) { return err; @@ -282,7 +288,10 @@ extern "C" esp_err_t nvs_open_from_partition(const char *part_name, const char* return err; } - HandleEntry *handle_entry = new HandleEntry(open_mode==NVS_READONLY, nsIndex, sHandle); + HandleEntry *handle_entry = new (std::nothrow) HandleEntry(open_mode==NVS_READONLY, nsIndex, sHandle); + + if (!handle_entry) return ESP_ERR_NO_MEM; + s_nvs_handles.push_back(handle_entry); *out_handle = handle_entry->mHandle; diff --git a/components/nvs_flash/src/nvs_encr.cpp b/components/nvs_flash/src/nvs_encr.cpp index 6f0b46cf9..c33a59547 100644 --- a/components/nvs_flash/src/nvs_encr.cpp +++ b/components/nvs_flash/src/nvs_encr.cpp @@ -27,8 +27,10 @@ namespace nvs { if(!isActive) { - instance = new EncrMgr(); - isActive = true; + instance = new (std::nothrow) EncrMgr(); + if (instance) { + isActive = true; + } } return instance; } @@ -62,7 +64,9 @@ namespace nvs uint8_t* eky = reinterpret_cast(cfg); - auto ctxt = new XtsCtxt(); + auto ctxt = new (std::nothrow) XtsCtxt(); + + if (!ctxt) return ESP_ERR_NO_MEM; ctxt->baseSector = baseSector; ctxt->sectorCount = sectorCount; diff --git a/components/nvs_flash/src/nvs_item_hash_list.cpp b/components/nvs_flash/src/nvs_item_hash_list.cpp index a6cfdac1e..7e1c1241a 100644 --- a/components/nvs_flash/src/nvs_item_hash_list.cpp +++ b/components/nvs_flash/src/nvs_item_hash_list.cpp @@ -20,7 +20,7 @@ namespace nvs HashList::HashList() { } - + void HashList::clear() { for (auto it = mBlockList.begin(); it != mBlockList.end();) { @@ -30,7 +30,7 @@ void HashList::clear() delete static_cast(tmp); } } - + HashList::~HashList() { clear(); @@ -42,7 +42,7 @@ HashList::HashListBlock::HashListBlock() "cache block size calculation incorrect"); } -void HashList::insert(const Item& item, size_t index) +esp_err_t HashList::insert(const Item& item, size_t index) { const uint32_t hash_24 = item.calculateCrc32WithoutValue() & 0xffffff; // add entry to the end of last block if possible @@ -50,14 +50,19 @@ void HashList::insert(const Item& item, size_t index) auto& block = mBlockList.back(); if (block.mCount < HashListBlock::ENTRY_COUNT) { block.mNodes[block.mCount++] = HashListNode(hash_24, index); - return; + return ESP_OK; } } // if the above failed, create a new block and add entry to it - HashListBlock* newBlock = new HashListBlock; + HashListBlock* newBlock = new (std::nothrow) HashListBlock; + + if (!newBlock) return ESP_ERR_NO_MEM; + mBlockList.push_back(newBlock); newBlock->mNodes[0] = HashListNode(hash_24, index); newBlock->mCount++; + + return ESP_OK; } void HashList::erase(size_t index, bool itemShouldExist) diff --git a/components/nvs_flash/src/nvs_item_hash_list.hpp b/components/nvs_flash/src/nvs_item_hash_list.hpp index e759cd818..ca21c92c1 100644 --- a/components/nvs_flash/src/nvs_item_hash_list.hpp +++ b/components/nvs_flash/src/nvs_item_hash_list.hpp @@ -27,16 +27,16 @@ class HashList public: HashList(); ~HashList(); - - void insert(const Item& item, size_t index); + + esp_err_t insert(const Item& item, size_t index); void erase(const size_t index, bool itemShouldExist=true); size_t find(size_t start, const Item& item); void clear(); - + private: HashList(const HashList& other); const HashList& operator= (const HashList& rhs); - + protected: struct HashListNode { diff --git a/components/nvs_flash/src/nvs_ops.cpp b/components/nvs_flash/src/nvs_ops.cpp index 1ee32befc..4dfcc9c11 100644 --- a/components/nvs_flash/src/nvs_ops.cpp +++ b/components/nvs_flash/src/nvs_ops.cpp @@ -26,6 +26,9 @@ esp_err_t nvs_flash_write(size_t destAddr, const void *srcAddr, size_t size) { if(EncrMgr::isEncrActive()) { auto encrMgr = EncrMgr::getInstance(); + + if (!encrMgr) return ESP_ERR_NO_MEM; + auto xtsCtxt = encrMgr->findXtsCtxtFromAddr(destAddr); if(xtsCtxt) { @@ -44,7 +47,7 @@ esp_err_t nvs_flash_write(size_t destAddr, const void *srcAddr, size_t size) { } esp_err_t nvs_flash_read(size_t srcAddr, void *destAddr, size_t size) { - + auto err = spi_flash_read(srcAddr, destAddr, size); if(err != ESP_OK) { @@ -53,6 +56,9 @@ esp_err_t nvs_flash_read(size_t srcAddr, void *destAddr, size_t size) { if(EncrMgr::isEncrActive()) { auto encrMgr = EncrMgr::getInstance(); + + if (!encrMgr) return ESP_ERR_NO_MEM; + auto xtsCtxt = encrMgr->findXtsCtxtFromAddr(srcAddr); if(xtsCtxt) { return encrMgr->decryptNvsData(static_cast(destAddr), diff --git a/components/nvs_flash/src/nvs_page.cpp b/components/nvs_flash/src/nvs_page.cpp index e0bda34c5..821668c18 100644 --- a/components/nvs_flash/src/nvs_page.cpp +++ b/components/nvs_flash/src/nvs_page.cpp @@ -49,7 +49,10 @@ esp_err_t Page::load(uint32_t sectorNumber) // check if the whole page is really empty // reading the whole page takes ~40 times less than erasing it const int BLOCK_SIZE = 128; - uint32_t* block = new uint32_t[BLOCK_SIZE]; + uint32_t* block = new (std::nothrow) uint32_t[BLOCK_SIZE]; + + if (!block) return ESP_ERR_NO_MEM; + for (uint32_t i = 0; i < SPI_FLASH_SEC_SIZE; i += 4 * BLOCK_SIZE) { rc = spi_flash_read(mBaseAddress + i, block, 4 * BLOCK_SIZE); if (rc != ESP_OK) { @@ -215,7 +218,11 @@ esp_err_t Page::writeItem(uint8_t nsIndex, ItemType datatype, const char* key, c // write first item size_t span = (totalSize + ENTRY_SIZE - 1) / ENTRY_SIZE; item = Item(nsIndex, datatype, span, key, chunkIdx); - mHashList.insert(item, mNextFreeEntry); + err = mHashList.insert(item, mNextFreeEntry); + + if (err != ESP_OK) { + return err; + } if (!isVariableLengthType(datatype)) { memcpy(item.data, data, dataSize); @@ -426,7 +433,11 @@ esp_err_t Page::copyItems(Page& other) return err; } - other.mHashList.insert(entry, other.mNextFreeEntry); + err = other.mHashList.insert(entry, other.mNextFreeEntry); + if (err != ESP_OK) { + return err; + } + err = other.writeEntry(entry); if (err != ESP_OK) { return err; @@ -549,7 +560,11 @@ esp_err_t Page::mLoadEntryTable() continue; } - mHashList.insert(item, i); + err = mHashList.insert(item, i); + if (err != ESP_OK) { + mState = PageState::INVALID; + return err; + } // search for potential duplicate item size_t duplicateIndex = mHashList.find(0, item); @@ -619,7 +634,11 @@ esp_err_t Page::mLoadEntryTable() assert(item.span > 0); - mHashList.insert(item, i); + err = mHashList.insert(item, i); + if (err != ESP_OK) { + mState = PageState::INVALID; + return err; + } size_t span = item.span; diff --git a/components/nvs_flash/src/nvs_pagemanager.cpp b/components/nvs_flash/src/nvs_pagemanager.cpp index 58d9e47f4..f33a24e97 100644 --- a/components/nvs_flash/src/nvs_pagemanager.cpp +++ b/components/nvs_flash/src/nvs_pagemanager.cpp @@ -21,7 +21,9 @@ esp_err_t PageManager::load(uint32_t baseSector, uint32_t sectorCount) mPageCount = sectorCount; mPageList.clear(); mFreePageList.clear(); - mPages.reset(new Page[sectorCount]); + mPages.reset(new (std::nothrow) Page[sectorCount]); + + if (!mPages) return ESP_ERR_NO_MEM; for (uint32_t i = 0; i < sectorCount; ++i) { auto err = mPages[i].load(baseSector + i); @@ -85,7 +87,7 @@ esp_err_t PageManager::load(uint32_t baseSector, uint32_t sectorCount) break; } } - } + } } // check if power went out while page was being freed diff --git a/components/nvs_flash/src/nvs_storage.cpp b/components/nvs_flash/src/nvs_storage.cpp index be92da072..7eae18feb 100644 --- a/components/nvs_flash/src/nvs_storage.cpp +++ b/components/nvs_flash/src/nvs_storage.cpp @@ -31,7 +31,7 @@ void Storage::clearNamespaces() mNamespaces.clearAndFreeNodes(); } -void Storage::populateBlobIndices(TBlobIndexList& blobIdxList) +esp_err_t Storage::populateBlobIndices(TBlobIndexList& blobIdxList) { for (auto it = mPageManager.begin(); it != mPageManager.end(); ++it) { Page& p = *it; @@ -43,7 +43,9 @@ void Storage::populateBlobIndices(TBlobIndexList& blobIdxList) * duplicate index at this point */ while (p.findItem(Page::NS_ANY, ItemType::BLOB_IDX, nullptr, itemIndex, item) == ESP_OK) { - BlobIndexNode* entry = new BlobIndexNode; + BlobIndexNode* entry = new (std::nothrow) BlobIndexNode; + + if (!entry) return ESP_ERR_NO_MEM; item.getKey(entry->key, sizeof(entry->key) - 1); entry->nsIndex = item.nsIndex; @@ -54,6 +56,8 @@ void Storage::populateBlobIndices(TBlobIndexList& blobIdxList) itemIndex += item.span; } } + + return ESP_OK; } void Storage::eraseOrphanDataBlobs(TBlobIndexList& blobIdxList) @@ -100,7 +104,13 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount) size_t itemIndex = 0; Item item; while (p.findItem(Page::NS_INDEX, ItemType::U8, nullptr, itemIndex, item) == ESP_OK) { - NamespaceEntry* entry = new NamespaceEntry; + NamespaceEntry* entry = new (std::nothrow) NamespaceEntry; + + if (!entry) { + mState = StorageState::INVALID; + return ESP_ERR_NO_MEM; + } + item.getKey(entry->mName, sizeof(entry->mName) - 1); item.getValue(entry->mIndex); mNamespaces.push_back(entry); @@ -114,7 +124,11 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount) // Populate list of multi-page index entries. TBlobIndexList blobIdxList; - populateBlobIndices(blobIdxList); + err = populateBlobIndices(blobIdxList); + if (err != ESP_OK) { + mState = StorageState::INVALID; + return ESP_ERR_NO_MEM; + } // Remove the entries for which there is no parent multi-page index. eraseOrphanDataBlobs(blobIdxList); @@ -182,7 +196,7 @@ esp_err_t Storage::writeMultiPageBlob(uint8_t nsIndex, const char* key, const vo return err; } else if(getCurrentPage().getVarDataTailroom() == tailroom) { /* We got the same page or we are not improving.*/ - return ESP_ERR_NVS_NOT_ENOUGH_SPACE; + return ESP_ERR_NVS_NOT_ENOUGH_SPACE; } else { continue; } @@ -203,7 +217,11 @@ esp_err_t Storage::writeMultiPageBlob(uint8_t nsIndex, const char* key, const vo if (err != ESP_OK) { break; } else { - UsedPageNode* node = new UsedPageNode(); + UsedPageNode* node = new (std::nothrow) UsedPageNode(); + if (!node) { + err = ESP_ERR_NO_MEM; + break; + } node->mPage = &page; usedPages.push_back(node); if (remainingSize || (tailroom - chunkSize) < Page::ENTRY_SIZE) { @@ -301,9 +319,9 @@ esp_err_t Storage::writeItem(uint8_t nsIndex, ItemType datatype, const char* key if (err != ESP_OK) { return err; } - + findPage = nullptr; - } else { + } else { /* Support for earlier versions where BLOBS were stored without index */ err = findItem(nsIndex, datatype, key, findPage, item); if (err != ESP_OK && err != ESP_ERR_NVS_NOT_FOUND) { @@ -381,6 +399,11 @@ esp_err_t Storage::createOrOpenNamespace(const char* nsName, bool canCreate, uin return ESP_ERR_NVS_NOT_ENOUGH_SPACE; } + NamespaceEntry* entry = new (std::nothrow) NamespaceEntry; + if (!entry) { + return ESP_ERR_NO_MEM; + } + auto err = writeItem(Page::NS_INDEX, ItemType::U8, nsName, &ns, sizeof(ns)); if (err != ESP_OK) { return err; @@ -388,7 +411,6 @@ esp_err_t Storage::createOrOpenNamespace(const char* nsName, bool canCreate, uin mNamespaceUsage.set(ns, true); nsIndex = ns; - NamespaceEntry* entry = new NamespaceEntry; entry->mIndex = ns; strncpy(entry->mName, nsName, sizeof(entry->mName) - 1); entry->mName[sizeof(entry->mName) - 1] = 0; @@ -456,14 +478,14 @@ esp_err_t Storage::readItem(uint8_t nsIndex, ItemType datatype, const char* key, if (err != ESP_ERR_NVS_NOT_FOUND) { return err; } // else check if the blob is stored with earlier version format without index - } + } auto err = findItem(nsIndex, datatype, key, findPage, item); if (err != ESP_OK) { return err; } return findPage->readItem(nsIndex, datatype, key, data, dataSize); - + } esp_err_t Storage::eraseMultiPageBlob(uint8_t nsIndex, const char* key, VerOffset chunkStart) diff --git a/components/nvs_flash/src/nvs_storage.hpp b/components/nvs_flash/src/nvs_storage.hpp index 3a79e705c..add5cca7c 100644 --- a/components/nvs_flash/src/nvs_storage.hpp +++ b/components/nvs_flash/src/nvs_storage.hpp @@ -128,7 +128,7 @@ protected: void clearNamespaces(); - void populateBlobIndices(TBlobIndexList&); + esp_err_t populateBlobIndices(TBlobIndexList&); void eraseOrphanDataBlobs(TBlobIndexList&); diff --git a/components/openssl/platform/ssl_pm.c b/components/openssl/platform/ssl_pm.c index 1448faa4e..5a6f1981c 100644 --- a/components/openssl/platform/ssl_pm.c +++ b/components/openssl/platform/ssl_pm.c @@ -213,21 +213,36 @@ void ssl_pm_free(SSL *ssl) static int ssl_pm_reload_crt(SSL *ssl) { int ret; - int mode; + int mode = MBEDTLS_SSL_VERIFY_UNSET; struct ssl_pm *ssl_pm = ssl->ssl_pm; struct x509_pm *ca_pm = (struct x509_pm *)ssl->client_CA->x509_pm; struct pkey_pm *pkey_pm = (struct pkey_pm *)ssl->cert->pkey->pkey_pm; struct x509_pm *crt_pm = (struct x509_pm *)ssl->cert->x509->x509_pm; - if (ssl->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) - mode = MBEDTLS_SSL_VERIFY_REQUIRED; - else if (ssl->verify_mode & SSL_VERIFY_PEER) - mode = MBEDTLS_SSL_VERIFY_OPTIONAL; - else if (ssl->verify_mode & SSL_VERIFY_CLIENT_ONCE) - mode = MBEDTLS_SSL_VERIFY_UNSET; - else - mode = MBEDTLS_SSL_VERIFY_NONE; +/* OpenSSL verification modes outline (see `man SSL_set_verify` for more details) + * + * | openssl mode | Server | Client | + * | SSL_VERIFY_NONE | will not send a client certificate request | server certificate which will be checked | + * handshake will be continued regardless | + * | SSL_VERIFY_PEER | depends on SSL_VERIFY_FAIL_IF_NO_PEER_CERT | handshake is terminated if verify fails | + * (unless anonymous ciphers--not supported | + * | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | handshake is terminated if | ignored | + * client cert verify fails | | + */ + if (ssl->method->endpoint == MBEDTLS_SSL_IS_SERVER) { + if (ssl->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) + mode = MBEDTLS_SSL_VERIFY_REQUIRED; + else if (ssl->verify_mode & SSL_VERIFY_PEER) + mode = MBEDTLS_SSL_VERIFY_OPTIONAL; + else if (ssl->verify_mode == SSL_VERIFY_NONE) + mode = MBEDTLS_SSL_VERIFY_NONE; + } else if (ssl->method->endpoint == MBEDTLS_SSL_IS_CLIENT) { + if (ssl->verify_mode & SSL_VERIFY_PEER) + mode = MBEDTLS_SSL_VERIFY_REQUIRED; + else if (ssl->verify_mode == SSL_VERIFY_NONE) + mode = MBEDTLS_SSL_VERIFY_NONE; + } mbedtls_ssl_conf_authmode(&ssl_pm->conf, mode); diff --git a/components/partition_table/CMakeLists.txt b/components/partition_table/CMakeLists.txt index 492dfb810..11fef65f0 100644 --- a/components/partition_table/CMakeLists.txt +++ b/components/partition_table/CMakeLists.txt @@ -49,7 +49,14 @@ if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) endif() if(EXISTS ${partition_csv}) - add_custom_target(partition_table ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}") + add_custom_target(partition_table ALL DEPENDS "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${final_partition_bin}" + COMMAND ${CMAKE_COMMAND} -E echo "Partition table binary generated. Contents:" + COMMAND ${CMAKE_COMMAND} -E echo "*******************************************************************************" + COMMAND COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" + -q --offset ${PARTITION_TABLE_OFFSET} ${md5_opt} ${flashsize_opt} + ${partition_secure_opt} "${IDF_BUILD_ARTIFACTS_DIR}/partition_table/${unsigned_partition_bin}" + COMMAND ${CMAKE_COMMAND} -E echo "*******************************************************************************" + VERBATIM) else() # If the partition input CSV is not found, create a phony partition_table target that # fails the build. fail_at_build_time also touches CMakeCache.txt to cause a cmake run next time diff --git a/components/protocomm/src/transports/protocomm_ble.c b/components/protocomm/src/transports/protocomm_ble.c index 3b5161fdb..802439ea9 100644 --- a/components/protocomm/src/transports/protocomm_ble.c +++ b/components/protocomm/src/transports/protocomm_ble.c @@ -108,28 +108,39 @@ static void transport_simple_ble_read(esp_gatts_cb_event_t event, esp_gatt_if_t { static const uint8_t *read_buf = NULL; static uint16_t read_len = 0; + static uint16_t max_read_len = 0; esp_gatt_status_t status = ESP_OK; ESP_LOGD(TAG, "Inside read w/ session - %d on param %d %d", param->read.conn_id, param->read.handle, read_len); if (!read_len && !param->read.offset) { ESP_LOGD(TAG, "Reading attr value first time"); - status = esp_ble_gatts_get_attr_value(param->read.handle, &read_len, &read_buf); + status = esp_ble_gatts_get_attr_value(param->read.handle, &read_len, &read_buf); + max_read_len = read_len; + } else if ((read_len + param->read.offset) > max_read_len) { + status = ESP_GATT_INVALID_OFFSET; } else { ESP_LOGD(TAG, "Subsequent read request for attr value"); } esp_gatt_rsp_t gatt_rsp = {0}; - gatt_rsp.attr_value.len = MIN(read_len, (protoble_internal->gatt_mtu - 1)); gatt_rsp.attr_value.handle = param->read.handle; gatt_rsp.attr_value.offset = param->read.offset; - gatt_rsp.attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE; - if (gatt_rsp.attr_value.len && read_buf) { - memcpy(gatt_rsp.attr_value.value, - read_buf + param->read.offset, - gatt_rsp.attr_value.len); + + if (status == ESP_GATT_OK) { + gatt_rsp.attr_value.len = MIN(read_len, (protoble_internal->gatt_mtu - 1)); + gatt_rsp.attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE; + if (gatt_rsp.attr_value.len && read_buf) { + memcpy(gatt_rsp.attr_value.value, + read_buf + param->read.offset, + gatt_rsp.attr_value.len); + } + read_len -= gatt_rsp.attr_value.len; + } else { + read_len = 0; + max_read_len = 0; + read_buf = NULL; } - read_len -= gatt_rsp.attr_value.len; esp_err_t err = esp_ble_gatts_send_response(gatts_if, param->read.conn_id, param->read.trans_id, status, &gatt_rsp); if (err != ESP_OK) { diff --git a/components/protocomm/src/transports/protocomm_httpd.c b/components/protocomm/src/transports/protocomm_httpd.c index 1a20c4442..22be22c20 100644 --- a/components/protocomm/src/transports/protocomm_httpd.c +++ b/components/protocomm/src/transports/protocomm_httpd.c @@ -31,6 +31,17 @@ static uint32_t session_id = PROTOCOMM_NO_SESSION_ID; #define MAX_REQ_BODY_LEN 4096 +static void protocomm_httpd_session_close(void *ctx) +{ + if (pc_httpd->sec && pc_httpd->sec->close_transport_session) { + ESP_LOGW(TAG, "Closing session as socket %d was closed", session_id); + if (pc_httpd->sec->close_transport_session(session_id) != ESP_OK) { + ESP_LOGW(TAG, "Error closing session with ID: %d", session_id); + } + } + session_id = PROTOCOMM_NO_SESSION_ID; +} + static esp_err_t common_post_handler(httpd_req_t *req) { esp_err_t ret; @@ -42,6 +53,7 @@ static esp_err_t common_post_handler(httpd_req_t *req) int cur_session_id = httpd_req_to_sockfd(req); if (cur_session_id != session_id) { + ESP_LOGI(TAG, "Creating new session: %d", cur_session_id); /* Initialize new security session */ if (session_id != PROTOCOMM_NO_SESSION_ID) { ESP_LOGD(TAG, "Closing session with ID: %d", session_id); @@ -62,6 +74,8 @@ static esp_err_t common_post_handler(httpd_req_t *req) ret = ESP_FAIL; goto out; } + req->free_ctx = protocomm_httpd_session_close; + } session_id = cur_session_id; ESP_LOGD(TAG, "New session with ID: %d", cur_session_id); diff --git a/components/sdmmc/sdmmc_sd.c b/components/sdmmc/sdmmc_sd.c index 8d6323996..2634aa081 100644 --- a/components/sdmmc/sdmmc_sd.c +++ b/components/sdmmc/sdmmc_sd.c @@ -225,24 +225,29 @@ esp_err_t sdmmc_enable_hs_mode_and_check(sdmmc_card_t* card) /* HS mode has been enabled on the card. * Read CSD again, it should now indicate that the card supports * 50MHz clock. - * Since SEND_CSD is allowed only in standby mode, and the card is - * currently in data transfer more, deselect the card first, then - * get the CSD, then select the card again. + * Since SEND_CSD is allowed only in standby mode, and the card is currently in data transfer + * mode, deselect the card first, then get the CSD, then select the card again. This step is + * not required in SPI mode, since CMD7 (select_card) is not supported. */ - err = sdmmc_send_cmd_select_card(card, 0); - if (err != ESP_OK) { - ESP_LOGE(TAG, "%s: select_card (1) returned 0x%x", __func__, err); - return err; + const bool is_spi = host_is_spi(card); + if (!is_spi) { + err = sdmmc_send_cmd_select_card(card, 0); + if (err != ESP_OK) { + ESP_LOGE(TAG, "%s: select_card (1) returned 0x%x", __func__, err); + return err; + } } err = sdmmc_send_cmd_send_csd(card, &card->csd); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: send_csd returned 0x%x", __func__, err); return err; } - err = sdmmc_send_cmd_select_card(card, card->rca); - if (err != ESP_OK) { - ESP_LOGE(TAG, "%s: select_card (2) returned 0x%x", __func__, err); - return err; + if (!is_spi) { + err = sdmmc_send_cmd_select_card(card, card->rca); + if (err != ESP_OK) { + ESP_LOGE(TAG, "%s: select_card (2) returned 0x%x", __func__, err); + return err; + } } if (card->csd.tr_speed != 50000000) { diff --git a/components/sdmmc/test/test_sd.c b/components/sdmmc/test/test_sd.c index ea0a144f3..c64fde377 100644 --- a/components/sdmmc/test/test_sd.c +++ b/components/sdmmc/test/test_sd.c @@ -320,6 +320,8 @@ TEST_CASE("SDMMC read/write test (SD slot 1, in SPI mode)", "[sdspi][test_env=UT sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT(); TEST_ESP_OK(sdspi_host_init()); TEST_ESP_OK(sdspi_host_init_slot(config.slot, &slot_config)); + // This test can only run under 20MHz on ESP32, because the runner connects the card to + // non-IOMUX pins of HSPI. sdmmc_card_t* card = malloc(sizeof(sdmmc_card_t)); TEST_ASSERT_NOT_NULL(card); TEST_ESP_OK(sdmmc_card_init(&config, card)); diff --git a/components/spi_flash/flash_mmap.c b/components/spi_flash/flash_mmap.c index 534a7e3d3..b3ccf301e 100644 --- a/components/spi_flash/flash_mmap.c +++ b/components/spi_flash/flash_mmap.c @@ -157,6 +157,7 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp uint32_t region_addr; // base address of memory region get_mmu_region(memory,®ion_begin,®ion_size,®ion_addr); if (region_size < page_count) { + spi_flash_enable_interrupts_caches_and_other_cpu(); return ESP_ERR_NO_MEM; } // The following part searches for a range of MMU entries which can be used. diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index b535e8008..420399269 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -71,6 +71,7 @@ static spi_flash_counters_t s_flash_stats; static esp_err_t spi_flash_translate_rc(esp_rom_spiflash_result_t rc); static bool is_safe_write_address(size_t addr, size_t size); +static void spi_flash_os_yield(void); const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_default_ops = { .start = spi_flash_disable_interrupts_caches_and_other_cpu, @@ -78,18 +79,20 @@ const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_default_ops = { .op_lock = spi_flash_op_lock, .op_unlock = spi_flash_op_unlock, #if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED - .is_safe_write_address = is_safe_write_address + .is_safe_write_address = is_safe_write_address, #endif + .yield = spi_flash_os_yield, }; const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_no_os_ops = { .start = spi_flash_disable_interrupts_caches_and_other_cpu_no_os, .end = spi_flash_enable_interrupts_caches_no_os, - .op_lock = 0, - .op_unlock = 0, + .op_lock = NULL, + .op_unlock = NULL, #if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED - .is_safe_write_address = 0 + .is_safe_write_address = NULL, #endif + .yield = NULL, }; static const spi_flash_guard_funcs_t *s_flash_guard_ops; @@ -184,6 +187,13 @@ static inline void IRAM_ATTR spi_flash_guard_op_unlock() } } +static void IRAM_ATTR spi_flash_os_yield(void) +{ +#ifdef CONFIG_SPI_FLASH_YIELD_DURING_ERASE + vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); +#endif +} + static esp_rom_spiflash_result_t IRAM_ATTR spi_flash_unlock() { static bool unlocked = false; @@ -246,8 +256,10 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(uint32_t start_addr, uint32_t size) /* For example when dt_ms = 15 and CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS = 20. * In this case we need to call vTaskDelay because * the duration of this command + the next command probably will exceed more than 20. - */ - vTaskDelay(CONFIG_SPI_FLASH_ERASE_YIELD_TICKS); + */ + if (s_flash_guard_ops && s_flash_guard_ops->yield) { + s_flash_guard_ops->yield(); + } } #endif } diff --git a/components/spi_flash/include/esp_spi_flash.h b/components/spi_flash/include/esp_spi_flash.h index 254e40895..ddcbbf620 100644 --- a/components/spi_flash/include/esp_spi_flash.h +++ b/components/spi_flash/include/esp_spi_flash.h @@ -317,6 +317,10 @@ typedef void (*spi_flash_op_unlock_func_t)(void); * @brief Function to protect SPI flash critical regions corruption. */ typedef bool (*spi_flash_is_safe_write_address_t)(size_t addr, size_t size); +/** + * @brief Function to yield to the OS during erase operation. + */ +typedef void (*spi_flash_os_yield_t)(void); /** * Structure holding SPI flash access critical sections management functions. @@ -357,6 +361,7 @@ typedef struct { #if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED spi_flash_is_safe_write_address_t is_safe_write_address; /**< checks flash write addresses.*/ #endif + spi_flash_os_yield_t yield; /**< yield to the OS during flash erase */ } spi_flash_guard_funcs_t; /** diff --git a/components/spi_flash/test/test_mmap.c b/components/spi_flash/test/test_mmap.c index 4cdb77594..8d17fa3ac 100644 --- a/components/spi_flash/test/test_mmap.c +++ b/components/spi_flash/test/test_mmap.c @@ -299,9 +299,8 @@ TEST_CASE("flash_mmap can mmap after get enough free MMU pages", "[spi_flash]") } } uint32_t free_pages = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA); - if (spi_flash_get_chip_size() <= 0x200000) { - free_pages -= 0x200000/0x10000; - } + uint32_t flash_pages = spi_flash_get_chip_size() / SPI_FLASH_MMU_PAGE_SIZE; + free_pages = (free_pages > flash_pages) ? flash_pages : free_pages; printf("Mapping %x (+%x)\n", 0, free_pages * SPI_FLASH_MMU_PAGE_SIZE); const void *ptr2; diff --git a/components/spi_flash/test/test_partitions.c b/components/spi_flash/test/test_partitions.c index d859d3dd2..d280f2625 100644 --- a/components/spi_flash/test/test_partitions.c +++ b/components/spi_flash/test/test_partitions.c @@ -24,6 +24,7 @@ #include #include #include +#include "esp_log.h" TEST_CASE("Test erase partition", "[spi_flash]") { @@ -66,3 +67,27 @@ TEST_CASE("Test erase partition", "[spi_flash]") } } } + +TEST_CASE("Test esp_partition_get_sha256() that it can handle a big partition", "[spi_flash]") +{ + esp_partition_t partition; + const void *ptr; + spi_flash_mmap_handle_t handle; + + uint8_t sha256[32] = { 0 }; + size_t size_flash_chip = spi_flash_get_chip_size(); + + printf("size_flash_chip = %d bytes\n", size_flash_chip); + + ESP_ERROR_CHECK(spi_flash_mmap(0x00000000, size_flash_chip * 7 / 10, SPI_FLASH_MMAP_DATA, &ptr, &handle)); + TEST_ASSERT_NOT_NULL(ptr); + + partition.address = 0x00000000; + partition.size = size_flash_chip; + partition.type = ESP_PARTITION_TYPE_DATA; + + ESP_ERROR_CHECK(esp_partition_get_sha256(&partition, sha256)); + ESP_LOG_BUFFER_HEX("sha", sha256, sizeof(sha256)); + + spi_flash_munmap(handle); +} diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 1fa912fc9..03f9bfb64 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -33,6 +33,10 @@ #include "netif/wlanif.h" #include "netif/ethernetif.h" +#if CONFIG_LWIP_TCP_ISN_HOOK +#include "tcp_isn.h" +#endif + #include "dhcpserver/dhcpserver.h" #include "dhcpserver/dhcpserver_options.h" @@ -102,6 +106,18 @@ void tcpip_adapter_init(void) int ret; if (tcpip_inited == false) { +#if CONFIG_LWIP_TCP_ISN_HOOK + uint8_t rand_buf[16]; + /* + * This is early startup code where WiFi/BT is yet to be enabled and hence + * relevant entropy source is not available. However, bootloader enables + * SAR ADC based entropy source at its initialization, and our requirement + * of random bytes is pretty small (16), so we can assume that following + * API will provide sufficiently random data. + */ + esp_fill_random(rand_buf, sizeof(rand_buf)); + lwip_init_tcp_isn(esp_log_timestamp(), rand_buf); +#endif tcpip_inited = true; tcpip_init(NULL, NULL); @@ -327,6 +343,7 @@ esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if) for(int8_t i = 0 ;i < LWIP_IPV6_NUM_ADDRESSES ;i++) { netif_ip6_addr_set(esp_netif[tcpip_if] ,i ,IP6_ADDR_ANY6); + netif_ip6_addr_set_state(esp_netif[tcpip_if], i, IP6_ADDR_INVALID); } netif_set_addr(esp_netif[tcpip_if], IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); netif_set_down(esp_netif[tcpip_if]); diff --git a/components/ulp/cmake/CMakeLists.txt b/components/ulp/cmake/CMakeLists.txt index 49654e84f..e105a267b 100644 --- a/components/ulp/cmake/CMakeLists.txt +++ b/components/ulp/cmake/CMakeLists.txt @@ -11,7 +11,7 @@ execute_process( OUTPUT_VARIABLE as_output ERROR_QUIET) -string(REGEX MATCH "GNU assembler \\(GNU Binutils\\) (${version_pattern})" as_version ${as_output}) +string(REGEX MATCH "\\(GNU Binutils\\) (${version_pattern})" as_version ${as_output}) set(as_version ${CMAKE_MATCH_1}) message(STATUS "Building ULP app ${ULP_APP_NAME}") @@ -100,4 +100,4 @@ add_custom_target(build ${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.h WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(${ULP_APP_NAME} -T${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT} -Map=${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.map) \ No newline at end of file +target_link_libraries(${ULP_APP_NAME} -T${CMAKE_CURRENT_BINARY_DIR}/${ULP_LD_SCRIPT} -Map=${CMAKE_CURRENT_BINARY_DIR}/${ULP_APP_NAME}.map) diff --git a/components/ulp/component_ulp_common.mk b/components/ulp/component_ulp_common.mk index a4174d1e1..cf6292998 100644 --- a/components/ulp/component_ulp_common.mk +++ b/components/ulp/component_ulp_common.mk @@ -26,7 +26,10 @@ ULP_PREPROCESSOR_ARGS := \ # Check the assembler version include $(IDF_PATH)/components/ulp/toolchain_ulp_version.mk -ULP_AS_VER := $(shell $(ULP_AS) --version | sed -E -n 's|GNU assembler \(GNU Binutils\) ([a-z0-9\.-]+)|\1|gp') +# $(ULP_AS) --version output might be localized, for example the first line could be +# "Ensamblador (GNU Binutils) 2.28.51-esp-20191205 de GNU" instead of +# "GNU assembler (GNU Binutils) 2.28.51-esp-20191205". +ULP_AS_VER := $(shell $(ULP_AS) --version | sed -E -n 's/.+ \(GNU Binutils\) ([a-z0-9\.-]+)( .*)?/\1/gp') $(info Building ULP app $(ULP_APP_NAME)) $(info ULP assembler version: $(ULP_AS_VER)) diff --git a/components/vfs/include/esp_vfs_dev.h b/components/vfs/include/esp_vfs_dev.h index b330b4c56..637f1449f 100644 --- a/components/vfs/include/esp_vfs_dev.h +++ b/components/vfs/include/esp_vfs_dev.h @@ -68,6 +68,44 @@ void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode); */ void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode); +/** + * @brief Set the line endings expected to be received on specified UART + * + * This specifies the conversion between line endings received on UART and + * newlines ('\n', LF) passed into stdin: + * + * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF + * - ESP_LINE_ENDINGS_CR: convert CR to LF + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. reading from UART + * + * @param uart_num the UART number + * @param mode line endings to send to UART + * @return 0 if successed, or -1 + * when an error (specified by errno) have occurred. + */ +int esp_vfs_dev_uart_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode); + +/** + * @brief Set the line endings to sent to specified UART + * + * This specifies the conversion between newlines ('\n', LF) on stdout and line + * endings sent over UART: + * + * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF + * - ESP_LINE_ENDINGS_CR: convert LF to CR + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. writing to UART + * + * @param uart_num the UART number + * @param mode line endings to send to UART + * @return 0 if successed, or -1 + * when an error (specified by errno) have occurred. + */ +int esp_vfs_dev_uart_port_set_tx_line_endings(int uart_num, esp_line_endings_t mode); + /** * @brief set VFS to use simple functions for reading and writing UART * Read is non-blocking, write is busy waiting until TX FIFO has enough space. diff --git a/components/vfs/test/test_vfs_uart.c b/components/vfs/test/test_vfs_uart.c index 2e45d76bf..59a6ccf0e 100644 --- a/components/vfs/test/test_vfs_uart.c +++ b/components/vfs/test/test_vfs_uart.c @@ -77,8 +77,8 @@ TEST_CASE("can read from stdin", "[vfs]") TEST_CASE("CRs are removed from the stdin correctly", "[vfs]") { - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CRLF); - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); flush_stdin_stdout(); const char* send_str = "1234567890\n\r123\r\n4\n"; diff --git a/components/vfs/vfs_uart.c b/components/vfs/vfs_uart.c index ebff91a87..c6aa6f096 100644 --- a/components/vfs/vfs_uart.c +++ b/components/vfs/vfs_uart.c @@ -71,14 +71,15 @@ static fd_set *_writefds_orig = NULL; static fd_set *_errorfds_orig = NULL; // Newline conversion mode when transmitting -static esp_line_endings_t s_tx_mode = +static esp_line_endings_t s_tx_mode [UART_NUM] = { [0 ... UART_NUM-1] = #if CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF - ESP_LINE_ENDINGS_CRLF; + ESP_LINE_ENDINGS_CRLF #elif CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR - ESP_LINE_ENDINGS_CR; + ESP_LINE_ENDINGS_CR #else - ESP_LINE_ENDINGS_LF; + ESP_LINE_ENDINGS_LF #endif + }; // Newline conversion mode when receiving static esp_line_endings_t s_rx_mode[UART_NUM] = { [0 ... UART_NUM-1] = @@ -172,9 +173,9 @@ static ssize_t uart_write(int fd, const void * data, size_t size) _lock_acquire_recursive(&s_uart_write_locks[fd]); for (size_t i = 0; i < size; i++) { int c = data_c[i]; - if (c == '\n' && s_tx_mode != ESP_LINE_ENDINGS_LF) { + if (c == '\n' && s_tx_mode[fd] != ESP_LINE_ENDINGS_LF) { s_uart_tx_func[fd](fd, '\r'); - if (s_tx_mode == ESP_LINE_ENDINGS_CR) { + if (s_tx_mode[fd] == ESP_LINE_ENDINGS_CR) { continue; } } @@ -927,7 +928,29 @@ void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode) void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode) { - s_tx_mode = mode; + for (int i = 0; i < UART_NUM; ++i) { + s_tx_mode[i] = mode; + } +} + +int esp_vfs_dev_uart_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode) +{ + if (uart_num < 0 || uart_num >= UART_NUM) { + errno = EBADF; + return -1; + } + s_rx_mode[uart_num] = mode; + return 0; +} + +int esp_vfs_dev_uart_port_set_tx_line_endings(int uart_num, esp_line_endings_t mode) +{ + if (uart_num < 0 || uart_num >= UART_NUM) { + errno = EBADF; + return -1; + } + s_tx_mode[uart_num] = mode; + return 0; } void esp_vfs_dev_uart_use_nonblocking(int uart_num) diff --git a/docs/en/api-guides/wifi.rst b/docs/en/api-guides/wifi.rst index 5819ac913..3d1917745 100644 --- a/docs/en/api-guides/wifi.rst +++ b/docs/en/api-guides/wifi.rst @@ -1019,13 +1019,6 @@ The table below shows the reason-code defined in ESP32. The first column is the | | | | connection to the AP has failed. | | | | | | +---------------------------+-------+---------+-------------------------------------------------------------+ -| AUTH_CHANGED | 206 |reserved | Espressif-specific Wi-Fi reason-code: the | -| | | | disconnection has happened since AP has changed the | -| | | | authmode. | -| | | | | -+---------------------------+-------+---------+-------------------------------------------------------------+ - - ESP32 Wi-Fi Station Connecting When Multiple APs Are Found --------------------------------------------------------------- diff --git a/docs/en/get-started-cmake/macos-setup.rst b/docs/en/get-started-cmake/macos-setup.rst index 75130d71a..3b023eb49 100644 --- a/docs/en/get-started-cmake/macos-setup.rst +++ b/docs/en/get-started-cmake/macos-setup.rst @@ -47,11 +47,11 @@ Toolchain Setup ESP32 toolchain for macOS is available for download from Espressif website: -|download_link_osx| +|download_link_macos| Download this file, then extract it in ``~/esp`` directory: -.. include:: /_build/inc/unpack-code-osx.inc +.. include:: /_build/inc/unpack-code-macos.inc .. _setup-macos-toolchain-add-it-to-path-cmake: diff --git a/docs/en/get-started/macos-setup.rst b/docs/en/get-started/macos-setup.rst index 7e1921a6c..b69ae1237 100644 --- a/docs/en/get-started/macos-setup.rst +++ b/docs/en/get-started/macos-setup.rst @@ -21,11 +21,11 @@ Toolchain Setup ESP32 toolchain for macOS is available for download from Espressif website: -|download_link_osx| +|download_link_macos| Download this file, then extract it in ``~/esp`` directory: -.. include:: /_build/inc/unpack-code-osx.inc +.. include:: /_build/inc/unpack-code-macos.inc .. _setup-macos-toolchain-add-it-to-path: diff --git a/docs/en/get-started/windows-setup.rst b/docs/en/get-started/windows-setup.rst index ee2dcea11..6e8e054b8 100644 --- a/docs/en/get-started/windows-setup.rst +++ b/docs/en/get-started/windows-setup.rst @@ -14,7 +14,7 @@ Toolchain Setup The quick setup is to download the Windows all-in-one toolchain & MSYS2 zip file from dl.espressif.com: -https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain_idf3-20200601.zip +https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain_idf3-20201104.zip Unzip the zip file to ``C:\`` (or some other location, but this guide assumes ``C:\``) and it will create an ``msys32`` directory with a pre-prepared environment. diff --git a/docs/en/versions.rst b/docs/en/versions.rst index 69c955600..cf4b8e2e6 100644 --- a/docs/en/versions.rst +++ b/docs/en/versions.rst @@ -70,7 +70,7 @@ Checking The Current Version The local ESP-IDF version can be checked using git:: cd $IDF_PATH - git describe --tags --dirty + git describe --dirty The version is also compiled into the firmware and can be accessed (as a string) via the macro ``IDF_VER``. The default ESP-IDF bootloader will print the version on boot (these versions in code will not always update, it only changes if that particular source file is recompiled). diff --git a/docs/gen-toolchain-links.py b/docs/gen-toolchain-links.py index ea90f47c7..0a93d6306 100644 --- a/docs/gen-toolchain-links.py +++ b/docs/gen-toolchain-links.py @@ -51,7 +51,7 @@ def main(): platform_info = [["linux64", "tar.gz", "z", unpack_code_linux_macos], ["linux32", "tar.gz", "z", unpack_code_linux_macos], - ["osx", "tar.gz", "z", unpack_code_linux_macos], + ["macos", "tar.gz", "z", unpack_code_linux_macos], ["win32", "zip", None, None]] with open(os.path.join(out_dir, 'download-links.inc'), "w") as links_file: diff --git a/docs/gen-version-specific-includes.py b/docs/gen-version-specific-includes.py index 08b111d65..6bd377c4b 100755 --- a/docs/gen-version-specific-includes.py +++ b/docs/gen-version-specific-includes.py @@ -198,7 +198,7 @@ def get_version(): # Otherwise, use git to look for a tag try: - tag = subprocess.check_output(["git", "describe", "--tags", "--exact-match"]).strip() + tag = subprocess.check_output(["git", "describe", "--exact-match"]).strip() is_stable = re.match(r"v[0-9\.]+$", tag) is not None return (tag, "tag", is_stable) except subprocess.CalledProcessError: diff --git a/docs/issue_template.md b/docs/issue_template.md index 7bf65e781..bce83a969 100644 --- a/docs/issue_template.md +++ b/docs/issue_template.md @@ -27,7 +27,7 @@ If the issue cannot be solved after the steps before, please follow these instru - Development Kit: [ESP32-Wrover-Kit|ESP32-DevKitC|ESP32-PICO-Kit|ESP32-LyraT|ESP32-LyraTD-MSC|none] - Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4] - Module or chip used: [ESP32-WROOM-32|ESP32-WROOM-32D|ESP32-WROOM-32U|ESP32-WROVER|ESP32-WROVER-I|ESP32-WROVER-B|ESP32-WROVER-IB|ESP32-SOLO-1|ESP32-PICO-D4|ESP32] -- IDF version (run ``git describe --tags`` to find it): +- IDF version (run ``git describe`` to find it): // v3.2-dev-1148-g96cd3b75c - Build System: [Make|CMake] - Compiler version (run ``xtensa-esp32-elf-gcc --version`` to find it): diff --git a/docs/zh_CN/get-started-cmake/macos-setup.rst b/docs/zh_CN/get-started-cmake/macos-setup.rst index 83536dbe3..6d0f72cf5 100644 --- a/docs/zh_CN/get-started-cmake/macos-setup.rst +++ b/docs/zh_CN/get-started-cmake/macos-setup.rst @@ -48,11 +48,11 @@ ESP-IDF 将使用 Mac OS 上默认安装的 Python 版本。 下载 MacOS 版本的 ESP32 工具链,请前往乐鑫官网: -|download_link_osx| +|download_link_macos| 完成下载后,请在 ``~/esp`` 目录下进行解压: -.. include:: /_build/inc/unpack-code-osx.inc +.. include:: /_build/inc/unpack-code-macos.inc .. _setup-macos-toolchain-add-it-to-path-cmake: @@ -92,4 +92,4 @@ ESP-IDF 将使用 Mac OS 上默认安装的 Python 版本。 .. _ninja: https://ninja-build.org/ .. _ccache: https://ccache.samba.org/ .. _homebrew: https://brew.sh/ -.. _MacPorts: https://www.macports.org/install.php \ No newline at end of file +.. _MacPorts: https://www.macports.org/install.php diff --git a/docs/zh_CN/get-started-cmake/windows-setup-scratch.rst b/docs/zh_CN/get-started-cmake/windows-setup-scratch.rst index 154bdf6b8..e3e50c3bb 100644 --- a/docs/zh_CN/get-started-cmake/windows-setup-scratch.rst +++ b/docs/zh_CN/get-started-cmake/windows-setup-scratch.rst @@ -58,7 +58,7 @@ Python 安装完成后,打开 Windows 开始菜单下的 Command Prompt,并 从 dl.espressif.com 下载预编译的 Windows 平台工具链: -https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip +https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip 解压压缩包文件到 ``C:\Program Files`` (或其他地址)。压缩包文件包含 ``xtensa-esp32-elf`` 目录。 diff --git a/docs/zh_CN/get-started/macos-setup.rst b/docs/zh_CN/get-started/macos-setup.rst index 72596ead2..502b37cf9 100644 --- a/docs/zh_CN/get-started/macos-setup.rst +++ b/docs/zh_CN/get-started/macos-setup.rst @@ -23,11 +23,11 @@ Mac OS 版本的 ESP32 工具链可以从以下地址下载: -|download_link_osx| +|download_link_macos| 下载压缩文件之后,解压到 ``~/esp`` 目录中: -.. include:: /_build/inc/unpack-code-osx.inc +.. include:: /_build/inc/unpack-code-macos.inc .. _setup-macos-toolchain-add-it-to-path: diff --git a/docs/zh_CN/get-started/windows-setup.rst b/docs/zh_CN/get-started/windows-setup.rst index 95e3e560b..b3540d8d8 100644 --- a/docs/zh_CN/get-started/windows-setup.rst +++ b/docs/zh_CN/get-started/windows-setup.rst @@ -15,7 +15,7 @@ Windows 没有内置的 "make" 环境,因此如果要安装工具链,你需 快速设置的方法是从 dl.espressif.com 下载集成在一起的工具链和 MSYS2 压缩文件: -https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain_idf3-20200601.zip +https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain_idf3-20201104.zip 将 zip 压缩文件解压到 ``C:\`` (或其它路径,这里假设是 ``C:\``),它会使用预先准备的环境创建一个 ``msys32`` 目录。 diff --git a/examples/bluetooth/ble_hid_device_demo/main/hid_dev.h b/examples/bluetooth/ble_hid_device_demo/main/hid_dev.h index 17b406b79..9954a8344 100644 --- a/examples/bluetooth/ble_hid_device_demo/main/hid_dev.h +++ b/examples/bluetooth/ble_hid_device_demo/main/hid_dev.h @@ -253,5 +253,9 @@ void hid_keyboard_build_report(uint8_t *buffer, keyboard_cmd_t cmd); void hid_mouse_build_report(uint8_t *buffer, mouse_cmd_t cmd); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* HID_DEV_H__ */ diff --git a/examples/bluetooth/ble_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/ble_throughput/throughput_client/main/example_ble_client_throughput.c index d438b7fd9..22e79d3f8 100644 --- a/examples/bluetooth/ble_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/ble_throughput/throughput_client/main/example_ble_client_throughput.c @@ -504,7 +504,7 @@ static void throughput_client_task(void *param) assert(res == pdTRUE); } else { if (is_connect) { - int free_buff_num = esp_ble_get_sendable_packets_num(); + int free_buff_num = esp_ble_get_cur_sendable_packets_num(gl_profile_tab[PROFILE_A_APP_ID].conn_id); if(free_buff_num > 0) { for( ; free_buff_num > 0; free_buff_num--) { // the app data set to 490 just for divided into two packages to send in the low layer diff --git a/examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c index 9087de10b..e28d5dfbb 100644 --- a/examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c @@ -624,7 +624,7 @@ void throughput_server_task(void *param) assert(res == pdTRUE); } else { if (is_connect) { - int free_buff_num = esp_ble_get_sendable_packets_num(); + int free_buff_num = esp_ble_get_cur_sendable_packets_num(gl_profile_tab[PROFILE_A_APP_ID].conn_id); if(free_buff_num > 0) { for( ; free_buff_num > 0; free_buff_num--) { esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id, diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md new file mode 100644 index 000000000..26a639b8a --- /dev/null +++ b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md @@ -0,0 +1,723 @@ +# Gatt Client Example Walkthrough + +## Introduction + +In this tutorial, the GATT client example code for the ESP32 is reviewed. The code implements a Bluetooth Low Energy (BLE) Generic Attribute (GATT) client, which scans for nearby peripheral servers and connects to a predefined service. The client then searches for available characteristics and subscribes to a known characteristic in order to receive notifications or indications. The example can register an Application Profile and initializes a sequence of events, which can be used to configure Generic Access Profile (GAP) parameters and to handle events such as scanning, connecting to peripherals and reading and writing characteristics. + +# Includes + +This example is located in the examples folder of the ESP-IDF under the [bluetooth/bluedroid/ble/gatt_client/main](../main). The [gattc_demo.c](../main/gattc_demo.c) file located in the main folder contains all the functionality that we are going to review. The header files contained in [gattc_demo.c](../main/gattc_demo.c) are: + +```c +#include +#include +#include +#include +#include "nvs.h" +#include "nvs_flash.h" +#include "controller.h" + +#include "bt.h" +#include "esp_gap_ble_api.h" +#include "esp_gattc_api.h" +#include "esp_gatt_defs.h" +#include "esp_bt_main.h" +#include "esp_gatt_common_api.h" +``` + +These `includes` are required for the FreeRTOS and underlaying system components to run, including the logging functionality and a library to store data in non-volatile flash memory. We are interested in `“bt.h”`, `“esp_bt_main.h”`, `"esp_gap_ble_api.h"` and `“esp_gattc_api.h”`, which expose the BLE APIs required to implement this example. + +* `bt.h`: configures the BT controller and VHCI from the host side. +* `esp_bt_main.h`: initializes and enables the Bluedroid stack. +* `esp_gap_ble_api.h`: implements the GAP configuration, such as advertising and connection parameters. +* `esp_gattc_api.h`: implements the GATT Client configuration, such as connecting to peripherals and searching for services. + +## Main Entry Point + +The program’s entry point is the app_main() function: + +```c +void app_main() +{ + // Initialize NVS. + esp_err_t ret = nvs_flash_init(); + if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } + ESP_ERROR_CHECK( ret ); + + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); + ret = esp_bt_controller_init(&bt_cfg); + if (ret) { + ESP_LOGE(GATTC_TAG, "%s initialize controller failed, error code = %x\n", __func__, ret); + return; + } + + ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); + if (ret) { + ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret); + return; + } + + ret = esp_bluedroid_init(); + if (ret) { + ESP_LOGE(GATTC_TAG, "%s init bluetooth failed, error code = %x\n", __func__, ret); + return; + } + + ret = esp_bluedroid_enable(); + if (ret) { + ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed, error code = %x\n", __func__, ret); + return; + } + + //register the callback function to the gap module + ret = esp_ble_gap_register_callback(esp_gap_cb); + if (ret){ + ESP_LOGE(GATTC_TAG, "%s gap register failed, error code = %x\n", __func__, ret); + return; + } + + //register the callback function to the gattc module + ret = esp_ble_gattc_register_callback(esp_gattc_cb); + if(ret){ + ESP_LOGE(GATTC_TAG, "%s gattc register failed, error code = %x\n", __func__, ret); + return; + } + + ret = esp_ble_gattc_app_register(PROFILE_A_APP_ID); + if (ret){ + ESP_LOGE(GATTC_TAG, "%s gattc app register failed, error code = %x\n", __func__, ret); + } + + esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500); + if (local_mtu_ret){ + ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", local_mtu_ret); + } + +} +``` + +The main function starts by initializing the non-volatile storage library. This library allows to save key-value pairs in flash memory and is used by some components such as the Wi-Fi library to save the SSID and password: + +```c +esp_err_t ret = nvs_flash_init(); +if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); +} +ESP_ERROR_CHECK( ret ); +``` + +## BT Controller and Stack Initialization + +The main function also initializes the BT controller by first creating a BT controller configuration structure named `esp_bt_controller_config_t` with default settings generated by the `BT_CONTROLLER_INIT_CONFIG_DEFAULT()` macro. The BT controller implements the Host Controller Interface (HCI) on the controller side, the Link Layer (LL) and the Physical Layer (PHY). The BT Controller is invisible to the user applications and deals with the lower layers of the BLE stack. The controller configuration includes setting the BT controller stack size, priority and HCI baud rate. With the settings created, the BT controller is initialized and enabled with the `esp_bt_controller_init()` function: + +```c +esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); +ret = esp_bt_controller_init(&bt_cfg); +``` + +Next, the controller is enabled in BLE Mode. + +```c +ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); +``` +>The controller should be enabled in `ESP_BT_MODE_BTDM`, if you want to use the dual mode (BLE + BT). + +There are four Bluetooth modes supported: + +1. `ESP_BT_MODE_IDLE`: Bluetooth not running +2. `ESP_BT_MODE_BLE`: BLE mode +3. `ESP_BT_MODE_CLASSIC_BT`: BT Classic mode +4. `ESP_BT_MODE_BTDM`: Dual mode (BLE + BT Classic) + +After the initialization of the BT controller, the Bluedroid stack, which includes the common definitions and APIs for both BT Classic and BLE, is initialized and enabled by using: + +```c +ret = esp_bluedroid_init(); +ret = esp_bluedroid_enable(); +``` +The main function ends by registering the GAP and GATT event handlers, as well as the Application Profile and set the maximum supported MTU size. + +```c + //register the callback function to the gap module + ret = esp_ble_gap_register_callback(esp_gap_cb); + + //register the callback function to the gattc module + ret = esp_ble_gattc_register_callback(esp_gattc_cb); + + ret = esp_ble_gattc_app_register(PROFILE_A_APP_ID); + + esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500); + if (local_mtu_ret){ + ESP_LOGE(GATTC_TAG, "set local MTU failed, error code = %x", local_mtu_ret); + } +``` + +The GAP and GATT event handlers are the functions used to catch the events generated by the BLE stack and execute functions to configure parameters of the application. Moreover, the event handlers are also used to handle read and write events coming from the central. The GAP event handler takes care of scanning and connecting to servers and the GATT handler manages events that happen after the client has connected to a server, such as searching for services and writing and reading data. The GAP and GATT event handlers are registered by using: + +```c +esp_ble_gap_register_callback(); +esp_ble_gattc_register_callback(); +``` +The functions `esp_gap_cb()` and `esp_gattc_cb()` handle all the events generated by the BLE stack. + +## Application Profiles + +The Application Profiles are a way to group functionalities that are designed for one or more server applications. For example, you can have an Application Profile connected to the Heart Rate Sensors, and another one connected to the Temperature Sensors. Each Application Profile creates a GATT interface to connect to other devices. The Application Profiles in the code are instances of the `gattc_profile_inst` structure, which is defined as: + +```c +struct gattc_profile_inst { + esp_gattc_cb_t gattc_cb; + uint16_t gattc_if; + uint16_t app_id; + uint16_t conn_id; + uint16_t service_start_handle; + uint16_t service_end_handle; + uint16_t char_handle; + esp_bd_addr_t remote_bda; +}; +``` + +The Application Profile structure contains: + +* `gattc_cb`: GATT client callback function +* `gattc_if`: GATT client interface number for this profile +* `app_id`: Application Profile ID number +* `conn_id`: Connection ID +* `service_start_handle`: Service start handle +* `service_end_handle`: Service end handle +* `char_handle`: Char handle +* `remote_bda`: Remote device address connected to this client. + +In this example there is one Application Profile and its ID is defined as: + +```c +#define PROFILE_NUM 1 +#define PROFILE_A_APP_ID 0 +``` +The Application Profile are stored in the `gl_profile_tab` array, which is initialized as: + +```c +/* One gatt-based profile one app_id and one gattc_if, this array will store the gattc_if returned by ESP_GATTS_REG_EVT */ +static struct gattc_profile_inst gl_profile_tab[PROFILE_NUM] = { + [PROFILE_A_APP_ID] = {.gattc_cb = gattc_profile_event_handler, + .gattc_if = ESP_GATT_IF_NONE, /* Not get the gatt_if, so initial is ESP_GATT_IF_NONE */ + }, +}; +``` + +The initialization of the Application Profile table array includes defining the callback functions for each Profile. These are `gattc_profile_a_event_handler()` and `gattc_profile_a_event_handler()` respectively. In addition, the GATT interface is initialized to the default value of `ESP_GATT_IF_NONE`. Later on, when the Application Profile is registered, the BLE stack returns a GATT interface instance to use with that Application Profile. + +The profile registration triggers an `ESP_GATTC_REG_EVT` event, which is handled by the `esp_gattc_cb()` event handler. The handler takes the GATT interface returned by the event and stores it in the profile table: + +```c +static void esp_gattc_cb(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) +{ + ESP_LOGI(GATTC_TAG, "EVT %d, gattc if %d", event, gattc_if); + + /* If event is register event, store the gattc_if for each profile */ + if (event == ESP_GATTC_REG_EVT) { + if (param->reg.status == ESP_GATT_OK) { + gl_profile_tab[param->reg.app_id].gattc_if = gattc_if; + } else { + ESP_LOGI(GATTC_TAG, "reg app failed, app_id %04x, status %d", + param->reg.app_id, + param->reg.status); + return; + } + } +… +``` + +Finally, the callback function invokes the corresponding event handler for each profile in the `gl_profile_tab` table. + +```c +… +/* If the gattc_if equal to profile A, call profile A cb handler, + * so here call each profile's callback */ + do { + int idx; + for (idx = 0; idx < PROFILE_NUM; idx++) { + if (gattc_if == ESP_GATT_IF_NONE || /* ESP_GATT_IF_NONE, not specify a certain gatt_if, need to call every profile cb function */ + gattc_if == gl_profile_tab[idx].gattc_if) { + if (gl_profile_tab[idx].gattc_cb) { + gl_profile_tab[idx].gattc_cb(event, gattc_if, param); + } + } + } + } while (0); +} +``` +## Setting Scan Parameters + +The GATT client normally scans for nearby servers and tries connect to them, if interested. However, in order to perform the scanning, first the configuration parameters need to be set. This is done after the registration of the Application Profiles, because the registration, once completed, triggers an `ESP_GATTC_REG_EVT` event. The first time this event is triggered, the GATT event handler captures it and assigns a GATT interface to Profile A, then the event is forwarded to the GATT event handler of Profile A. One in this event handler, the event is used to call the `esp_ble_gap_set_scan_params()` function, which takes a `ble_scan_params` structure instance as parameter. This structure is defined as: + +```c +/// Ble scan parameters +typedef struct { + esp_ble_scan_type_t scan_type; /*!< Scan type */ + esp_ble_addr_type_t own_addr_type; /*!< Owner address type */ + esp_ble_scan_filter_t scan_filter_policy; /*!< Scan filter policy */ + uint16_t scan_interval; /*!< Scan interval. This is defined as the time interval from when the Controller started its last LE scan until it begins the subsequent LE scan.*/ + //Range: 0x0004 to 0x4000 + //Default: 0x0010 (10 ms) + //Time = N * 0.625 msec + //Time Range: 2.5 msec to 10.24 seconds + uint16_t scan_window; /*!< Scan window. The duration of the LE scan. LE_Scan_Window shall be less than or equal to LE_Scan_Interval*/ + //Range: 0x0004 to 0x4000 //Default: 0x0010 (10 ms) + //Time = N * 0.625 msec + //Time Range: 2.5 msec to 10240 msec +} esp_ble_scan_params_t; +``` +An it is initialized as: + +```c +static esp_ble_scan_params_t ble_scan_params = { + .scan_type = BLE_SCAN_TYPE_ACTIVE, + .own_addr_type = BLE_ADDR_TYPE_PUBLIC, + .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, + .scan_interval = 0x50, + .scan_window = 0x30 +}; +``` + +The BLE scan parameters are configured so that the type of scanning is active (includes reading the scanning response), it is of public type, allows any advertising device to be read and has a scanning interval of 100 ms (1.25 ms * 0x50) and a scanning window of 60 ms (1.25 ms * 0x30). + +The scan values are set using the `esp_ble_gap_set_scan_params()` function: + +```c +case ESP_GATTC_REG_EVT: + ESP_LOGI(GATTC_TAG, "REG_EVT"); + esp_err_t scan_ret = esp_ble_gap_set_scan_params(&ble_scan_params); + if (scan_ret){ + ESP_LOGE(GATTC_TAG, "set scan params error, error code = %x", scan_ret); + } + break; +``` + +## Start Scanning + +Once the scanning parameters are set, an `ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT` event is triggered, which is handled by the GAP event handler `esp_gap_cb()`. This event is used to start the scanning of nearby GATT servers: + +```c + case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: { + //the unit of the duration is second + uint32_t duration = 30; + esp_ble_gap_start_scanning(duration); + break; + } +``` + +The scanning is started using the `esp_ble_gap_start_scanning()` function which takes a parameter representing the duration of the continuous scanning (in seconds). Once the scanning period is ended, an `ESP_GAP_SEARCH_INQ_CMPL_EVT` event is triggered. + +## Getting Scan Results + +The results of the scanning are displayed as soon as they arrive with the `ESP_GAP_BLE_SCAN_RESULT_EVT` event, which includes the following parameters: + +```c + /** + * @brief ESP_GAP_BLE_SCAN_RESULT_EVT + */ + struct ble_scan_result_evt_param { + esp_gap_search_evt_t search_evt; /*!< Search event type */ + esp_bd_addr_t bda; /*!< Bluetooth device address which has been searched */ + esp_bt_dev_type_t dev_type; /*!< Device type */ + esp_ble_addr_type_t ble_addr_type; /*!< Ble device address type */ + esp_ble_evt_type_t ble_evt_type; /*!< Ble scan result event type */ + int rssi; /*!< Searched device's RSSI */ + uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX]; /*!< Received EIR */ + int flag; /*!< Advertising data flag bit */ + int num_resps; /*!< Scan result number */ + uint8_t adv_data_len; /*!< Adv data length */ + uint8_t scan_rsp_len; /*!< Scan response length */ + } scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */ +``` + +This event also includes a list of sub events as shown below: + +```c +/// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT +typedef enum { + ESP_GAP_SEARCH_INQ_RES_EVT = 0, /*!< Inquiry result for a peer device. */ + ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /*!< Inquiry complete. */ + ESP_GAP_SEARCH_DISC_RES_EVT = 2, /*!< Discovery result for a peer device. */ + ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /*!< Discovery result for BLE GATT based service on a peer device. */ + ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */ + ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */ + ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */ +} esp_gap_search_evt_t; +``` +We are interested in the `ESP_GAP_SEARCH_INQ_RES_EVT` event, which is called every time a new device is found. We are also interested in the `ESP_GAP_SEARCH_INQ_CMPL_EVT`, which is triggered when the duration of the scanning is completed and can be used to restart the scanning procedure: + +```c + case ESP_GAP_BLE_SCAN_RESULT_EVT: { + esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param; + switch (scan_result->scan_rst.search_evt) { + case ESP_GAP_SEARCH_INQ_RES_EVT: + esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6); + ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len); + adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); + ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len); + esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len); + ESP_LOGI(GATTC_TAG, "\n"); + if (adv_name != NULL) { + if (strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) { + ESP_LOGI(GATTC_TAG, "searched device %s\n", remote_device_name); + if (connect == false) { + connect = true; + ESP_LOGI(GATTC_TAG, "connect to the remote device."); + esp_ble_gap_stop_scanning(); + esp_ble_gattc_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, scan_result->scan_rst.bda, scan_result->scan_rst.ble_addr_type, true); + } + } + } + break; +``` + +First the device name is resolved and compared to the one defined in `remote_device_name`. If it equals to the device name of the GATT Server we are interested in, then the scanning is stopped. + + +## Connecting to A GATT Server + +Every time we receive a result from the `ESP_GAP_SEARCH_INQ_RES_EVT` event, the code first prints the address of the remote device: + +```c +case ESP_GAP_SEARCH_INQ_RES_EVT: + esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6); +``` + +The client then prints the advertised data length and the scan response length: + +```c +ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len); +``` + +In order to get the device name, we use the `esp_ble_resolve_adv_data()` function, which takes the advertised data stored in `scan_result->scan_rst.ble_adv`, the type of advertising data and the length, in order to extract the value from the advertising packet frame. Then the device name is printed. + +```c +adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); +ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len); +esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len); +``` + +Finally if the remote device name is the same as we have defined above, the local device stops scanning and tries to open a connection to the remote device using the `esp_ble_gattc_open()` function. This function takes as parameters the Application Profile GATT interface, the remote server address and a boolean value. The boolean value is used to indicate if the connection is done directly or if it’s done in the background (auto-connection), at the moment this boolean value must be set to true in order to establish the connection. Notice that the client opens a virtual connection to the server. The virtual connection returns a connection ID. The virtual connection is the connection between the Application Profile and the remote server. Since many Application Profiles can run on one ESP32, there could be many virtual connection opened to the same remote server. There is also the physical connection which is the actual BLE link between the client and the server. Therefore, if the physical connection is disconnected with the `esp_ble_gap_disconnect()` function, all other virtual connections are closed as well. In this example, each Application Profile creates a virtual connection to the same server with the `esp_ble_gattc_open()` function, so when the close function is called, only that connection from the Application Profile is closed, while if the gap disconnect function is called, both connections will be closed. In addition, connect events are propagated to all profiles because it relates to the physical connection, while open events are propagated only to the profile that creates the virtual connection. + +## Configuring the MTU Size + +ATT_MTU is defined as the maximum size of any packet sent between a client and a server. When the client connects to the server, it informs the server which MTU size to use by exchanging MTU Request and Response protocol data units (PDUs). This is done after the opening of a connection. After opening the connection, an `ESP_GATTC_CONNECT_EVT` event is triggered: + +```c + case ESP_GATTC_CONNECT_EVT: + //p_data->connect.status always be ESP_GATT_OK + ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT conn_id %d, if %d, status %d", conn_id, gattc_if, p_data->connect.status); + conn_id = p_data->connect.conn_id; + gl_profile_tab[PROFILE_A_APP_ID].conn_id = p_data->connect.conn_id; + memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t)); + ESP_LOGI(GATTC_TAG, "REMOTE BDA:"); + esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, sizeof(esp_bd_addr_t)); + esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, conn_id); + if (mtu_ret){ + ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret); + } + break; +``` + +The connection ID and the address of the remote device (server) are stored in the Application Profile table and printed to the console: + +```c +conn_id = p_data->connect.conn_id; +gl_profile_tab[PROFILE_A_APP_ID].conn_id = p_data->connect.conn_id; +memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, p_data->connect.remote_bda, + sizeof(esp_bd_addr_t)); +ESP_LOGI(GATTC_TAG, "REMOTE BDA:"); +esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, + sizeof(esp_bd_addr_t)); +``` + +The typical MTU size for a Bluetooth 4.0 connection is 23 bytes. A client can change the size of MUT, using `esp_ble_gattc_send_mtu_req()` function, which takes the GATT interface and the connection ID. The size of the requested MTU is defined by `esp_ble_gatt_set_local_mtu()`. The server can then accept or reject the request. The ESP32 supports a MTU size of up to 517 bytes, which is defined by the `ESP_GATT_MAX_MTU_SIZE` in `esp_gattc_api.h`. In this example, the MTU size is set to 500 bytes. In case the configuration fails, the returned error is printed: + +```c +esp_err_t mtu_ret = esp_ble_gattc_send_mtu_req (gattc_if, conn_id); +if (mtu_ret){ + ESP_LOGE(GATTC_TAG, "config MTU error, error code = %x", mtu_ret); +} +break; +``` + +The connection opening also triggers an `ESP_GATTC_OPEN_EVT`, which is used to check that the opening of the connection was done successfully, otherwise print an error and exit. + +```c +case ESP_GATTC_OPEN_EVT: + if (param->open.status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "open failed, status %d", p_data->open.status); + break; + } +ESP_LOGI(GATTC_TAG, "open success"); +``` + +When the MTU is exchanged, an `ESP_GATTC_CFG_MTU_EVT` is triggered, which in this example is used to print the new MTU size. + +```c +case ESP_GATTC_CFG_MTU_EVT: + if (param->cfg_mtu.status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG,"config mtu failed, error status = %x", param->cfg_mtu.status); + } + ESP_LOGI(GATTC_TAG, "ESP_GATTC_CFG_MTU_EVT, Status %d, MTU %d, conn_id %d", param->cfg_mtu.status, param->cfg_mtu.mtu, param->cfg_mtu.conn_id); +… +``` + +## Discovering Services + +The MTU configuration event is also used to start discovering the services available in the server that the client just connected to. To discover the services, the function `esp_ble_gattc_search_service()` is used. The parameters of the function are the GATT interface, the Application Profile connection ID and the UUID of the service application that the client is interested in. The service we are looking for is defined as: + +```c +static esp_bt_uuid_t remote_filter_service_uuid = { + .len = ESP_UUID_LEN_16, + .uuid = {.uuid16 = REMOTE_SERVICE_UUID,}, +}; +``` +Where, + +```c +#define REMOTE_SERVICE_UUID 0x00FF +``` +If UUID of the service application the user is interested in is 128-bit, then there is one note below for the user which is relevant with the little-endian storage mode of the processor architecture. +The struct of UUID is defined as: + +```c +typedef struct { +#define ESP_UUID_LEN_16 2 +#define ESP_UUID_LEN_32 4 +#define ESP_UUID_LEN_128 16 + uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */ + union { + uint16_t uuid16; /*!< 16bit UUID */ + uint32_t uuid32; /*!< 32bit UUID */ + uint8_t uuid128[ESP_UUID_LEN_128]; /*!< 128bit UUID */ + } uuid; /*!< UUID */ +} __attribute__((packed)) esp_bt_uuid_t; +``` + +Note: In little-endian storage mode, you can define service UUID directly in the normal order if it's a 16-bit or a 32-bit UUID, but if service UUID is 128-bit, there is minor difference. For example, if the UUID of the service application that the user is interested in is 12345678-a1b2-c3d4-e5f6-9fafd205e457, `REMOTE_SERVICE_UUID` should be defined as {0x57,0xE4,0x05,0xD2,0xAF,0x9F,0xF6,0xE5,0xD4,0xC3,0xB2,0xA1,0x78,0x56,0x34,0x12}. + +The services are then discovered as follows: + +```c +esp_ble_gattc_search_service(gattc_if, param->cfg_mtu.conn_id, &remote_filter_service_uuid); + break; +``` + +The resulting service found, if there is any, will be returned from an `ESP_GATTC_SEARCH_RES_EVT`. For each service found, the event is triggered to print information about the service discovered, depending on the size of the UUID: + +```c + case ESP_GATTC_SEARCH_RES_EVT: { + esp_gatt_srvc_id_t *srvc_id = &p_data->search_res.srvc_id; + conn_id = p_data->search_res.conn_id; + if (srvc_id->id.uuid.len == ESP_UUID_LEN_16 && srvc_id->id.uuid.uuid.uuid16 == +REMOTE_SERVICE_UUID) { + get_server = true; + gl_profile_tab[PROFILE_A_APP_ID].service_start_handle = p_data->search_res.start_handle; + gl_profile_tab[PROFILE_A_APP_ID].service_end_handle = p_data->search_res.end_handle; + ESP_LOGI(GATTC_TAG, "UUID16: %x", srvc_id->id.uuid.uuid.uuid16); + } + break; +``` + +In case that the client finds the service that it is looking for, the flag get_server is set to true, and the start handle value and end handle value, which will be used later to get all the characteristics of that service, are saved. After all service results are returned, the search is completed and an `ESP_GATTC_SEARCH_CMPL_EVT` event is triggered. + +## Getting Characteristics + +This example implements getting characteristic data from a predefined service. The service that we want the characteristics from has an UUID of 0x00FF, and the characteristic we are interested in has an UUID of 0xFF01: + +```c +#define REMOTE_NOTIFY_CHAR_UUID 0xFF01 +``` +A service is defined using the `esp_gatt_srvc_id_t` structure as: + +```c +/** + * @brief Gatt id, include uuid and instance id + */ +typedef struct { + esp_bt_uuid_t uuid; /*!< UUID */ + uint8_t inst_id; /*!< Instance id */ +} __attribute__((packed)) esp_gatt_id_t; +``` + +In this example, we define the service that we want to get the characteristics from as: + +```c +static esp_gatt_srvc_id_t remote_service_id = { + .id = { + .uuid = { + .len = ESP_UUID_LEN_16, + .uuid = {.uuid16 = REMOTE_SERVICE_UUID,}, + }, + .inst_id = 0, + }, + .is_primary = true, +}; +``` + +Once defined, we can get the characteristics from that service using the `esp_ble_gattc_get_characteristic()` function, which is called in the `ESP_GATTC_SEARCH_CMPL_EVT` event after the search for services is completed and the client has found the service that it was looking for. + +```c +case ESP_GATTC_SEARCH_CMPL_EVT: + if (p_data->search_cmpl.status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "search service failed, error status = %x", p_data->search_cmpl.status); + break; + } + conn_id = p_data->search_cmpl.conn_id; + if (get_server){ + uint16_t count = 0; + esp_gatt_status_t status = esp_ble_gattc_get_attr_count( gattc_if, + p_data->search_cmpl.conn_id,ESP_GATT_DB_CHARACTERISTIC, gl_profile_tab[PROFILE_A_APP_ID].service_start_handle, gl_profile_tab[PROFILE_A_APP_ID].service_end_handle, + INVALID_HANDLE, + &count); + if (status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); + } + + if (count > 0){ + char_elem_result = (esp_gattc_char_elem_t*)malloc + (sizeof(esp_gattc_char_elem_t) * count); + if (!char_elem_result){ + ESP_LOGE(GATTC_TAG, "gattc no mem"); + }else{ + status = esp_ble_gattc_get_char_by_uuid( gattc_if, + p_data->search_cmpl.conn_id, + gl_profile_tab[PROFILE_A_APP_ID].service_start_handle, + gl_profile_tab[PROFILE_A_APP_ID].service_end_handle, + remote_filter_char_uuid, + char_elem_result, + &count); + if (status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_char_by_uuid error"); + } + + /* Every service have only one char in our 'ESP_GATTS_DEMO' demo, + so we used first 'char_elem_result' */ + if (count > 0 && (char_elem_result[0].properties + &ESP_GATT_CHAR_PROP_BIT_NOTIFY)){ + gl_profile_tab[PROFILE_A_APP_ID].char_handle = + char_elem_result[0].char_handle; + esp_ble_gattc_register_for_notify (gattc_if, + gl_profile_tab[PROFILE_A_APP_ID].remote_bda, + char_elem_result[0].char_handle); + } + } + /* free char_elem_result */ + free(char_elem_result); + }else{ + ESP_LOGE(GATTC_TAG, "no char found"); + } } + break; +``` + +`esp_ble_gattc_get_attr_count()` gets the attribute count with the given service or characteristic in the gattc cache. The parameters of `esp_ble_gattc_get_attr_count()` function are the GATT interface, the connection ID, the attribute type defined in `esp_gatt_db_attr_type_t`, the attribute start handle, the attribute end handle, the characteristic handle (this parameter is only valid when the type is set to `ESP_GATT_DB_DESCRIPTOR`.) and output the number of attribute has been found in the gattc cache with the given attribute type. Then we allocate a buffer to save the char information for `esp_ble_gattc_get_char_by_uuid()` function. The function finds the characteristic with the given characteristic UUID in the gattc cache. It just gets characteristic from local cache, instead of the remote devices. In a server, there might be more than one chars sharing the same UUID. However, in our gatt_server demo, every char has an unique UUID and that’s why we only use the first char in `char_elem_result`, which is the pointer to the characteristic of the service. Count initially stores the number of the characteristics that the client wants to find, and will be updated with the number of the characteristics that have been actually found in the gattc cache with `esp_ble_gattc_get_char_by_uuid`. + +## Registering for Notifications + +The client can register to receive notifications from the server every time the characteristic value changes. In this example, we want to register for notifications of the characteristic identified with an UUID of 0xff01. After getting all the characteristics, we check the properties of the received characteristic, then use the `esp_ble_gattc_register_for_notify()` function to register notifications. The function arguments are the GATT interface, the address of the remote server, and the handle we want to register for notifications. + +```c +… +/* Every service have only one char in our 'ESP_GATTS_DEMO' demo, so we used first 'char_elem_result' */ + if(count > 0 && (char_elem_result[0].properties & ESP_GATT_CHAR_PROP_BIT_NOTIFY)){ + gl_profile_tab[PROFILE_A_APP_ID].char_handle = char_elem_result[0].char_handle; + esp_ble_gattc_register_for_notify (gattc_if, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, + char_elem_result[0].char_handle); + } +… +``` + +This procedure registers notifications to the BLE stack, and triggers an `ESP_GATTC_REG_FOR_NOTIFY_EVT`. This event is used to write to the server Client Configuration Descriptor: + +```c + case ESP_GATTC_REG_FOR_NOTIFY_EVT: { + ESP_LOGI(GATTC_TAG, "ESP_GATTC_REG_FOR_NOTIFY_EVT"); + if (p_data->reg_for_notify.status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "REG FOR NOTIFY failed: error status = %d", p_data->reg_for_notify.status); + }else{ + uint16_t count = 0; + uint16_t notify_en = 1; + esp_gatt_status_t ret_status = esp_ble_gattc_get_attr_count( gattc_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id, + ESP_GATT_DB_DESCRIPTOR, + gl_profile_tab[PROFILE_A_APP_ID].service_start_handle, + gl_profile_tab[PROFILE_A_APP_ID].service_end_handle, + gl_profile_tab[PROFILE_A_APP_ID].char_handle, &count); + if (ret_status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); + } + if (count > 0){ + descr_elem_result = malloc(sizeof(esp_gattc_descr_elem_t) * count); + if (!descr_elem_result){ + ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); + }else{ + ret_status = esp_ble_gattc_get_descr_by_char_handle( + gattc_if, + gl_profile_tab[PROFILE_A_APP_ID].conn_id, + p_data->reg_for_notify.handle, + notify_descr_uuid, + descr_elem_result,&count); + + if (ret_status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_descr_by_char_handle + error"); + } + + /* Every char has only one descriptor in our 'ESP_GATTS_DEMO' demo, so we used first 'descr_elem_result' */ + if (count > 0 && descr_elem_result[0].uuid.len == ESP_UUID_LEN_16 && descr_elem_result[0].uuid.uuid.uuid16 == ESP_GATT_UUID_CHAR_CLIENT_CONFIG){ + ret_status = esp_ble_gattc_write_char_descr( gattc_if, + gl_profile_tab[PROFILE_A_APP_ID].conn_id, + descr_elem_result[0].handle, + sizeof(notify_en), + (Uint8 *)¬ify_en, + ESP_GATT_WRITE_TYPE_RSP, + ESP_GATT_AUTH_REQ_NONE); + } + + if (ret_status != ESP_GATT_OK){ + ESP_LOGE(GATTC_TAG, "esp_ble_gattc_write_char_descr error"); + } + + /* free descr_elem_result */ + free(descr_elem_result); + } + } + else{ + ESP_LOGE(GATTC_TAG, "decsr not found"); + } + + } + break; + } +``` + +The event is used to first print the notification register status and the service and characteristic UUIDs of the just registered notifications. The client then writes to the Client Configuration Descriptor by using the `esp_ble_gattc_write_char_descr()` function. There are many characteristic descriptors defined in the Bluetooth specification. However, in this case we are interested in writing to the descriptor that deals with enabling notifications, which is the Client Configuration descriptor. In order to pass this descriptor as parameter, we first define it as: + +```c +static esp_gatt_id_t notify_descr_id = { + .uuid = { + .len = ESP_UUID_LEN_16, + .uuid = {.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG,}, + }, + .inst_id = 0, +}; +``` +Where `ESP_GATT_UUID_CHAR_CLIENT_CONFIG` is defined with the UUID to identify the Characteristic Client Configuration: + +```c +#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */ +``` +The value to write is “1” to enable notifications. We also pass `ESP_GATT_WRITE_TYPE_RSP` to request that the server responds to the request of enabling notifications and `ESP_GATT_AUTH_REQ_NONE` to indicate that the Write request does not need authorization. + + + +## Conclusion + +We have reviewed the GATT Client example code for the ESP32. This example scans for nearby devices and searches for services and characteristics of servers of interest. When the server of interest is found, a connection is made with that server and a search for services is performed. Finally, the client looks for a specific characteristic in the services found, if found, gets the characteristic value and registers for notifications to that characteristic. This is done by registering one Application Profile and following a sequence of events to configure the GAP and GATT parameters required. + diff --git a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c index e73241e30..5c7974aac 100644 --- a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c +++ b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c @@ -98,6 +98,12 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) ESP_LOGI(SPP_TAG, "ESP_SPP_SRV_OPEN_EVT"); gettimeofday(&time_old, NULL); break; + case ESP_SPP_SRV_STOP_EVT: + ESP_LOGI(SPP_TAG, "ESP_SPP_SRV_STOP_EVT"); + break; + case ESP_SPP_UNINIT_EVT: + ESP_LOGI(SPP_TAG, "ESP_SPP_UNINIT_EVT"); + break; default: break; } diff --git a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c index 91cf6940b..de8dd0edc 100644 --- a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c +++ b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c @@ -116,7 +116,7 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) break; case ESP_SPP_OPEN_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_OPEN_EVT"); - esp_spp_write(param->srv_open.handle, SPP_DATA_LEN, spp_data); + esp_spp_write(param->open.handle, SPP_DATA_LEN, spp_data); gettimeofday(&time_old, NULL); break; case ESP_SPP_CLOSE_EVT: @@ -157,6 +157,9 @@ static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) case ESP_SPP_SRV_OPEN_EVT: ESP_LOGI(SPP_TAG, "ESP_SPP_SRV_OPEN_EVT"); break; + case ESP_SPP_UNINIT_EVT: + ESP_LOGI(SPP_TAG, "ESP_SPP_UNINIT_EVT"); + break; default: break; } diff --git a/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c b/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c index fdd75cc86..ab427407d 100644 --- a/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c +++ b/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c @@ -53,6 +53,9 @@ static void spp_read_handle(void * param) int size = 0; int fd = (int)param; do { + /* controll the log frequency, retry after 1s */ + vTaskDelay(1000 / portTICK_PERIOD_MS); + size = read (fd, spp_data, SPP_DATA_LEN); ESP_LOGI(SPP_TAG, "fd = %d data_len = %d", fd, size); if (size == -1) { diff --git a/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c b/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c index 4a2902553..5e26d9bee 100644 --- a/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c +++ b/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c @@ -61,6 +61,9 @@ static void spp_write_handle(void * param) int fd = (int)param; printf("%s %d %p\n", __func__,fd,param); do { + /* controll the log frequency, retry after 1s */ + vTaskDelay(1000 / portTICK_PERIOD_MS); + size = write (fd, spp_data, SPP_DATA_LEN); ESP_LOGI(SPP_TAG, "fd = %d data_len = %d",fd, size); if (size == -1) { diff --git a/examples/bluetooth/esp_ble_mesh/README.md b/examples/bluetooth/esp_ble_mesh/README.md index 50659c91e..6552c8428 100644 --- a/examples/bluetooth/esp_ble_mesh/README.md +++ b/examples/bluetooth/esp_ble_mesh/README.md @@ -1,6 +1,6 @@ # ESP-BLE-MESH Examples -[ESP-BLE-MESH]($IDF_PATH/components/bt/esp_ble_mesh/) is the official Bluetooth® Mesh stack of Espressif Systems. We will provide long-term support for new features, performance optimization, etc. +[ESP-BLE-MESH](../../../components/bt/esp_ble_mesh/) is the official Bluetooth® Mesh stack of Espressif Systems. We will provide long-term support for new features, performance optimization, etc. Please help note that breaking changes may be introduced into ESP-BLE-MESH on [minor IDF versions](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html). diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c index 3e961a4f2..f4bf0edc8 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c @@ -58,9 +58,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c index 357c93636..3401aa485 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c @@ -61,9 +61,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c index 7b590d312..a3dd1df77 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c @@ -31,6 +31,8 @@ #include "ble_mesh_fast_prov_client_model.h" #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + #define PROV_OWN_ADDR 0x0001 #define APP_KEY_OCTET 0x12 #define GROUP_ADDRESS 0xC000 diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid index eebbd1d5c..58ffb2da0 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.bluedroid @@ -10,5 +10,6 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y -CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble index 55232fbd2..abc7bd361 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.ci.nimble @@ -10,5 +10,6 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y -CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.defaults b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.defaults index d45436ce9..07918a446 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.defaults +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/sdkconfig.defaults @@ -18,4 +18,4 @@ CONFIG_BLE_MESH_ADV_BUF_COUNT=100 CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=10 CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=10 CONFIG_BLE_MESH_CFG_CLI=y -CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/tutorial/BLE_Mesh_Fast_Prov_Client_Example_Walkthrough.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/tutorial/BLE_Mesh_Fast_Prov_Client_Example_Walkthrough.md index dea6469b6..598a1f512 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/tutorial/BLE_Mesh_Fast_Prov_Client_Example_Walkthrough.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/tutorial/BLE_Mesh_Fast_Prov_Client_Example_Walkthrough.md @@ -24,7 +24,7 @@ This demo has only one element, in which the following four models are implement ## 2. Code Analysis -Code initialization part reference [Initializing the Bluetooth and Initializing the BLE Mesh](../../../ble_mesh_wifi_coexist/tutorial%20%20%20%20%20%20/ble_mesh_wifi_coexist.md) +Code initialization part reference [Initializing Bluetooth and BLE Mesh](../../../ble_mesh_wifi_coexist/tutorial/BLE_Mesh_WiFi_Coexist_Example_Walkthrough.md). ### 2.1 Data Structure diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c index b5fe155ac..26324d939 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c @@ -32,6 +32,8 @@ #include "ble_mesh_fast_prov_server_model.h" #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + extern struct _led_state led_state[3]; extern struct k_delayed_work send_self_prov_node_addr_timer; extern bt_mesh_atomic_t fast_prov_cli_flags; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid index 76f1d236f..7c6d6eb47 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.bluedroid @@ -11,4 +11,5 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_FAST_PROV=y CONFIG_BLE_MESH_PB_GATT=y -CONFIG_BLE_MESH_CFG_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_CFG_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble index 6efbebf50..adfeb6da7 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.ci.nimble @@ -10,4 +10,5 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_FAST_PROV=y CONFIG_BLE_MESH_PB_GATT=y -CONFIG_BLE_MESH_CFG_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_CFG_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.defaults b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.defaults index a8808f2ae..4bfc8de8a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.defaults +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/sdkconfig.defaults @@ -22,4 +22,4 @@ CONFIG_BLE_MESH_ADV_BUF_COUNT=200 CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=10 CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=10 CONFIG_BLE_MESH_TRACE_LEVEL_ERROR=y -CONFIG_BLE_MESH_CFG_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_CFG_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/BLE_Mesh_Fast_Prov_Server_Example_Walkthrough.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/BLE_Mesh_Fast_Prov_Server_Example_Walkthrough.md index d1e597cda..adeebab42 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/BLE_Mesh_Fast_Prov_Server_Example_Walkthrough.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/BLE_Mesh_Fast_Prov_Server_Example_Walkthrough.md @@ -18,7 +18,7 @@ This demo has only one element, where the following five Models are implemented: ## 2. Code Analysis -Code initialization part reference [Initializing the Bluetooth and Initializing the BLE Mesh](../../../ble_mesh_wifi_coexist/tutorial%20%20%20%20%20%20/ble_mesh_wifi_coexist.md) +Code initialization part reference [Initializing Bluetooth and BLE Mesh](../../../ble_mesh_wifi_coexist/tutorial/BLE_Mesh_WiFi_Coexist_Example_Walkthrough.md). ### 2.1 Data Structure diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/EspBleMesh.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/EspBleMesh.md index dd75437c9..f5570b6fe 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/EspBleMesh.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/tutorial/EspBleMesh.md @@ -2,18 +2,17 @@ This demo demonstrates the fast provisioning of ESP BLE Mesh network and how to use the EspBleMesh app to control an individual provisioned node or all the provisioned nodes. -A video of this demo can be seen -[here](http://download.espressif.com/BLE_MESH/BLE_Mesh_Demo/V0.4_Demo_Fast_Provision/ESP32_BLE_Mesh_Fast_Provision.mp4) +A video of this example can be seen from [here](http://download.espressif.com/BLE_MESH/BLE_Mesh_Demo/V0.4_Demo_Fast_Provision/ESP32_BLE_Mesh_Fast_Provision.mp4). # What You Need -* [EspBleMesh App for Android](http://download.espressif.com/BLE_MESH/BLE_Mesh_Tools/BLE_Mesh_App/EspBleMesh-0.9.4.apk) -* [ESP BLE Mesh SDK v0.6(Beta Version)](https://glab.espressif.cn/ble_mesh/esp-ble-mesh-v0.6) +* [EspBleMesh App for Android](https://github.com/EspressifApp/EspBLEMeshForAndroid/releases/tag/v1.1.0) +* [esp-idf](https://github.com/espressif/esp-idf) * ESP32 Development Boards > Note: > -> 1. Please flash the [`fast_prov_server`](https://glab.espressif.cn/ble_mesh/esp-ble-mesh-v0.6/tree/ble_mesh_release/esp-ble-mesh-v0.6/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server) to your boards first; +> 1. Please flash the [`fast_prov_server`](https://github.com/espressif/esp-idf/tree/release/v3.3/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server) to the development boards first; > 2. To have a better understanding of the performance of the BLE Mesh network, we recommend that at least 3 devices should be added in your network. > 3. We recommend that you solder LED indicators if your development board does not come with lights. > 4. Please check the type of board and LED pin definition enabled in `Example BLE Mesh Config` by running `idf.py menuconfig` diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.c index ce8f599af..ff0c2a65d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.c @@ -9,7 +9,7 @@ #include -#include "driver/uart.h" +#include "driver/gpio.h" #include "esp_log.h" #include "iot_button.h" diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c index ad6b5c3fa..9b642cf81 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c @@ -23,6 +23,8 @@ #include "ble_mesh_example_init.h" #include "ble_mesh_example_nvs.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 static uint8_t dev_uuid[16] = { 0xdd, 0xdd }; @@ -270,12 +272,16 @@ static esp_err_t ble_mesh_init(void) esp_ble_mesh_register_config_server_callback(example_ble_mesh_config_server_cb); err = esp_ble_mesh_init(&provision, &composition); - if (err) { - ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err); return err; } - esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err); + return err; + } ESP_LOGI(TAG, "BLE Mesh Node initialized"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid index e9b0c0b0f..9bb13af5b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.bluedroid @@ -8,7 +8,10 @@ CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y CONFIG_BTU_TASK_STACK_SIZE=4512 +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Enable | Enable | Disable | CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble index 7e4af3ba9..14335d315 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.nimble @@ -10,4 +10,5 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy00 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy00 new file mode 100644 index 000000000..ffe217d40 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy00 @@ -0,0 +1,17 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Disable | Disable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_GATT_PROXY_SERVER=n +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy01 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy01 new file mode 100644 index 000000000..219a495d4 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy01 @@ -0,0 +1,16 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Disable | Enable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy02 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy02 new file mode 100644 index 000000000..e212fccea --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy02 @@ -0,0 +1,18 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Disable | Disable | Enable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_GATT_PROXY_SERVER=n +CONFIG_BLE_MESH_GATT_PROXY_CLIENT=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy03 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy03 new file mode 100644 index 000000000..63b2e21f9 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy03 @@ -0,0 +1,17 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Enable | Disable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_GATT_PROXY_SERVER=n +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy04 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy04 new file mode 100644 index 000000000..5f243c626 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy04 @@ -0,0 +1,18 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Enable | Enable | Disable | Enable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_GATT_PROXY_SERVER=n +CONFIG_BLE_MESH_GATT_PROXY_CLIENT=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy05 b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy05 new file mode 100644 index 000000000..714f8f3f0 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/sdkconfig.ci.proxy05 @@ -0,0 +1,18 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Server | Proxy Client | +#| Disable | Disable | Disable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_GATT_PROXY_SERVER=n +CONFIG_BLE_MESH_PROXY=n +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/tutorial/BLE_Mesh_Node_OnOff_Client_Example_Walkthrough.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/tutorial/BLE_Mesh_Node_OnOff_Client_Example_Walkthrough.md index 49697c2ab..0bb6f8e6d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/tutorial/BLE_Mesh_Node_OnOff_Client_Example_Walkthrough.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/tutorial/BLE_Mesh_Node_OnOff_Client_Example_Walkthrough.md @@ -38,7 +38,7 @@ You can choose from the 4 message sequences described below: ## 2. Code Analysis -Code initialization part reference [Initializing the Bluetooth and Initializing the BLE Mesh](../../ble_mesh_wifi_coexist/tutorial%20%20%20%20%20%20/ble_mesh_wifi_coexist.md) +Code initialization part reference [Initializing Bluetooth and BLE Mesh](../../../ble_mesh_wifi_coexist/tutorial/BLE_Mesh_WiFi_Coexist_Example_Walkthrough.md) ### 2.1 Model Definition diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c index 9a8b9fbe6..da54a5e5c 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c @@ -24,6 +24,8 @@ #include "board.h" #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 extern struct _led_state led_state[3]; @@ -283,19 +285,23 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t static esp_err_t ble_mesh_init(void) { - esp_err_t err; + esp_err_t err = ESP_OK; esp_ble_mesh_register_prov_callback(example_ble_mesh_provisioning_cb); esp_ble_mesh_register_config_server_callback(example_ble_mesh_config_server_cb); esp_ble_mesh_register_generic_server_callback(example_ble_mesh_generic_server_cb); err = esp_ble_mesh_init(&provision, &composition); - if (err) { - ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err); return err; } - esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err); + return err; + } ESP_LOGI(TAG, "BLE Mesh Node initialized"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid index 9b3d74764..c2f5b3c92 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.bluedroid @@ -10,4 +10,6 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y -CONFIG_BLE_MESH_PB_GATT=y \ No newline at end of file +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_FRIEND=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble index 9cb2c2db2..c8ad8d1ef 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/sdkconfig.ci.nimble @@ -10,3 +10,5 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_LOW_POWER=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c index 7521adb1c..3e3765983 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c @@ -21,6 +21,8 @@ #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + #define LED_OFF 0x0 #define LED_ON 0x1 @@ -582,7 +584,7 @@ static void example_ble_mesh_generic_client_cb(esp_ble_mesh_generic_client_cb_ev static esp_err_t ble_mesh_init(void) { uint8_t match[2] = {0xdd, 0xdd}; - esp_err_t err; + esp_err_t err = ESP_OK; prov_key.net_idx = ESP_BLE_MESH_KEY_PRIMARY; prov_key.app_idx = APP_KEY_IDX; @@ -592,18 +594,29 @@ static esp_err_t ble_mesh_init(void) esp_ble_mesh_register_config_client_callback(example_ble_mesh_config_client_cb); esp_ble_mesh_register_generic_client_callback(example_ble_mesh_generic_client_cb); - err = esp_ble_mesh_init(&provision, &composition); - if (err) { - ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err); return err; } - esp_ble_mesh_provisioner_set_dev_uuid_match(match, sizeof(match), 0x0, false); + err = esp_ble_mesh_provisioner_set_dev_uuid_match(match, sizeof(match), 0x0, false); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to set matching device uuid (err %d)", err); + return err; + } - esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err); + return err; + } - esp_ble_mesh_provisioner_add_local_app_key(prov_key.app_key, prov_key.net_idx, prov_key.app_idx); + err = esp_ble_mesh_provisioner_add_local_app_key(prov_key.app_key, prov_key.net_idx, prov_key.app_idx); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to add local AppKey (err %d)", err); + return err; + } ESP_LOGI(TAG, "BLE Mesh Provisioner initialized"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid index 935a2823f..b6051ba40 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.bluedroid @@ -7,8 +7,11 @@ CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y CONFIG_BTU_TASK_STACK_SIZE=4512 +#| Proxy | PB-GATT | Proxy Client | +#| Enable | Enable | Disable | CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble index 1d48f60f6..abc7bd361 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.nimble @@ -10,5 +10,6 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy00 b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy00 new file mode 100644 index 000000000..da5fd368f --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy00 @@ -0,0 +1,16 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Client | +#| Enable | Disable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy01 b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy01 new file mode 100644 index 000000000..9b55d0576 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy01 @@ -0,0 +1,17 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Client | +#| Enable | Disable | Enable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_GATT_PROXY_CLIENT=y +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy02 b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy02 new file mode 100644 index 000000000..a3bf24757 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy02 @@ -0,0 +1,17 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Client | +#| Enable | Enable | Enable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_GATT_PROXY_CLIENT=y +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy03 b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy03 new file mode 100644 index 000000000..5fec5b9c6 --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/sdkconfig.ci.proxy03 @@ -0,0 +1,17 @@ +CONFIG_BT_ENABLED=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=n +CONFIG_BTDM_CONTROLLER_MODE_BTDM=n +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n +CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=y +CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=y +CONFIG_BTU_TASK_STACK_SIZE=4512 + +#| Proxy | PB-GATT | Proxy Client | +#| Disable | Disable | Disable | +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_PB_GATT=n +CONFIG_BLE_MESH_PROXY=n +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/tutorial/BLE_Mesh_Provisioner_Example_Walkthrough.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/tutorial/BLE_Mesh_Provisioner_Example_Walkthrough.md index b1d2e1b74..13b31ab6d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/tutorial/BLE_Mesh_Provisioner_Example_Walkthrough.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/tutorial/BLE_Mesh_Provisioner_Example_Walkthrough.md @@ -3,7 +3,7 @@ ## 1. Introduction -This demo shows how a BLE Mesh device can function as a Provisioner. If you are new to BLE Mesh, please start by checking [Demo for ESP BLE Mesh Node](../../ble_mesh_node/README.md). +This example shows how a BLE Mesh device can function as a Provisioner. If you are new to BLE Mesh, please start by checking [BLE Mesh Node Example](../../ble_mesh_node/onoff_server/README.md). ## 2. Code Flow diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.c index 8bc2e44e5..0921ca2c5 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.c @@ -9,7 +9,6 @@ #include #include "esp_log.h" -#include "driver/uart.h" #include "iot_button.h" #include "esp_ble_mesh_sensor_model_api.h" diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c index 60e7d9c55..fe40bac9b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c @@ -22,6 +22,8 @@ #include "ble_mesh_example_init.h" #include "board.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 #define PROV_OWN_ADDR 0x0001 @@ -561,10 +563,11 @@ static void example_ble_mesh_sensor_client_cb(esp_ble_mesh_sensor_client_cb_even if (data_len != ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN) { ESP_LOG_BUFFER_HEX("Sensor Data", data + mpid_len, data_len + 1); length += mpid_len + data_len + 1; + data += mpid_len + data_len + 1; } else { length += mpid_len; + data += mpid_len; } - data += length; } } break; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid index dd2e1e459..6267fb4c2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.bluedroid @@ -10,5 +10,6 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y CONFIG_BLE_MESH_SENSOR_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble index 5b560cda0..b6ad29693 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/sdkconfig.ci.nimble @@ -10,5 +10,6 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y CONFIG_BLE_MESH_CFG_CLI=y CONFIG_BLE_MESH_SENSOR_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c index f0f1bfb13..e171ef661 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c @@ -23,6 +23,8 @@ #include "ble_mesh_example_init.h" #include "board.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 /* Sensor Property ID */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid index 60ecff460..3915673ca 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.bluedroid @@ -11,3 +11,4 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble index 9cb2c2db2..da51254dc 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/sdkconfig.ci.nimble @@ -10,3 +10,4 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.c index 0937ae7d7..5e57bcf01 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.c @@ -9,7 +9,6 @@ #include #include "esp_log.h" -#include "driver/uart.h" #include "iot_button.h" #define TAG "BOARD" diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c index 71645fcb9..ba5956a82 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c @@ -23,6 +23,8 @@ #include "ble_mesh_example_nvs.h" #include "board.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 #define PROV_OWN_ADDR 0x0001 diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid index 69ae022e7..8830dea3b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.bluedroid @@ -10,4 +10,5 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y -CONFIG_BLE_MESH_CFG_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_CFG_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble index 8ae6ff247..5d04543a8 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/sdkconfig.ci.nimble @@ -10,4 +10,5 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_PB_GATT=y -CONFIG_BLE_MESH_CFG_CLI=y \ No newline at end of file +CONFIG_BLE_MESH_SETTINGS=y +CONFIG_BLE_MESH_CFG_CLI=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c index af91c84bd..4d4decff4 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c @@ -24,6 +24,8 @@ #include "board.h" #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + #define CID_ESP 0x02E5 #define ESP_BLE_MESH_VND_MODEL_ID_CLIENT 0x0000 diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid index 9b3d74764..3915673ca 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.bluedroid @@ -10,4 +10,5 @@ CONFIG_BTU_TASK_STACK_SIZE=4512 CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y -CONFIG_BLE_MESH_PB_GATT=y \ No newline at end of file +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble index 3862f3d0f..da51254dc 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/sdkconfig.ci.nimble @@ -9,4 +9,5 @@ CONFIG_NIMBLE_ENABLED=y CONFIG_BLE_MESH=y CONFIG_BLE_MESH_NODE=y -CONFIG_BLE_MESH_PB_GATT=y \ No newline at end of file +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_SETTINGS=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/README.md b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/README.md index 8173486ff..da50c6148 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/README.md +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/README.md @@ -1,7 +1,7 @@ ESP BLE Mesh and WiFi Coexist example ======================== -此demo是用来测试当BLE Mesh实现正常的配网和收发消息的正常功能时,WiFi 所能达到的最大throughput值。用户可以根据此demo中的throughput值来实现自己需要的应用场景。如果用户对ESP32 BLE Mesh使用方法还不熟悉的话, 可以参考[BLE Mesh brief introduction](../ble_mesh_node/README.md) +此 example 是用来测试当 BLE Mesh 实现正常的配网和收发消息的正常功能时,Wi-Fi 所能达到的最大 throughput 值。用户可以根据此 example 中的 throughput 值来实现自己需要的应用场景。如果用户对 ESP32 BLE Mesh 的使用方法还不熟悉,请参考[BLE Mesh Node Example](../ble_mesh_node/onoff_server/README.md). 此demo主要分为两个部分: diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c index 8a7aee84e..95a92f2f2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c @@ -44,6 +44,8 @@ #include "ble_mesh_fast_prov_server_model.h" #include "ble_mesh_example_init.h" +#define TAG "EXAMPLE" + extern struct _led_state led_state[3]; extern struct k_delayed_work send_self_prov_node_addr_timer; extern bt_mesh_atomic_t fast_prov_cli_flags; @@ -749,9 +751,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/bluetooth/esp_ble_mesh/components/button/include/iot_button.h b/examples/bluetooth/esp_ble_mesh/components/button/include/iot_button.h index 0a8564d68..76333c100 100644 --- a/examples/bluetooth/esp_ble_mesh/components/button/include/iot_button.h +++ b/examples/bluetooth/esp_ble_mesh/components/button/include/iot_button.h @@ -19,7 +19,7 @@ extern "C" { #endif #include "driver/gpio.h" -#include "freertos/portmacro.h" +#include "freertos/FreeRTOS.h" typedef void (* button_cb)(void*); typedef void* button_handle_t; diff --git a/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.c b/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.c index 99a73adcd..982802df7 100644 --- a/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.c +++ b/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.c @@ -27,7 +27,8 @@ #endif #include "esp_ble_mesh_defs.h" -#include "ble_mesh_example_init.h" + +#define TAG "EXAMPLE_INIT" #ifdef CONFIG_BLUEDROID_ENABLED diff --git a/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.h b/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.h index 4d15a84ec..a0f2229cd 100644 --- a/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.h +++ b/examples/bluetooth/esp_ble_mesh/components/example_init/ble_mesh_example_init.h @@ -11,8 +11,6 @@ #include "esp_err.h" -#define TAG "EXAMPLE" - void ble_mesh_get_dev_uuid(uint8_t *dev_uuid); esp_err_t bluetooth_init(void); diff --git a/examples/bluetooth/nimble/blehr/blehr_test.py b/examples/bluetooth/nimble/blehr/blehr_test.py index 7cc10ed88..0801ae455 100644 --- a/examples/bluetooth/nimble/blehr/blehr_test.py +++ b/examples/bluetooth/nimble/blehr/blehr_test.py @@ -20,9 +20,13 @@ import sys import re import threading import traceback -import Queue import subprocess +try: + import Queue +except ImportError: + import queue as Queue + try: # This environment variable is expected on the host machine test_fw_path = os.getenv("TEST_FW_PATH") diff --git a/examples/bluetooth/nimble/bleprph/bleprph_test.py b/examples/bluetooth/nimble/bleprph/bleprph_test.py index 97bfeca97..00032d5cb 100644 --- a/examples/bluetooth/nimble/bleprph/bleprph_test.py +++ b/examples/bluetooth/nimble/bleprph/bleprph_test.py @@ -18,11 +18,15 @@ from __future__ import print_function import os import sys import re -import Queue import traceback import threading import subprocess +try: + import Queue +except ImportError: + import queue as Queue + try: # This environment variable is expected on the host machine test_fw_path = os.getenv("TEST_FW_PATH") diff --git a/examples/ethernet/iperf/main/iperf_example_main.c b/examples/ethernet/iperf/main/iperf_example_main.c index 479a192fb..7d1c46b7f 100644 --- a/examples/ethernet/iperf/main/iperf_example_main.c +++ b/examples/ethernet/iperf/main/iperf_example_main.c @@ -60,9 +60,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c index 7e24968a7..278b877ee 100644 --- a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c +++ b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c @@ -60,9 +60,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/protocols/asio/chat_client/components/wifi_asio.cpp b/examples/protocols/asio/chat_client/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/chat_client/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_client/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/chat_server/components/wifi_asio.cpp b/examples/protocols/asio/chat_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/chat_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/wifi_init/wifi_asio.cpp b/examples/protocols/asio/wifi_init/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/wifi_init/wifi_asio.cpp +++ b/examples/protocols/asio/wifi_init/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/pppos_client/README.md b/examples/protocols/pppos_client/README.md index bcfb8e503..90a88ab5f 100644 --- a/examples/protocols/pppos_client/README.md +++ b/examples/protocols/pppos_client/README.md @@ -14,7 +14,7 @@ When PPP connection has been established, the IP packet flow from application si ### Hardware Required To run this example, you need an ESP32 dev board (e.g. ESP32-WROVER Kit) or ESP32 core board (e.g. ESP32-DevKitC). -For test purpose, you also need a cellular modem module. Here we take the [SIM800L](http://www.simcom.com/product/showproduct.php?lang=en&id=277) and [BG96](https://www.quectel.com/product/bg96.htm) as an example. +For test purpose, you also need a cellular modem module. Here we take the [SIM800L](https://www.simcom.com/product/SIM800.html) and [BG96](https://www.quectel.com/product/bg96.htm) as an example. You can also try other modules as long as they embedded PPP protocol. **Note:** Since SIM800L only support **2G** which will **not** work in some countries. And also keep in mind that in some other countries it will stop working soon (many remaining 2G networks will be switched off in the next 2-3 years). So you should **check with your local providers for further details** if you try this example with any 2G modules. diff --git a/examples/storage/parttool/example_test.py b/examples/storage/parttool/example_test.py index 6ba90c175..de4f1cf05 100644 --- a/examples/storage/parttool/example_test.py +++ b/examples/storage/parttool/example_test.py @@ -34,7 +34,7 @@ def test_examples_parttool(env, extra_data): binary_path = flash_file[1] break - subprocess.check_call([sys.executable, script_path, "--binary", binary_path]) + subprocess.check_call([sys.executable, script_path, "--binary", binary_path, "--port", dut.port]) if __name__ == '__main__': diff --git a/examples/system/app_trace_to_host/README.md b/examples/system/app_trace_to_host/README.md index 1abb8bde6..012fab03b 100644 --- a/examples/system/app_trace_to_host/README.md +++ b/examples/system/app_trace_to_host/README.md @@ -13,7 +13,7 @@ For more description of [logging to host](https://docs.espressif.com/projects/es Debugging of time critical functions may not work as desired if log messages are sent through the UART port. Printing out the logs may considerably slow down tested function to the point where it will not operate as expected. -Let's consider a case we are testing implementation of [zero level crossing](https://en.wikipedia.org/wiki/Zero_crossing) detection for a 50 Hz signal with ESP32's ADC. +Let's consider a case we are testing implementation of [zero level crossing](https://en.wikipedia.org/wiki/Zero_crossing) detection for a 50 Hz signal with ESP32's ADC. We will start by checking if we can read ADC, what is the signal level and how many samples can be collected over 20 ms period by using a code snippet below: @@ -36,7 +36,7 @@ I (4319) example: Sample:4, Value:27 I (4319) example: Sample:5, Value:4095 ``` -As you see we were able to collect only five samples. This seems rather not adequate for zero crossing detection. +As you see we were able to collect only five samples. This seems rather not adequate for zero crossing detection. We can remove `ESP_LOGI()` line and sample much faster, but then will not be able to see the values. To see the values we would need to save them in the memory and print out later. @@ -46,7 +46,7 @@ Instead of saving samples to memory, a simple and compelling solution to this is esp_log_set_vprintf(esp_apptrace_vprintf); ``` -Once time critical messages are sent out, we can redirect `ESP_LOGx` back back to the UART by adding extra two lines of code. +Once time critical messages are sent out, we can redirect `ESP_LOGx` back back to the UART by adding extra two lines of code. ```c esp_log_set_vprintf(vprintf); @@ -176,7 +176,7 @@ This is the log we have been looking for, complete with timestamps as if printed ## Example Output -Check the full example code [app_trace_to_host](main/app_trace_to_host_test.c) that combines both tests above and runs them in a loop showing instantly the number of samples collected: +Check the full example code [app_trace_to_host](main/app_trace_to_host_example_main.c) that combines both tests above and runs them in a loop showing instantly the number of samples collected: ``` I (4289) example: Sampling ADC and sending data to the host... @@ -199,7 +199,7 @@ With this example code we have demonstrated powerful functionality of logging to ## Troubleshooting 1. I can not flash new firmware when OpenOCD is connected to ESP32. - * One likely cause would be that you set wrong SPI flash voltage when you start OpenOCD. Suppose you're working with an ESP32 board / module which has a 3.3V powered SPI flash, but you select + * One likely cause would be that you set wrong SPI flash voltage when you start OpenOCD. Suppose you're working with an ESP32 board / module which has a 3.3V powered SPI flash, but you select `board/esp32-wrover.cfg` configuration file when start OpenOCD. In this situation, you might not be able to flash ESP32 when OpenOCD is connected. So make sure what the working voltage of the SPI flash is. Currently, for 1.8V flash, we'd like to suggest using `board/esp32-wrover.cfg` and for 3.3V flash, using `board/esp-wroom-32.cfg`. For more information about it, please refer to [ESP32 Modules and Boards](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html) and [Set SPI Flash Voltage](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/tips-and-quirks.html#why-to-set-spi-flash-voltage-in-openocd-configuration). (For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.) diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index ba16a9e61..b5a156d98 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -63,9 +63,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/system/ota/advanced_https_ota/example_test.py b/examples/system/ota/advanced_https_ota/example_test.py index 26a96ff38..c8255ea01 100644 --- a/examples/system/ota/advanced_https_ota/example_test.py +++ b/examples/system/ota/advanced_https_ota/example_test.py @@ -2,11 +2,16 @@ import re import os import sys import socket -import BaseHTTPServer -import SimpleHTTPServer from threading import Thread import ssl +try: + import BaseHTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler +except ImportError: + import http.server as BaseHTTPServer + from http.server import SimpleHTTPRequestHandler + try: import IDF except ImportError: @@ -110,7 +115,7 @@ def get_ca_cert(ota_image_dir): def start_https_server(ota_image_dir, server_ip, server_port): server_file, key_file = get_ca_cert(ota_image_dir) httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - SimpleHTTPServer.SimpleHTTPRequestHandler) + SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, @@ -128,7 +133,7 @@ def redirect_handler_factory(url): """ Returns a request handler class that redirects to supplied `url` """ - class RedirectHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + class RedirectHandler(SimpleHTTPRequestHandler): def do_GET(self): print("Sending resp, URL: " + url) self.send_response(301) diff --git a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c index 3ec256a4d..e4217e623 100644 --- a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c +++ b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c @@ -56,9 +56,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/system/ota/advanced_https_ota/sdkconfig.ci b/examples/system/ota/advanced_https_ota/sdkconfig.ci index 73f41c336..0a78f8da9 100644 --- a/examples/system/ota/advanced_https_ota/sdkconfig.ci +++ b/examples/system/ota/advanced_https_ota/sdkconfig.ci @@ -1,4 +1,4 @@ CONFIG_FIRMWARE_UPGRADE_URL="FROM_STDIN" CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y -CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000 +CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000 diff --git a/examples/system/ota/native_ota_example/example_test.py b/examples/system/ota/native_ota_example/example_test.py index 1ad6a1777..db0e266cf 100644 --- a/examples/system/ota/native_ota_example/example_test.py +++ b/examples/system/ota/native_ota_example/example_test.py @@ -2,11 +2,16 @@ import re import os import sys import socket -import BaseHTTPServer -import SimpleHTTPServer from threading import Thread import ssl +try: + import BaseHTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler +except ImportError: + import http.server as BaseHTTPServer + from http.server import SimpleHTTPRequestHandler + try: import IDF except ImportError: @@ -110,7 +115,7 @@ def get_ca_cert(ota_image_dir): def start_https_server(ota_image_dir, server_ip, server_port): server_file, key_file = get_ca_cert(ota_image_dir) httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - SimpleHTTPServer.SimpleHTTPRequestHandler) + SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, diff --git a/examples/system/ota/native_ota_example/main/native_ota_example.c b/examples/system/ota/native_ota_example/main/native_ota_example.c index 744e4ef21..2d8243e76 100644 --- a/examples/system/ota/native_ota_example/main/native_ota_example.c +++ b/examples/system/ota/native_ota_example/main/native_ota_example.c @@ -67,9 +67,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/system/ota/native_ota_example/sdkconfig.ci b/examples/system/ota/native_ota_example/sdkconfig.ci index afb368a21..c734d00be 100644 --- a/examples/system/ota/native_ota_example/sdkconfig.ci +++ b/examples/system/ota/native_ota_example/sdkconfig.ci @@ -1,4 +1,4 @@ CONFIG_FIRMWARE_UPG_URL="FROM_STDIN" CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y -CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000 +CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000 diff --git a/examples/system/ota/otatool/README.md b/examples/system/ota/otatool/README.md index c14e1cfb0..910aad59d 100644 --- a/examples/system/ota/otatool/README.md +++ b/examples/system/ota/otatool/README.md @@ -1,12 +1,12 @@ # OTA Tool Example -This example demonstrates common operations the OTA tool [otatool.py](../../../components/app_update/otatool.py) allows the user to perform: +This example demonstrates common operations the OTA tool [otatool.py](../../../../components/app_update/otatool.py) allows the user to perform: - reading, writing and erasing OTA partitions, - switching boot partitions, and - switching to factory partition. -Users taking a look at this example should focus on the contents of the python script [otatool_example.py](otatool_example.py). The script contains programmatic invocations of the tool [otatool.py](../../../components/app_update/otatool.py) in Python for the operations mentioned above; and can serve as a guide for users wanting to do the same in their applications. +Users taking a look at this example should focus on the contents of the python script [otatool_example.py](otatool_example.py). The script contains programmatic invocations of the tool [otatool.py](../../../../components/app_update/otatool.py) in Python for the operations mentioned above; and can serve as a guide for users wanting to do the same in their applications. The built application in this example outputs the currently running partition, whose output is used to verify if the tool switched OTA partitions succesfully. The built application binary is written to all OTA partitions at the start of the example to be able to determine the running @@ -40,7 +40,7 @@ or run it using python otatool_example.py ``` -The script searches for valid target devices connected to the host and performs the operations on the first one it finds. This could present problems if there +The script searches for valid target devices connected to the host and performs the operations on the first one it finds. This could present problems if there are multiple viable target devices attached to the host. To perform the operations on a specific device, specify the port it is attached to during script invocation: ```bash diff --git a/examples/system/ota/simple_ota_example/example_test.py b/examples/system/ota/simple_ota_example/example_test.py index 7c732a542..7b168322a 100644 --- a/examples/system/ota/simple_ota_example/example_test.py +++ b/examples/system/ota/simple_ota_example/example_test.py @@ -2,11 +2,16 @@ import re import os import sys import socket -import BaseHTTPServer -import SimpleHTTPServer from threading import Thread import ssl +try: + import BaseHTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler +except ImportError: + import http.server as BaseHTTPServer + from http.server import SimpleHTTPRequestHandler + try: import IDF except ImportError: @@ -99,7 +104,7 @@ def start_https_server(ota_image_dir, server_ip, server_port): key_file_handle.close() httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - SimpleHTTPServer.SimpleHTTPRequestHandler) + SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index c06d6297c..7d0c58328 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -56,9 +56,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/system/ulp/README.md b/examples/system/ulp/README.md index 4b2c5341a..f46f3f715 100644 --- a/examples/system/ulp/README.md +++ b/examples/system/ulp/README.md @@ -2,7 +2,7 @@ This example demonstrates how to program the ULP coprocessor to count pulses on an IO while the main CPUs are either running some other code or are in deep sleep. See the README.md file in the upper level 'examples' directory for more information about examples. -ULP program written in assembly can be found in `ulp/pulse_cnt.S`. The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application. +ULP program written in assembly can be found across `ulp/pulse_cnt.S` and `ulp/wake_up.S` (demonstrating multiple ULP source files). The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application. At runtime, the main code running on the ESP32 (found in main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_load_binary` function. Main code configures the ULP program by setting up values of some variables and then starts it using `ulp_run`. Once the ULP program is started, it runs periodically, with the period set by the main program. The main program enables ULP wakeup source and puts the chip into deep sleep mode. diff --git a/examples/system/ulp/main/CMakeLists.txt b/examples/system/ulp/main/CMakeLists.txt index 7b39598ce..77a9493bc 100644 --- a/examples/system/ulp/main/CMakeLists.txt +++ b/examples/system/ulp/main/CMakeLists.txt @@ -15,7 +15,7 @@ set(ULP_APP_NAME ulp_${COMPONENT_NAME}) # 2. Specify all assembly source files here. # Files should be placed into a separate directory (in this case, ulp/), # which should not be added to COMPONENT_SRCS. -set(ULP_S_SOURCES "ulp/pulse_cnt.S") +set(ULP_S_SOURCES "ulp/pulse_cnt.S" "ulp/wake_up.S") # # 3. List all the component source files which include automatically # generated ULP export file, $(ULP_APP_NAME).h: diff --git a/examples/system/ulp/main/component.mk b/examples/system/ulp/main/component.mk index 566757a56..55c5ba352 100644 --- a/examples/system/ulp/main/component.mk +++ b/examples/system/ulp/main/component.mk @@ -11,7 +11,7 @@ ULP_APP_NAME ?= ulp_$(COMPONENT_NAME) # Files should be placed into a separate directory (in this case, ulp/), # which should not be added to COMPONENT_SRCDIRS. ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \ - pulse_cnt.S \ + pulse_cnt.S wake_up.S\ ) # # 3. List all the component object files which include automatically diff --git a/examples/system/ulp/main/ulp/pulse_cnt.S b/examples/system/ulp/main/ulp/pulse_cnt.S index 774375e2a..33e6ef686 100644 --- a/examples/system/ulp/main/ulp/pulse_cnt.S +++ b/examples/system/ulp/main/ulp/pulse_cnt.S @@ -144,14 +144,3 @@ edge_detected: jump wake_up, eq /* Not yet. End program */ halt - - .global wake_up -wake_up: - /* Check if the system can be woken up */ - READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP) - and r0, r0, 1 - jump wake_up, eq - - /* Wake up the SoC, end program */ - wake - halt diff --git a/examples/system/ulp/main/ulp/wake_up.S b/examples/system/ulp/main/ulp/wake_up.S new file mode 100644 index 000000000..ec2e05da4 --- /dev/null +++ b/examples/system/ulp/main/ulp/wake_up.S @@ -0,0 +1,16 @@ +/* ULP assembly files are passed through C preprocessor first, so include directives + and C macros may be used in these files + */ +#include "soc/rtc_cntl_reg.h" +#include "soc/soc_ulp.h" + + .global wake_up +wake_up: + /* Check if the system can be woken up */ + READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP) + and r0, r0, 1 + jump wake_up, eq + + /* Wake up the SoC, end program */ + wake + halt diff --git a/examples/wifi/iperf/main/iperf_example_main.c b/examples/wifi/iperf/main/iperf_example_main.c index 50779b3e2..de44984e9 100644 --- a/examples/wifi/iperf/main/iperf_example_main.c +++ b/examples/wifi/iperf/main/iperf_example_main.c @@ -32,9 +32,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c index fcd01d8b6..3865f1bea 100644 --- a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c +++ b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c @@ -79,9 +79,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK(uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/make/project.mk b/make/project.mk index fff108d69..90f97650c 100644 --- a/make/project.mk +++ b/make/project.mk @@ -270,7 +270,7 @@ endif # If we have `version.txt` then prefer that for extracting IDF version ifeq ("$(wildcard ${IDF_PATH}/version.txt)","") -IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty) +IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --dirty) else IDF_VER_T := `cat ${IDF_PATH}/version.txt` endif diff --git a/make/version.mk b/make/version.mk index f429bfe20..ea6d0a652 100644 --- a/make/version.mk +++ b/make/version.mk @@ -1,3 +1,3 @@ IDF_VERSION_MAJOR := 3 IDF_VERSION_MINOR := 3 -IDF_VERSION_PATCH := 2 +IDF_VERSION_PATCH := 4 diff --git a/tools/ble/__init__.py b/tools/ble/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tools/ble/lib_ble_client.py b/tools/ble/lib_ble_client.py index 6fda14288..4cc12dab5 100644 --- a/tools/ble/lib_ble_client.py +++ b/tools/ble/lib_ble_client.py @@ -35,8 +35,13 @@ except ImportError as e: print("Run `pip install -r $IDF_PATH/tools/ble/requirements.txt` for resolving the issue") raise -import lib_gatt -import lib_gap +try: + import lib_gatt + import lib_gap +except ImportError: + # for python3 assign_test + from . import lib_gatt + from . import lib_gap srv_added_old_cnt = 0 srv_added_new_cnt = 0 diff --git a/tools/ci/check_idf_version.sh b/tools/ci/check_idf_version.sh index 143acf592..86a4a4469 100755 --- a/tools/ci/check_idf_version.sh +++ b/tools/ci/check_idf_version.sh @@ -33,7 +33,7 @@ cmake_ver_minor=$(get_ver_from_cmake IDF_VERSION_MINOR) cmake_ver_patch=$(get_ver_from_cmake IDF_VERSION_PATCH) version_from_cmake="${cmake_ver_major}.${cmake_ver_minor}.${cmake_ver_patch}" -git_desc=$(git describe --tags) +git_desc=$(git describe) git_desc_regex="^v([0-9]+)\.([0-9]+)(\.([0-9]+))?.*$" if [[ ! ${git_desc} =~ ${git_desc_regex} ]]; then echo "Could not determine the version from 'git describe' output: ${git_desc}" diff --git a/tools/ci/checkout_project_ref.py b/tools/ci/checkout_project_ref.py index e9c060a1b..d9d040254 100755 --- a/tools/ci/checkout_project_ref.py +++ b/tools/ci/checkout_project_ref.py @@ -35,7 +35,7 @@ def target_branch_candidates(proj_name): pass # branch name read from IDF try: - git_describe = subprocess.check_output(["git", "describe", "--tags", "HEAD"]) + git_describe = subprocess.check_output(["git", "describe", "HEAD"]) match = IDF_GIT_DESCRIBE_PATTERN.search(git_describe.decode()) if match: major_revision = match.group(1) @@ -68,7 +68,7 @@ if __name__ == "__main__": for candidate in candidate_branches: try: - subprocess.check_call(["git", "checkout", candidate]) + subprocess.check_call(["git", "checkout", "-f", candidate], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # not print the stdout nor stderr print("CI using ref {} for project {}".format(candidate, args.project)) break except subprocess.CalledProcessError: diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 4d9e2ce8f..74c5a9fbb 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -29,6 +29,7 @@ tools/ci/get-full-sources.sh tools/ci/mirror-submodule-update.sh tools/ci/mirror-synchronize.sh tools/ci/push_to_github.sh +tools/ci/retry_failed.sh tools/ci/test_build_system.sh tools/ci/test_build_system_cmake.sh tools/ci/test_configure_ci_environment.sh diff --git a/tools/ci/retry_failed.sh b/tools/ci/retry_failed.sh new file mode 100755 index 000000000..2da480b47 --- /dev/null +++ b/tools/ci/retry_failed.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# Retries a command RETRY_ATTEMPTS times in case of failure +# +# Inspired by https://stackoverflow.com/a/8351489 +# + +max_attempts=${RETRY_ATTEMPTS-3} +RETRY_TIMEWAIT=${RETRY_TIMEWAIT-1} +attempt=1 +exitCode=0 +whole_start=$(date +%s) +attempt_start=whole_start + +while true; do + if "$@" ; then + exitCode=0 + break + else + exitCode=$? + fi + + if (( $attempt >= $max_attempts )) ; then + break + fi + + echo "Failed! ("$@") Spent time $(( $(date '+%s') - ${attempt_start} )) sec. Retrying in ${RETRY_TIMEWAIT}..." 1>&2 + sleep $RETRY_TIMEWAIT + attempt=$(( attempt + 1 )) + RETRY_TIMEWAIT=$(( RETRY_TIMEWAIT * 2 )) + attempt_start=$(date +%s) +done + +if [[ $exitCode != 0 ]] ; then + echo -n "Totally failed! ("$@")" 1>&2 +else + echo -n "Done ("$@")" 1>&2 +fi + +echo " Spent time $(( $(date '+%s') - ${whole_start} )) sec in total" 1>&2 + +exit $exitCode diff --git a/tools/ci/setup_python.sh b/tools/ci/setup_python.sh index c134ba816..fac76cab4 100644 --- a/tools/ci/setup_python.sh +++ b/tools/ci/setup_python.sh @@ -1,11 +1,10 @@ #! /bin/bash # Regexp for matching job names which are incompatible with Python 3 -# - assign_test, nvs_compatible_test, IT - auto_test_script causes the incompatibility # - UT_009_ - multi-device tests are not compatible # - UT_014_ - multi-device tests are not compatible # - UT_017_ - multi-device tests are not compatible -py3_incomp='assign_test|nvs_compatible_test|IT|UT_009_|UT_013_|UT_014_|UT_017_' +py3_incomp='UT_009_|UT_013_|UT_014_|UT_017_' if [ -z ${PYTHON_VER+x} ] || [[ $CI_JOB_NAME =~ $py3_incomp ]]; then # Use this version of the Python interpreter if it was not defined before or diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index c4553e941..d99efd5a0 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -350,6 +350,10 @@ function run_tests() (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround" rm sdkconfig.defaults + print_status "Displays partition table when executing target partition_table" + idf.py partition_table | grep -E "# Espressif .+ Partition Table" + rm -r build + print_status "Make sure a full build never runs '/usr/bin/env python' or similar" OLDPATH="$PATH" PYTHON="$(which python)" diff --git a/tools/cmake/scripts/data_file_embed_asm.cmake b/tools/cmake/scripts/data_file_embed_asm.cmake index 291f9fea2..0422ed185 100644 --- a/tools/cmake/scripts/data_file_embed_asm.cmake +++ b/tools/cmake/scripts/data_file_embed_asm.cmake @@ -38,9 +38,7 @@ string(REGEX REPLACE "[^\n]+$" ".byte \\0\n" data "${data}") string(REGEX REPLACE "[0-9a-f][0-9a-f]" "0x\\0, " data "${data}") # hex formatted C bytes string(REGEX REPLACE ", \n" "\n" data "${data}") # trim the last comma -## Come up with C-friendly symbol name based on source file -get_filename_component(source_filename "${DATA_FILE}" NAME) -string(MAKE_C_IDENTIFIER "${source_filename}" varname) +get_filename_component(varname "${DATA_FILE}" NAME) function(append str) file(APPEND "${SOURCE_FILE}" "${str}") @@ -50,13 +48,14 @@ function(append_line str) append("${str}\n") endfunction() -function(append_identifier symbol) -append_line("\n.global ${symbol}") -append("${symbol}:") -if(${ARGC} GREATER 1) # optional comment - append(" /* ${ARGV1} */") -endif() -append("\n") +function(make_and_append_identifier str) + string(MAKE_C_IDENTIFIER "${str}" symbol) + append_line("\n.global ${symbol}") + append("${symbol}:") + if(${ARGC} GREATER 1) # optional comment + append(" /* ${ARGV1} */") + endif() + append("\n") endfunction() file(WRITE "${SOURCE_FILE}" "/*") @@ -68,16 +67,15 @@ append_line(" */") append_line(".data") append_line(".section .rodata.embedded") -append_identifier("${varname}") -append_identifier("_binary_${varname}_start" "for objcopy compatibility") +make_and_append_identifier("${varname}") +make_and_append_identifier("_binary_${varname}_start" "for objcopy compatibility") append("${data}") - -append_identifier("_binary_${varname}_end" "for objcopy compatibility") +make_and_append_identifier("_binary_${varname}_end" "for objcopy compatibility") append_line("") if(FILE_TYPE STREQUAL "TEXT") - append_identifier("${varname}_length" "not including null byte") + make_and_append_identifier("${varname}_length" "not including null byte") else() - append_identifier("${varname}_length") + make_and_append_identifier("${varname}_length") endif() append_line(".word ${data_len}") diff --git a/tools/cmake/third_party/GetGitRevisionDescription.cmake.in b/tools/cmake/third_party/GetGitRevisionDescription.cmake.in index 6d8b708ef..0cf025b14 100644 --- a/tools/cmake/third_party/GetGitRevisionDescription.cmake.in +++ b/tools/cmake/third_party/GetGitRevisionDescription.cmake.in @@ -24,10 +24,12 @@ if(HEAD_CONTENTS MATCHES "ref") if(EXISTS "@GIT_DIR@/${HEAD_REF}") configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) else() - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") + if(EXISTS "@GIT_DIR@/packed-refs") + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() endif() endif() else() diff --git a/tools/cmake/version.cmake b/tools/cmake/version.cmake index 3dab26aa3..1018bad91 100644 --- a/tools/cmake/version.cmake +++ b/tools/cmake/version.cmake @@ -1,3 +1,3 @@ set(IDF_VERSION_MAJOR 3) set(IDF_VERSION_MINOR 3) -set(IDF_VERSION_PATCH 2) +set(IDF_VERSION_PATCH 4) diff --git a/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index 0b55263c3..5671c4772 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -40,13 +40,13 @@ import textwrap import functools # list files here which should not be parsed -ignore_files = ['components/mdns/test_afl_fuzz_host/esp32_compat.h'] +ignore_files = [os.path.join('components', 'mdns', 'test_afl_fuzz_host', 'esp32_compat.h')] # add directories here which should not be parsed -ignore_dirs = ('examples') +ignore_dirs = os.path.join('examples') # macros from here have higher priorities in case of collisions -priority_headers = ['components/esp32/include/esp_err.h'] +priority_headers = [os.path.join('components', 'esp32', 'include', 'esp_err.h')] err_dict = collections.defaultdict(list) # identified errors are stored here; mapped by the error code rev_err_dict = dict() # map of error string to error code diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 4ccb7a9d2..6341218f7 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -837,7 +837,7 @@ def get_python_env_path(): with open(version_file_path, "r") as version_file: idf_version_str = version_file.read() else: - idf_version_str = subprocess.check_output(['git', '--work-tree=' + global_idf_path, 'describe', '--tags'], cwd=global_idf_path, env=os.environ).decode() + idf_version_str = subprocess.check_output(['git', '--work-tree=' + global_idf_path, 'describe'], cwd=global_idf_path, env=os.environ).decode() match = re.match(r'^v([0-9]+\.[0-9]+).*', idf_version_str) idf_version = match.group(1) diff --git a/tools/ldgen/generation.py b/tools/ldgen/generation.py index 4c0f1a8c4..76a5da1ed 100644 --- a/tools/ldgen/generation.py +++ b/tools/ldgen/generation.py @@ -21,7 +21,7 @@ import fnmatch from fragments import Sections, Scheme, Mapping, Fragment from pyparsing import Suppress, White, ParseException, Literal, Group, ZeroOrMore -from pyparsing import Word, OneOrMore, nums, alphanums, alphas, Optional, LineEnd, printables +from pyparsing import Word, OneOrMore, nums, alphanums, alphas, Optional, restOfLine from ldgen_common import LdGenFailure @@ -608,9 +608,9 @@ class SectionsInfo(dict): first_line = sections_info_file.readline() archive_path = (Literal("In archive").suppress() + - # trim the last character from archive_path, : - Word(printables + " ").setResultsName("archive_path").setParseAction(lambda t: t[0][:-1]) + - LineEnd()) + White().suppress() + + # trim the colon and line ending characters from archive_path + restOfLine.setResultsName("archive_path").setParseAction(lambda s, loc, toks: s.rstrip(":\n\r "))) parser = archive_path results = None diff --git a/tools/ldgen/test/data/sections.info b/tools/ldgen/test/data/sections.info index db450cfba..860d2163f 100644 --- a/tools/ldgen/test/data/sections.info +++ b/tools/ldgen/test/data/sections.info @@ -1,4 +1,4 @@ -In archive libfreertos.a: +In archive /home/user/ãóç+ěščřžýáíé/build/esp-idf/freertos/libfreertos.a: FreeRTOS-openocd.c.obj: file format elf32-xtensa-le diff --git a/tools/test_apps/build_system/embed_test/CMakeLists.txt b/tools/test_apps/build_system/embed_test/CMakeLists.txt new file mode 100644 index 000000000..37f6ccfc1 --- /dev/null +++ b/tools/test_apps/build_system/embed_test/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(file_embed_test) diff --git a/tools/test_apps/build_system/embed_test/README.txt b/tools/test_apps/build_system/embed_test/README.txt new file mode 100644 index 000000000..a847054bc --- /dev/null +++ b/tools/test_apps/build_system/embed_test/README.txt @@ -0,0 +1 @@ +This project tests that proper identifiers are generated during build for embedded files. diff --git a/tools/test_apps/build_system/embed_test/main/2file.txt b/tools/test_apps/build_system/embed_test/main/2file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/test_apps/build_system/embed_test/main/CMakeLists.txt b/tools/test_apps/build_system/embed_test/main/CMakeLists.txt new file mode 100644 index 000000000..cee0c41d0 --- /dev/null +++ b/tools/test_apps/build_system/embed_test/main/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRCS "test_main.c" + INCLUDE_DIRS "." + # Test file names starting with a number, a letter and an underscore. + EMBED_TXTFILES "2file.txt" "file.txt" "_file.txt") diff --git a/tools/test_apps/build_system/embed_test/main/_file.txt b/tools/test_apps/build_system/embed_test/main/_file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/test_apps/build_system/embed_test/main/file.txt b/tools/test_apps/build_system/embed_test/main/file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/test_apps/build_system/embed_test/main/test_main.c b/tools/test_apps/build_system/embed_test/main/test_main.c new file mode 100644 index 000000000..5c2881b80 --- /dev/null +++ b/tools/test_apps/build_system/embed_test/main/test_main.c @@ -0,0 +1,18 @@ +#include +#include + +extern uint8_t _2file_start[] asm("_binary_2file_txt_start"); +extern uint8_t _2file_end[] asm("_binary_2file_txt_end"); +extern uint8_t file_start[] asm("_binary_file_txt_start"); +extern uint8_t file_end[] asm("_binary_file_txt_start"); +extern uint8_t _file_start[] asm("_binary__file_txt_start"); +extern uint8_t _file_end[] asm("_binary__file_txt_start"); + +#define PRINT_ADDR(f) printf("%s -> start: %p end:%p\n", #f, f ## _start, f ## _end); + +void app_main(void) +{ + PRINT_ADDR(_2file); + PRINT_ADDR(file); + PRINT_ADDR(_file); +} diff --git a/tools/toolchain_versions.mk b/tools/toolchain_versions.mk index 741b52a51..dfca250a3 100644 --- a/tools/toolchain_versions.mk +++ b/tools/toolchain_versions.mk @@ -1,6 +1,6 @@ -SUPPORTED_TOOLCHAIN_COMMIT_DESC = crosstool-ng-1.22.0-96-g2852398 +SUPPORTED_TOOLCHAIN_COMMIT_DESC = crosstool-ng-1.22.0-97-gc752ad5 SUPPORTED_TOOLCHAIN_GCC_VERSIONS = 5.2.0 -CURRENT_TOOLCHAIN_COMMIT_DESC = crosstool-ng-1.22.0-96-g2852398 -CURRENT_TOOLCHAIN_COMMIT_DESC_SHORT = 1.22.0-96-g2852398 +CURRENT_TOOLCHAIN_COMMIT_DESC = crosstool-ng-1.22.0-97-gc752ad5 +CURRENT_TOOLCHAIN_COMMIT_DESC_SHORT = 1.22.0-97-gc752ad5 CURRENT_TOOLCHAIN_GCC_VERSION = 5.2.0 diff --git a/tools/tools.json b/tools/tools.json index 34853ae1d..6170f47fc 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -21,41 +21,41 @@ "version_regex_replace": "\\1-\\2", "versions": [ { - "name": "1.22.0-96-g28523988-5.2.0", + "name": "1.22.0-97-gc752ad58-5.2.0", "status": "recommended", "win32": { - "sha256": "8e2a2e25d4714ae6e4b992be1b1c261caed5b523b0cc0887b6749229c9febbb0", - "size": 125810912, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip" + "sha256": "80571e5d5a63494f4fa758bb9d8fb882ba4059853a8c412a84d232dc1c1400e6", + "size": 125747216, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip" }, "win64": { - "sha256": "8e2a2e25d4714ae6e4b992be1b1c261caed5b523b0cc0887b6749229c9febbb0", - "size": 125810912, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip" + "sha256": "80571e5d5a63494f4fa758bb9d8fb882ba4059853a8c412a84d232dc1c1400e6", + "size": 125747216, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip" } }, { "linux-amd64": { - "sha256": "798a8638f11ad37f41b9640582f869c61ffb4da6d932279fde94a2b636ad2dac", - "size": 44211883, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-96-g2852398-5.2.0.tar.gz" + "sha256": "96f5f6e7611a0ed1dc47048c54c3113fc5cebffbf0ba90d8bfcd497afc7ef9f3", + "size": 44225380, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-97-gc752ad5-5.2.0.tar.gz" }, "linux-armel": { - "sha256": "abfe06522f7c3479f6c7434c4bf926c50fa2039362b96abe95fa1f05ec519a9b", - "size": 50670980, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux-armel-1.22.0-96-g2852398-5.2.0.tar.gz" + "sha256": "d70d550f88448fa476b29fa50ef5502ab497a16ac7fa9ca24c6d0a39bb1e681e", + "size": 50657803, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux-armel-1.22.0-97-gc752ad5-5.2.0.tar.gz" }, "linux-i686": { - "sha256": "4eea601188aa8f3c3d45d7936ab4c0fabb75b4970dccf7a061de47dba49e377f", - "size": 45563578, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-96-g2852398-5.2.0.tar.gz" + "sha256": "8094a2c30b474e99ce64dd0ba8f310c4614eb3b3cac884a3aea0fd5f565af119", + "size": 45575521, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-97-gc752ad5-5.2.0.tar.gz" }, "macos": { - "sha256": "6aeae9547f0cd7e442d1df21821cea8b15d0a6ce349bbd86466e2997b738a99c", - "size": 50520203, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-macos-1.22.0-96-g2852398-5.2.0.tar.gz" + "sha256": "b1ce39a563ae359cf363fb7d8ee80cb1e5226fda83188203cff60f16f55e33ef", + "size": 50525386, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-macos-1.22.0-97-gc752ad5-5.2.0.tar.gz" }, - "name": "1.22.0-96-g2852398-5.2.0", + "name": "1.22.0-97-gc752ad5-5.2.0", "status": "recommended" } ] diff --git a/tools/unit-test-app/idf_ext.py b/tools/unit-test-app/idf_ext.py index 06b843f01..e7ce9b9d2 100644 --- a/tools/unit-test-app/idf_ext.py +++ b/tools/unit-test-app/idf_ext.py @@ -138,7 +138,7 @@ def add_action_extensions(base_functions, base_actions): set_config_build_variables("TEST_EXCLUDE_COMPONENTS","''") - with tempfile.NamedTemporaryFile() as sdkconfig_temp: + with tempfile.NamedTemporaryFile(delete=False) as sdkconfig_temp: # Use values from the combined defaults and the values from # config folder to build config sdkconfig_default = os.path.join(PROJECT_PATH, "sdkconfig.defaults") @@ -150,9 +150,7 @@ def add_action_extensions(base_functions, base_actions): with open(sdkconfig_config, "rb") as sdkconfig_config_file: sdkconfig_temp.write(b"\n") sdkconfig_temp.write(sdkconfig_config_file.read()) - - sdkconfig_temp.flush() - + try: try: args.define_cache_entry.append("SDKCONFIG_DEFAULTS=" + sdkconfig_temp.name) except AttributeError: @@ -160,6 +158,11 @@ def add_action_extensions(base_functions, base_actions): reconfigure = base_functions["reconfigure"] reconfigure(None, args) + finally: + try: + os.unlink(sdkconfig_temp.name) + except OSError: + pass else: if not config_name == "all-configs": print("unknown unit test app config for action '%s'" % ut_apply_config_name) diff --git a/tools/windows/eclipse_make.py b/tools/windows/eclipse_make.py index 76f510c0b..4f877ccf8 100644 --- a/tools/windows/eclipse_make.py +++ b/tools/windows/eclipse_make.py @@ -20,7 +20,7 @@ def check_path(path): pass paths[path] = path # cache as failed, replace with success if it works try: - winpath = subprocess.check_output(["cygpath", "-w", path]).strip() + winpath = subprocess.check_output(["cygpath", "-w", path]).decode().strip() except subprocess.CalledProcessError: return path # something went wrong running cygpath, assume this is not a path! if not os.path.exists(winpath): diff --git a/tools/windows/tool_setup/build_installer.sh b/tools/windows/tool_setup/build_installer.sh index 679d2dfcc..4d3e8eefa 100755 --- a/tools/windows/tool_setup/build_installer.sh +++ b/tools/windows/tool_setup/build_installer.sh @@ -21,7 +21,7 @@ if [ "$1" != "--no-download" ]; then cd `dirname $0` pushd dl - wget --continue "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip" + wget --continue "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip" wget --continue "https://github.com/espressif/binutils-esp32ulp/releases/download/v2.28.51-esp32ulp-20180809/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip" wget --continue "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20180920/openocd-esp32-win32-0.10.0-esp32-20180920.zip" wget --continue "https://github.com/espressif/kconfig-frontends/releases/download/v4.6.0.0-idf-20180525/mconf-v4.6.0.0-idf-20180525-win32.zip" @@ -30,7 +30,7 @@ if [ "$1" != "--no-download" ]; then rm -rf input/* pushd input - unzip ../dl/xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip + unzip ../dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip unzip ../dl/mconf-v4.6.0.0-idf-20180525-win32.zip unzip ../dl/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip unzip ../dl/openocd-esp32-win32-0.10.0-esp32-20180920.zip diff --git a/tools/windows/windows_install_prerequisites.sh b/tools/windows/windows_install_prerequisites.sh index ba6354809..4cbd5a886 100644 --- a/tools/windows/windows_install_prerequisites.sh +++ b/tools/windows/windows_install_prerequisites.sh @@ -42,7 +42,7 @@ if [ -n "$IDF_PATH" ]; then fi # Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/ -TOOLCHAIN_ZIP=xtensa-esp32-elf-win32-1.22.0-96-g2852398-5.2.0.zip +TOOLCHAIN_ZIP=xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..." cd ~ curl -LO --retry 10 http://dl.espressif.com/dl/${TOOLCHAIN_ZIP}