1#ifndef SENSESP_BASE_APP_H_
2#define SENSESP_BASE_APP_H_
7#define BUTTON_BUILTIN 0
22inline void SetupLogging(esp_log_level_t default_level = ESP_LOG_DEBUG) {
23 esp_log_level_set(
"*", default_level);
22inline void SetupLogging(esp_log_level_t default_level = ESP_LOG_DEBUG) {
…}
29 if (baudrate != 115200) {
30 ESP_LOGW(__FILENAME__,
"SetupSerialDebug baudrate parameter is ignored.");
51 static const std::shared_ptr<SensESPBaseApp>&
get() {
return instance_; }
57 bool outside_users =
instance_.use_count() > 1;
60 ESP_LOGW(__FILENAME__,
61 "SensESPBaseApp instance has active references and won't be "
62 "properly destroyed.");
65 return !outside_users;
73 ESP_LOGW(__FILENAME__,
"start() call is deprecated and can be removed.");
81 ESP_LOGW(__FILENAME__,
82 "Resetting the device configuration to system defaults.");
85 this->event_loop_->onDelay(1000, []() {
97 return std::static_pointer_cast<ObservableValue<String>>(
hostname_);
128 event_loop_{std::make_shared<reactesp::EventLoop>()} {
135 hostname_ = std::make_shared<PersistingObservableValue<String>>(
159 std::shared_ptr<PersistingObservableValue<String>>
hostname_;
The base class for SensESP applications.
static String get_hostname()
Get the current hostname.
static std::shared_ptr< reactesp::EventLoop > get_event_loop()
Get the event loop object from the singleton SensESPBaseApp instance.
static std::shared_ptr< SensESPBaseApp > instance_
std::shared_ptr< reactesp::EventLoop > event_loop_
void set_instance(const std::shared_ptr< SensESPBaseApp > &instance)
const SensESPBaseApp * set_hostname(String hostname)
std::shared_ptr< PersistingObservableValue< String > > hostname_
virtual void start()
Start the app (activate all the subcomponents)
std::shared_ptr< ObservableValue< String > > get_hostname_observable()
Get the hostname observable object.
virtual void setup()
Perform initialization of SensESPBaseApp once builder configuration is done.
SensESPBaseApp()
Construct a new SensESP Base App object.
virtual void reset()
Reset the device to factory defaults.
virtual bool destroy()
Destroy the SensESPBaseApp instance.
std::shared_ptr< Filesystem > filesystem_
static const std::shared_ptr< SensESPBaseApp > & get()
Get the singleton instance of the SensESPBaseApp.
constexpr auto kDefaultHostname
void SetupSerialDebug(uint32_t baudrate)
std::shared_ptr< ConfigItemT< T > > ConfigItem(std::shared_ptr< T >)
Register a ConfigItemT with the ConfigItemBase.
void SetupLogging(esp_log_level_t default_level=ESP_LOG_DEBUG)