Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 101 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master

jobs:
build_esp_pio:
build_esp_pio_legacy:
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -48,16 +48,13 @@ jobs:
cp ${{ matrix.example }}/* example/src/
platformio run -d example

build_bt5_esp_pio:
build_bt5_esp_pio_legacy:
strategy:
fail-fast: false
matrix:
example:
- "examples/Bluetooth_5/NimBLE_extended_client"
- "examples/Bluetooth_5/NimBLE_extended_server"
variant:
- esp32c3
- esp32s3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -90,6 +87,99 @@ jobs:
cp ${{ matrix.example }}/* example/src/
platformio run -d example

build_esp_pioarduino:
strategy:
fail-fast: false
matrix:
example:
- "examples/NimBLE_Client"
- "examples/NimBLE_Server"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install platformio
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Build esp PIO
run: |
mkdir -p example/lib
rsync -Rr . example/lib/
mkdir example/src
cat > example/platformio.ini << EOF
[env]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino

[env:esp32dev]
board = esp32dev

[env:esp32c3]
board = esp32-c3-devkitm-1

[env:esp32s3]
board = esp32-s3-devkitc-1

[env:esp32c6]
board = esp32-c6-devkitc-1

[env:esp32h2]
board = esp32-h2-devkitm-1
EOF
cp ${{ matrix.example }}/* example/src/
platformio run -d example

build_bt5_esp_pioarduino:
strategy:
fail-fast: false
matrix:
example:
- "examples/Bluetooth_5/NimBLE_extended_client"
- "examples/Bluetooth_5/NimBLE_extended_server"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install platformio
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Build esp PIO
run: |
mkdir -p example/lib
rsync -Rr . example/lib/
mkdir example/src
cat > example/platformio.ini << EOF
[env]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino

[env:esp32c3]
board = esp32-c3-devkitm-1
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'

[env:esp32s3]
board = esp32-s3-devkitc-1
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'

[env:esp32c6]
board = esp32-c6-devkitc-1
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'

[env:esp32h2]
board = esp32-h2-devkitm-1
build_flags = '-DCONFIG_BT_NIMBLE_EXT_ADV=1'
EOF
cp ${{ matrix.example }}/* example/src/
platformio run -d example

build_arduino-esp32:
strategy:
fail-fast: false
Expand All @@ -101,6 +191,8 @@ jobs:
- esp32
- esp32c3
- esp32s3
- esp32c6
- esp32h2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -125,6 +217,8 @@ jobs:
variant:
- esp32c3
- esp32s3
- esp32c6
- esp32h2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -219,7 +313,7 @@ jobs:
mkdir example/src
cat > example/platformio.ini << EOF
[env]
platform = https://github.com/h2zero/platform-n-able.git#1.0.0
platform = https://github.com/h2zero/platform-n-able.git#1.1.1
framework = arduino

[env:generic_nrf51822_xxaa
Expand Down Expand Up @@ -262,7 +356,7 @@ jobs:
mkdir example/src
cat > example/platformio.ini << EOF
[env]
platform = https://github.com/h2zero/platform-n-able.git#1.0.0
platform = https://github.com/h2zero/platform-n-able.git#1.1.1
framework = arduino

[env:generic_nrf52840]
Expand Down
10 changes: 7 additions & 3 deletions src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,13 @@ bool NimBLEDevice::init(const std::string& deviceName) {

# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) | !defined(CONFIG_NIMBLE_CPP_IDF)
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
# if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
bt_cfg.bluetooth_mode = ESP_BT_MODE_BLE;
# else
# if defined(CONFIG_IDF_TARGET_ESP32)
bt_cfg.mode = ESP_BT_MODE_BLE;
bt_cfg.ble_max_conn = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
# elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
bt_cfg.ble_max_act = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
# else
bt_cfg.nimble_max_connections = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
# endif

# ifdef CONFIG_BTDM_BLE_SCAN_DUPL
Expand All @@ -889,11 +891,13 @@ bool NimBLEDevice::init(const std::string& deviceName) {
return false;
}

# if CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE
err = esp_nimble_hci_init();
if (err != ESP_OK) {
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_init() failed; err=%d", err);
return false;
}
# endif
# endif
# endif
nimble_port_init();
Expand Down
3 changes: 3 additions & 0 deletions src/nimble/esp_port/esp-hci/src/esp_nimble_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

#ifdef ESP_PLATFORM
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE

#include <assert.h>
#include "nimble/porting/nimble/include/sysinit/sysinit.h"
Expand Down Expand Up @@ -342,4 +344,5 @@ esp_err_t esp_nimble_hci_deinit(void)
return ESP_OK;
}

#endif
#endif //ESP_PLATFORM
94 changes: 94 additions & 0 deletions src/nimble/esp_port/esp-hci/src/na_hci_driver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifdef ESP_PLATFORM
#include "syscfg/syscfg.h"
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT

#include <string.h>
#include <stdio.h>
#include "esp_hci_internal.h"
#include "esp_hci_driver.h"

typedef struct {
hci_driver_forward_fn *forward_cb;
} hci_driver_vhci_env_t;

static hci_driver_vhci_env_t s_hci_driver_vhci_env;

static int
hci_driver_vhci_controller_tx(hci_driver_data_type_t data_type, uint8_t *data)
{
/* The length is contained in the data. */
return s_hci_driver_vhci_env.forward_cb(data_type, data, 0, HCI_DRIVER_DIR_C2H);
}

