Skip to content

Commit

Permalink
Fix regression for esp32 BLE controller (#26347)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSONALl authored and pull[bot] committed Nov 23, 2023
1 parent 03cd85e commit 08a5ac1
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 38 deletions.
4 changes: 4 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ if ((CONFIG_BT_ENABLED) AND (CONFIG_ENABLE_CHIPOBLE))
endif()
endif()

if (CONFIG_ENABLE_ESP32_BLE_CONTROLLER)
chip_gn_arg_append("chip_enable_ble_controller" "true")
endif()

if (CONFIG_ENABLE_MATTER_OVER_THREAD)
chip_gn_arg_append("chip_enable_openthread" "true")
else()
Expand Down
7 changes: 0 additions & 7 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,6 @@ menu "CHIP Device Layer"
help
Enable esp32 as a BLE Commissioner.

config ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
bool "Enable Commissionee and Commissioner mode"
default n
depends on ENABLE_ESP32_BLE_Controller
help
Enable including commissioner code (CHIPDeviceController.cpp) in the commissionee (Server.cpp) code.

endmenu

endmenu
1 change: 1 addition & 0 deletions src/platform/ESP32/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class BLEManagerImpl final : public BLEManager,
#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER

void NewConnection(chip::Ble::BleLayer * bleLayer, void * appState, const SetupDiscriminator & connDiscriminator) override;
void NewConnection(chip::Ble::BleLayer * bleLayer, void * appState, BLE_CONNECTION_OBJECT connObj) override{};
CHIP_ERROR CancelConnection() override;

// ===== Members that implement virtual methods on ChipDeviceScannerDelegate
Expand Down
25 changes: 14 additions & 11 deletions src/platform/ESP32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ declare_args() {
chip_enable_chipoble = true
chip_bt_nimble_enabled = false
chip_bt_bluedroid_enabled = false
chip_enable_ble_controller = false
chip_use_secure_cert_dac_provider = false
}

Expand Down Expand Up @@ -90,20 +91,22 @@ static_library("ESP32") {
}

if (chip_bt_nimble_enabled) {
sources += [
"nimble/BLEManagerImpl.cpp",
"nimble/ChipDeviceScanner.cpp",
"nimble/blecent.h",
"nimble/misc.c",
"nimble/peer.c",
]
sources += [ "nimble/BLEManagerImpl.cpp" ]
if (chip_enable_ble_controller) {
sources += [
"nimble/ChipDeviceScanner.cpp",
"nimble/blecent.h",
"nimble/misc.c",
"nimble/peer.c",
]
}
}

if (chip_bt_bluedroid_enabled) {
sources += [
"bluedroid/BLEManagerImpl.cpp",
"bluedroid/ChipDeviceScanner.cpp",
]
sources += [ "bluedroid/BLEManagerImpl.cpp" ]
if (chip_enable_ble_controller) {
sources += [ "bluedroid/ChipDeviceScanner.cpp" ]
}
}

if (chip_enable_wifi) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/ESP32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@
#define CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION CONFIG_CHIP_KVS_NAMESPACE_PARTITION_LABEL
#define CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER
#define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS CONFIG_CHIP_DISCOVERY_TIMEOUT_SECS
#define CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
#define CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE CONFIG_ENABLE_ESP32_BLE_CONTROLLER
3 changes: 0 additions & 3 deletions src/platform/ESP32/nimble/ChipDeviceScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER

#include "blecent.h"
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
Expand Down Expand Up @@ -153,4 +151,3 @@ CHIP_ERROR ChipDeviceScanner::StopScan()
} // namespace Internal
} // namespace DeviceLayer
} // namespace chip
#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER
2 changes: 0 additions & 2 deletions src/platform/ESP32/nimble/blecent.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* under the License.
*/
#pragma once
#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER
#include <host/ble_gatt.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -107,4 +106,3 @@ struct peer * peer_find(uint16_t conn_handle);
#ifdef __cplusplus
}
#endif
#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER
2 changes: 0 additions & 2 deletions src/platform/ESP32/nimble/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER
#include "blecent.h"
#include "host/ble_hs.h"
#include "host/ble_uuid.h"
Expand Down Expand Up @@ -216,4 +215,3 @@ void print_adv_fields(const struct ble_hs_adv_fields * fields)
MODLOG_DFLT(DEBUG, "\n");
}
}
#endif // CONFIG_ENABLE_ESP32_BLE_CONTROLLER
22 changes: 10 additions & 12 deletions src/platform/ESP32/nimble/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

