From 006b4456e74dea339efb3f8adb4e4313000177dd Mon Sep 17 00:00:00 2001 From: Yuan Hong Hui Date: Wed, 9 Feb 2022 06:18:42 +0000 Subject: [PATCH] filter repeated packages but not send response(v4.4) --- .../ble_mesh_console/main/ble_mesh_adapter.c | 21 ++++++---------- .../ble_mesh_console/main/ble_mesh_adapter.h | 18 ++++--------- .../ble_mesh_console/sdkconfig.defaults | 2 ++ .../sdkconfig.defaults.esp32c3 | 25 +++++++++++++++++++ .../sdkconfig.defaults.esp32s3 | 25 +++++++++++++++++++ 5 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32c3 create mode 100644 examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32s3 diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.c index 54e3dc1854..469bd06fae 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.c @@ -1,16 +1,9 @@ -// 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 +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ -// 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 "esp_ble_mesh_networking_api.h" #include "ble_mesh_adapter.h" @@ -116,9 +109,10 @@ int ble_mesh_node_statistics_accumulate(uint8_t *data, uint32_t value, uint16_t xSemaphoreTake(ble_mesh_node_sema, portMAX_DELAY); for (i = 0; i < ble_mesh_node_statistics.total_package_num; i++) { + /* Filter out repeated packages during retransmission */ if (ble_mesh_node_statistics.package_index[i] == sequence_num) { xSemaphoreGive(ble_mesh_node_sema); - return 1; + return 0; } } @@ -129,6 +123,7 @@ int ble_mesh_node_statistics_accumulate(uint8_t *data, uint32_t value, uint16_t } for (i = 0; i < ble_mesh_node_statistics.total_package_num; i++) { + /* Judge whether the package is received for the first time */ if (ble_mesh_node_statistics.package_index[i] == 0) { ble_mesh_node_statistics.package_index[i] = sequence_num; ble_mesh_node_statistics.package_num += 1; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.h index c3b79b2451..3ed7655b3a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_adapter.h @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _BLE_MESH_ADAPTER_H_ #define _BLE_MESH_ADAPTER_H_ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults index a18fe8b7ff..20e0b0db4b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults @@ -21,6 +21,8 @@ CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y CONFIG_BLE_MESH_PROVISIONER=y CONFIG_BLE_MESH_SELF_TEST=y CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK=y +CONFIG_BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM=80 +CONFIG_BLE_MESH_MAX_PROV_NODES=80 # partitions CONFIG_PARTITION_TABLE_CUSTOM=y diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32c3 b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32c3 new file mode 100644 index 0000000000..eee9ca57cd --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32c3 @@ -0,0 +1,25 @@ +# ESP32C3-specific +##Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_ENABLED=y +CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE=y +CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN=y +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BT_BTU_TASK_STACK_SIZE=4512 +CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y + +# Override some defaults of ESP BLE Mesh +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=3 +CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=3 +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_SELF_TEST=y +CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK=y +CONFIG_BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM=80 +CONFIG_BLE_MESH_MAX_PROV_NODES=80 + +# end of ESP32C3-specific diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32s3 b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32s3 new file mode 100644 index 0000000000..f5e28dbf1d --- /dev/null +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/sdkconfig.defaults.esp32s3 @@ -0,0 +1,25 @@ +# ESP32S3-specific +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_ENABLED=y +CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE=y +CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN=y +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y +CONFIG_BT_BTU_TASK_STACK_SIZE=4512 +CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y + +# Override some defaults of ESP BLE Mesh +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_NODE=y +CONFIG_BLE_MESH_PB_GATT=y +CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=3 +CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=3 +CONFIG_BLE_MESH_CFG_CLI=y +CONFIG_BLE_MESH_GENERIC_ONOFF_CLI=y +CONFIG_BLE_MESH_PROVISIONER=y +CONFIG_BLE_MESH_SELF_TEST=y +CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK=y +CONFIG_BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM=80 +CONFIG_BLE_MESH_MAX_PROV_NODES=80 + +# end of ESP32S3-specific