static int
hci_driver_vhci_host_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length)
{
return s_hci_driver_vhci_env.forward_cb(data_type, data, length, HCI_DRIVER_DIR_H2C);
}

static int
hci_driver_vhci_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length,
hci_driver_direction_t dir)
{
int rc;

if (dir == HCI_DRIVER_DIR_C2H) {
rc = hci_driver_vhci_controller_tx(data_type, data);
} else {
rc = hci_driver_vhci_host_tx(data_type, data, length);
}
return rc;
}

static int
hci_driver_vhci_init(hci_driver_forward_fn *cb)
{
s_hci_driver_vhci_env.forward_cb = cb;
return 0;
}

static void
hci_driver_vhci_deinit(void)
{
memset(&s_hci_driver_vhci_env, 0, sizeof(hci_driver_vhci_env_t));
}

hci_driver_ops_t na_hci_driver_vhci_ops = {
.hci_driver_tx = hci_driver_vhci_tx,
.hci_driver_init = hci_driver_vhci_init,
.hci_driver_deinit = hci_driver_vhci_deinit,
};

// Prevent linking errors when using arduino + bluedroid with esp32c2
#if defined (CONFIG_IDF_TARGET_ESP32C2)
void adv_stack_enableClearLegacyAdvVsCmd(bool en){}
void scan_stack_enableAdvFlowCtrlVsCmd(bool en){}
void advFilter_stack_enableDupExcListVsCmd(bool en){}
void arr_stack_enableMultiConnVsCmd(bool en){}
void pcl_stack_enableSetRssiThreshVsCmd(bool en){}
void chanSel_stack_enableSetCsaVsCmd(bool en){}
void log_stack_enableLogsRelatedVsCmd(bool en){}
void hci_stack_enableSetVsEvtMaskVsCmd(bool en){}
void winWiden_stack_enableSetConstPeerScaVsCmd(bool en){}
#if CONFIG_IDF_TARGET_ESP32C61_ECO3
void conn_stack_enableSetPrefTxRxCntVsCmd(bool en){}
#endif // CONFIG_IDF_TARGET_ESP32C61_ECO3

void adv_stack_enableScanReqRxdVsEvent(bool en){}
void conn_stack_enableChanMapUpdCompVsEvent(bool en){}
void sleep_stack_enableWakeupVsEvent(bool en){}

#ifdef SOC_ECC_SUPPORTED
void esp_crypto_ecc_lock_acquire(void) {}
void esp_crypto_ecc_lock_release(void) {}
#endif
#endif

#endif
#endif
Loading