Files
esphome/tests/dummy_main.cpp
J. Nick Koston f926978f61 [core] Make register_component protected, remove runtime checks
Instead of runtime null, duplicate, and capacity checks in
register_component_, make the method unreachable from outside
codegen by removing the public template wrapper and granting
friend access to the codegen-generated ::setup() function.

Since ESPHOME_COMPONENT_COUNT is set to exactly
len(CORE.component_ids) at codegen time, the StaticVector is
always correctly sized and the runtime capacity check cannot
trigger from codegen. External components that bypassed codegen
to call App.register_component() directly will now get a
compile error, forcing them to properly declare their components
in their config schema.

Co-Authored-By: J. Nick Koston <nick@koston.org>
2026-02-27 21:05:34 -10:00

35 lines
1.0 KiB
C++

// Dummy main.cpp file for the PlatformIO project in the git repository.
// Primarily used to get IDE integration working (so the contents here don't
// matter at all, as long as it compiles).
// Not used during runtime nor for CI.
#include <esphome/components/gpio/switch/gpio_switch.h>
#include <esphome/components/logger/logger.h>
#include <esphome/components/esphome/ota/ota_esphome.h>
#include <esphome/components/wifi/wifi_component.h>
#include <esphome/core/application.h>
using namespace esphome;
void setup() {
App.pre_setup("livingroom", "LivingRoom", false);
auto *log = new logger::Logger(115200); // NOLINT
log->pre_setup();
log->set_uart_selection(logger::UART_SELECTION_UART0);
App.register_component_(log);
auto *wifi = new wifi::WiFiComponent(); // NOLINT
App.register_component_(wifi);
wifi::WiFiAP ap;
ap.set_ssid("Test SSID");
ap.set_password("password1");
wifi->add_sta(ap);
auto *ota = new esphome::ESPHomeOTAComponent(); // NOLINT
ota->set_port(8266);
App.setup();
}
void loop() { App.loop(); }