#if CONFIG_ENABLE_ESP32_BLE_CONTROLLER

#include "blecent.h"
#include "host/ble_hs.h"
#include <assert.h>
Expand Down Expand Up @@ -259,7 +257,8 @@ uint16_t chr_end_handle(const struct peer_svc * svc, const struct peer_chr * chr
next_chr = SLIST_NEXT(chr, next);
if (next_chr != NULL)
{
return next_chr->chr.def_handle - 1;
int result = next_chr->chr.def_handle - 1;
return (uint16_t) result;
}
else
{
Expand Down Expand Up @@ -763,56 +762,56 @@ int peer_init(int max_peers, int max_svcs, int max_chrs, int max_dscs)
/* Free memory first in case this function gets called more than once. */
peer_free_mem();

peer_mem = malloc(OS_MEMPOOL_BYTES(max_peers, sizeof(struct peer)));
peer_mem = malloc(OS_MEMPOOL_BYTES((uint16_t) max_peers, sizeof(struct peer)));
if (peer_mem == NULL)
{
rc = BLE_HS_ENOMEM;
goto err;
}

rc = os_mempool_init(&peer_pool, max_peers, sizeof(struct peer), peer_mem, "peer_pool");
rc = os_mempool_init(&peer_pool, (uint16_t) max_peers, sizeof(struct peer), peer_mem, "peer_pool");
if (rc != 0)
{
rc = BLE_HS_EOS;
goto err;
}

peer_svc_mem = malloc(OS_MEMPOOL_BYTES(max_svcs, sizeof(struct peer_svc)));
peer_svc_mem = malloc(OS_MEMPOOL_BYTES((uint16_t) max_svcs, sizeof(struct peer_svc)));
if (peer_svc_mem == NULL)
{
rc = BLE_HS_ENOMEM;
goto err;
}

rc = os_mempool_init(&peer_svc_pool, max_svcs, sizeof(struct peer_svc), peer_svc_mem, "peer_svc_pool");
rc = os_mempool_init(&peer_svc_pool, (uint16_t) max_svcs, sizeof(struct peer_svc), peer_svc_mem, "peer_svc_pool");
if (rc != 0)
{
rc = BLE_HS_EOS;
goto err;
}

peer_chr_mem = malloc(OS_MEMPOOL_BYTES(max_chrs, sizeof(struct peer_chr)));
peer_chr_mem = malloc(OS_MEMPOOL_BYTES((uint16_t) max_chrs, sizeof(struct peer_chr)));
if (peer_chr_mem == NULL)
{
rc = BLE_HS_ENOMEM;
goto err;
}

rc = os_mempool_init(&peer_chr_pool, max_chrs, sizeof(struct peer_chr), peer_chr_mem, "peer_chr_pool");
rc = os_mempool_init(&peer_chr_pool, (uint16_t) max_chrs, sizeof(struct peer_chr), peer_chr_mem, "peer_chr_pool");
if (rc != 0)
{
rc = BLE_HS_EOS;
goto err;
}

peer_dsc_mem = malloc(OS_MEMPOOL_BYTES(max_dscs, sizeof(struct peer_dsc)));
peer_dsc_mem = malloc(OS_MEMPOOL_BYTES((uint16_t) max_dscs, sizeof(struct peer_dsc)));
if (peer_dsc_mem == NULL)
{
rc = BLE_HS_ENOMEM;
goto err;
}

rc = os_mempool_init(&peer_dsc_pool, max_dscs, sizeof(struct peer_dsc), peer_dsc_mem, "peer_dsc_pool");
rc = os_mempool_init(&peer_dsc_pool, (uint16_t) max_dscs, sizeof(struct peer_dsc), peer_dsc_mem, "peer_dsc_pool");
if (rc != 0)
{
rc = BLE_HS_EOS;
Expand All @@ -825,4 +824,3 @@ int peer_init(int max_peers, int max_svcs, int max_chrs, int max_dscs)
peer_free_mem();
return rc;
}
#endif

0 comments on commit 08a5ac1

Please sign in to comment.