Compare commits

...

7 Commits

Author SHA1 Message Date
J. Nick Koston
123d4c3e0d ble testing 2025-06-07 15:42:41 -05:00
Jonathan Swoboda
4f1953c581 Merge remote-tracking branch 'upstream/dev' into p4_remote_wifi 2025-06-04 07:41:52 -04:00
Jonathan Swoboda
5bdf5c1bf3 Make pins required and add esp_wifi_remote to idf_component.yml 2025-05-25 18:15:31 -04:00
Jonathan Swoboda
fa27c0b8f1 Add esp32_hosted tests 2025-05-23 17:55:39 -04:00
Jonathan Swoboda
69fec85cc1 Fix exec bit 2025-05-23 13:40:26 -04:00
Jonathan Swoboda
aa26e2bffd Add pin settings 2025-05-23 13:30:17 -04:00
Jonathan Swoboda
af1a4d8a0a Add initial support for remote wifi 2025-05-23 12:44:34 -04:00
9 changed files with 257 additions and 0 deletions

View File

@@ -146,6 +146,7 @@ esphome/components/esp32_ble_client/* @jesserockz
esphome/components/esp32_ble_server/* @Rapsssito @clydebarrow @jesserockz
esphome/components/esp32_camera_web_server/* @ayufan
esphome/components/esp32_can/* @Sympatron
esphome/components/esp32_hosted/* @swoboda1337
esphome/components/esp32_improv/* @jesserockz
esphome/components/esp32_rmt/* @jesserockz
esphome/components/esp32_rmt_led_strip/* @jesserockz

View File

@@ -0,0 +1,125 @@
import os
from esphome import pins
import esphome.codegen as cg
from esphome.components import esp32
import esphome.config_validation as cv
from esphome.const import (
CONF_CLK_PIN,
CONF_ID,
CONF_RESET_PIN,
CONF_VARIANT,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
)
from esphome.core import CORE
CODEOWNERS = ["@swoboda1337"]
AUTO_LOAD = ["esp32"]
esp32_hosted_ns = cg.esphome_ns.namespace("esp32_hosted")
ESP32Hosted = esp32_hosted_ns.class_("ESP32Hosted", cg.Component)
CONF_ACTIVE_HIGH = "active_high"
CONF_CMD_PIN = "cmd_pin"
CONF_D0_PIN = "d0_pin"
CONF_D1_PIN = "d1_pin"
CONF_D2_PIN = "d2_pin"
CONF_D3_PIN = "d3_pin"
CONF_SLOT = "slot"
VARIANTS_WITHOUT_WIFI = {
esp32.VARIANT_ESP32H2,
esp32.VARIANT_ESP32P4,
}
CONFIG_SCHEMA = cv.All(
cv.Schema(
{
cv.GenerateID(): cv.declare_id(ESP32Hosted),
cv.Required(CONF_VARIANT): cv.one_of(*esp32.VARIANTS, upper=True),
cv.Optional(CONF_ACTIVE_HIGH, default=True): cv.boolean,
cv.Required(CONF_CLK_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_CMD_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_D0_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_D1_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_D2_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_D3_PIN): pins.internal_gpio_output_pin_number,
cv.Required(CONF_RESET_PIN): pins.internal_gpio_output_pin_number,
cv.Optional(CONF_SLOT, default=1): cv.int_range(min=0, max=1),
}
),
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
if config[CONF_ACTIVE_HIGH]:
esp32.add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH", True)
else:
esp32.add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_SDIO_RESET_ACTIVE_LOW", True)
esp32.add_idf_sdkconfig_option(
f"CONFIG_SLAVE_IDF_TARGET_{config[CONF_VARIANT]}", # NOLINT
True,
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_SDIO_SLOT_{config[CONF_SLOT]}", True
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CLK_SLOT_{config[CONF_SLOT]}",
config[CONF_CLK_PIN],
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CMD_SLOT_{config[CONF_SLOT]}",
config[CONF_CMD_PIN],
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D0_SLOT_{config[CONF_SLOT]}",
config[CONF_D0_PIN],
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D1_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
config[CONF_D1_PIN],
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D2_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
config[CONF_D2_PIN],
)
esp32.add_idf_sdkconfig_option(
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D3_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
config[CONF_D3_PIN],
)
esp32.add_idf_sdkconfig_option(
"CONFIG_ESP_HOSTED_SDIO_GPIO_RESET_SLAVE", # NOLINT
config[CONF_RESET_PIN],
)
os.environ["ESP_IDF_VERSION"] = f"{framework_ver.major}.{framework_ver.minor}"
if config[CONF_VARIANT] not in VARIANTS_WITHOUT_WIFI:
esp32.add_idf_component(
name="esp_wifi_remote",
repo="https://github.com/espressif/esp-wifi-remote.git",
path="components/esp_wifi_remote",
ref="wifi_remote-v0.10.2",
)
esp32.add_extra_script(
"post",
"esp32_hosted.py",
os.path.join(os.path.dirname(__file__), "esp32_hosted.py.script"),
)

View File

@@ -0,0 +1,53 @@
#include "esp32_hosted.h"
#include "esphome/core/log.h"
#ifdef USE_ESP32
#ifdef USE_ESP32_BLE
#include <esp_bluedroid_hci.h>
#include <hosted_hci_bluedroid.h>
#endif
namespace esphome {
namespace esp32_hosted {
static const char *const TAG = "esp32_hosted";
void ESP32Hosted::setup() {
ESP_LOGCONFIG(TAG, "Setting up ESP32 Hosted...");
#ifdef USE_ESP32_BLE
// Initialize Bluetooth if esp32_ble component is enabled
this->init_bluetooth_();
#else
ESP_LOGD(TAG, "Bluetooth support disabled (esp32_ble not included)");
#endif
}
void ESP32Hosted::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 Hosted:"); }
#ifdef USE_ESP32_BLE
void ESP32Hosted::init_bluetooth_() {
ESP_LOGD(TAG, "Initializing Bluetooth...");
// Initialize TRANSPORT first
hosted_hci_bluedroid_open();
// Get HCI driver operations
esp_bluedroid_hci_driver_operations_t operations = {
.send = hosted_hci_bluedroid_send,
.check_send_available = hosted_hci_bluedroid_check_send_available,
.register_host_callback = hosted_hci_bluedroid_register_host_callback,
};
// Attach HCI driver
esp_bluedroid_attach_hci_driver(&operations);
ESP_LOGD(TAG, "Bluetooth initialized successfully");
}
#endif
} // namespace esp32_hosted
} // namespace esphome
#endif // USE_ESP32

View File

@@ -0,0 +1,26 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/helpers.h"
#ifdef USE_ESP32
namespace esphome {
namespace esp32_hosted {
class ESP32Hosted : public Component {
public:
void setup() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
protected:
#ifdef USE_ESP32_BLE
void init_bluetooth_();
#endif
};
} // namespace esp32_hosted
} // namespace esphome
#endif // USE_ESP32

View File

@@ -0,0 +1,12 @@
# pylint: disable=E0602
Import("env") # noqa
# Workaround whole archive issue
if "__LIB_DEPS" in env and "libespressif__esp_hosted.a" in env["__LIB_DEPS"]:
env.Append(
LINKFLAGS=[
"-Wl,--whole-archive",
env["BUILD_DIR"] + "/esp-idf/espressif__esp_hosted/libespressif__esp_hosted.a",
"-Wl,--no-whole-archive",
]
)

View File

@@ -11,3 +11,10 @@ dependencies:
path: components/mdns
rules:
- if: "idf_version >=5.0"
esp_wifi_remote:
git: https://github.com/espressif/esp-wifi-remote.git
version: wifi_remote-v0.10.2
path: components/esp_wifi_remote
rules:
- if: "idf_version >=5.0"
- if: "target in [esp32h2, esp32p4]"

View File

@@ -0,0 +1,15 @@
esp32_hosted:
variant: ESP32C6
slot: 1
active_high: true
reset_pin: GPIO15
cmd_pin: GPIO13
clk_pin: GPIO12
d0_pin: GPIO11
d1_pin: GPIO10
d2_pin: GPIO9
d3_pin: GPIO8
wifi:
ssid: MySSID
password: password1

View File

@@ -0,0 +1 @@
<<: !include common.yaml

View File

@@ -0,0 +1,17 @@
esphome:
name: componenttestesp32p4idf
friendly_name: $component_name
esp32:
board: esp32-p4-evboard
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_test_file: $component_test_file