58 static std::shared_ptr<SensESPApp>
get() {
62 return std::static_pointer_cast<SensESPApp>(
instance_);
139 std::function<std::shared_ptr<NetworkProvisioner>()> factory) {
168 const std::vector<ClientSSIDConfig>& wifi_client_configs) {
189 std::shared_ptr<SystemStatusLed>& system_status_led) {
235 ->set_title(
"WiFi Watchdog")
237 "Restart the device if the network stays down longer than the "
238 "timeout. Armed after the first successful connection.")
239 ->set_sort_order(1500);
252 "provisioner_factory_ returned nullptr; falling back to "
253 "WiFiProvisioner so the rest of setup() has a valid object.");
257 std::shared_ptr<WiFiProvisioner> wifi;
260 wifi = std::make_shared<WiFiProvisioner>(
"/System/WiFi Settings",
265 wifi = std::make_shared<WiFiProvisioner>(
"/System/WiFi Settings",
ssid_,
288 nsp->attach([nsp, wp]() { wp->emit(nsp->get()); });
297 bool captive_portal_enabled =
false;
298 IPAddress captive_portal_ap_ip;
306 this->
http_server_->set_captive_portal(captive_portal_enabled,
307 captive_portal_ap_ip);
335 this->
ws_client_ = std::make_shared<SKWSClient>(
359#elif defined(LED_BUILTIN)
366 this->
ws_client_->get_delta_tx_count_producer().connect_to(
411 int event_loop_queue_size =
event_loop_->getEventQueueSize();
412 int event_loop_timed_queue_size =
event_loop_->getTimedEventQueueSize();
413 int event_loop_untimed_queue_size =
417 uint64_t current_tick_count =
event_loop_->getTickCount();
421 uint64_t current_event_count =
event_loop_->getEventCount();
422 uint64_t current_timed_event_count =
event_loop_->getTimedEventCount();
423 uint64_t current_untimed_event_count =
430 static uint64_t last_tick_count = 0;
431 static uint64_t last_event_count = 0;
432 static uint64_t last_timed_event_count = 0;
433 static uint64_t last_untimed_event_count = 0;
434 static uint64_t last_millis = 0;
435 uint64_t current_millis = millis();
436 float interval_seconds = (current_millis - last_millis) / 1000.0;
438 uint64_t ticks_diff = current_tick_count - last_tick_count;
439 uint64_t events_diff = current_event_count - last_event_count;
440 uint64_t timed_events_diff =
441 current_timed_event_count - last_timed_event_count;
442 uint64_t untimed_events_diff =
443 current_untimed_event_count - last_untimed_event_count;
455 int(timed_events_diff / interval_seconds));
457 int(untimed_events_diff / interval_seconds));
460 last_tick_count = current_tick_count;
461 last_event_count = current_event_count;
462 last_timed_event_count = current_timed_event_count;
463 last_untimed_event_count = current_untimed_event_count;
464 last_millis = current_millis;
470 ws_client_->get_delta_tx_count_producer().connect_to(
472 ws_client_->get_delta_rx_count_producer().connect_to(
497 std::make_shared<SystemStatusController>();
519 "Min free memory before last reset (bytes)", 0,
"System", 1020};
532 "",
"Signal K", 1600};
536 "",
"Signal K", 1800};
543 "Event Loop queue size", 0,
"Event Loop Queues", 2100};
545 "Event Loop timed queue size", 0,
"Event Loop Queues", 2200};
547 "Event Loop untimed queue size", 0,
"Event Loop Queues", 2300};
549 "Event Loop interrupt queue size", 0,
"Event Loop Queues", 2400};
552 "Total ticks processed", 0,
"Event Loop Lifetime", 2500};
554 "Event Loop Lifetime", 2600};
556 "Timed events processed", 0,
"Event Loop Lifetime", 2700};
558 "Untimed events processed", 0,
"Event Loop Lifetime", 2800};
560 "Ticks per second", 0,
"Event Loop Performance", 2900};
562 "Events per second", 0,
"Event Loop Performance", 3000};
564 "Timed events per second", 0,
"Event Loop Performance", 3100};
566 "Untimed events per second", 0,
"Event Loop Performance", 3200};
571 "Build date", __DATE__
" " __TIME__,
"Software", 3400};
Captures ESP_LOGx output into a bounded RAM buffer for the web UI.
void install()
Install the chained vprintf hook. Call once, early in startup.
void set(const T &value) override
A class for quickly configuring a SensESP application object before wiring up your sensors.
StatusPageItem< int > event_loop_interrupt_queue_ui_output_
const SensESPApp * set_sk_server_port(uint16_t sk_server_port)
StatusPageItem< String > sensesp_version_ui_output_
static std::shared_ptr< SensESPApp > get()
Get the singleton instance of the SensESPApp.
SensESPApp()
SensESPApp constructor.
void connect_status_page_items()
void operator=(const SensESPApp &)=delete
String pending_admin_user_
std::shared_ptr< SKDeltaQueue > sk_delta_queue_
const SensESPApp * set_hostname(String hostname)
StatusPageItem< uint64_t > timed_event_count_ui_output_
std::shared_ptr< HTTPServer > http_server_
std::shared_ptr< NetworkProvisioner > & get_network_provisioner()
Active network provisioner (transport-agnostic).
StatusPageItem< String > wifi_ssid_ui_output_
std::shared_ptr< NetworkStateProducer > network_state_producer_
const SensESPApp * set_sk_server_address(String sk_server_address)
StatusPageItem< float > ticks_per_second_ui_output_
StatusPageItem< int8_t > wifi_rssi_ui_output_
std::shared_ptr< NetworkProvisioner > network_provisioner_
virtual bool destroy() override
Destroy the SensESPBaseApp instance.
std::shared_ptr< WiFiProvisioner > wifi_provisioner_
void setup()
Perform initialization of SensESPApp once builder configuration is done.
const SensESPApp * set_wifi_clients(const std::vector< ClientSSIDConfig > &wifi_client_configs)
std::shared_ptr< ValueProducer< String > > ip_address_sensor_
StatusPageItem< int > min_free_before_reset_ui_output_
String sk_server_address_
StatusPageItem< uint64_t > untimed_event_count_ui_output_
std::shared_ptr< ValueProducer< float > > uptime_sensor_
StatusPageItem< int > min_free_memory_ui_output_
StatusPageItem< String > hostname_ui_output_
const SensESPApp * set_wifi_password(String wifi_password)
int wifi_watchdog_timeout_s_
StatusPageItem< uint16_t > sk_server_port_ui_output_
StatusPageItem< String > sk_server_address_ui_output_
StatusPageItem< int > event_loop_timed_queue_ui_output_
std::shared_ptr< ValueProducer< uint32_t > > free_mem_sensor_
StatusPageItem< String > mac_address_ui_output_
std::shared_ptr< SKWSClient > get_ws_client()
const char * ota_password_
String wifi_client_password_
StatusPageItem< uint64_t > total_tick_count_ui_output_
std::shared_ptr< BaseSystemStatusLed > system_status_led_
std::shared_ptr< WiFiProvisioner > & get_wifi_provisioner()
Active WiFi provisioner, or nullptr if a non-WiFi transport is in use.
StatusPageItem< int > uptime_ui_output_
std::shared_ptr< ValueProducer< int > > wifi_signal_sensor_
std::function< std::shared_ptr< NetworkProvisioner >()> provisioner_factory_
StatusPageItem< int > delta_rx_count_ui_output_
StatusPageItem< int > event_loop_untimed_queue_ui_output_
StatusPageItem< int > free_memory_ui_output_
String pending_admin_pass_
StatusPageItem< float > timed_events_per_second_ui_output_
void set_network_provisioner_factory(std::function< std::shared_ptr< NetworkProvisioner >()> factory)
Install a custom factory that setup() will use to construct the NetworkProvisioner instead of the def...
StatusPageItem< int > event_loop_queue_size_ui_output_
std::shared_ptr< WiFiProvisioner > & get_networking()
const SensESPApp * enable_ota(const char *password)
const SensESPApp * set_ap_password(const String &password)
const SensESPApp * set_admin_user(const char *username, const char *password)
StatusPageItem< uint64_t > event_count_ui_output_
std::shared_ptr< WiFiWatchdog > wifi_watchdog_
std::shared_ptr< SystemStatusController > get_system_status_controller()
std::shared_ptr< NetworkStateProducer > get_network_state_producer()
Unified producer that emits NetworkState transitions for any active interface (WiFi STA,...
std::shared_ptr< SKWSClient > ws_client_
StatusPageItem< String > build_info_ui_output_
StatusPageItem< float > untimed_events_per_second_ui_output_
const SensESPApp * set_system_status_led(std::shared_ptr< SystemStatusLed > &system_status_led)
StatusPageItem< String > sk_server_connection_ui_output_
StatusPageItem< String > reset_reason_ui_output_
std::shared_ptr< SystemStatusController > system_status_controller_
std::vector< ClientSSIDConfig > wifi_client_configs_
std::shared_ptr< ButtonHandler > button_handler_
std::shared_ptr< MDNSDiscovery > mdns_discovery_
const SensESPApp * set_ap_ssid(const String &ssid)
const SensESPApp * set_ssid(String ssid)
StatusPageItem< float > events_per_second_ui_output_
std::shared_ptr< OTA > ota_
SensESPApp(SensESPApp &other)=delete
std::shared_ptr< SKDeltaQueue > get_sk_delta()
StatusPageItem< int > delta_tx_count_ui_output_
std::shared_ptr< ValueProducer< float > > system_hz_sensor_
const SensESPApp * set_button_pin(int pin)
The base class for SensESP applications.
static String get_hostname()
Get the current hostname.
static std::shared_ptr< SensESPBaseApp > instance_
std::shared_ptr< reactesp::EventLoop > event_loop_
const SensESPBaseApp * set_hostname(String hostname)
std::shared_ptr< PersistingObservableValue< String > > hostname_
virtual void setup()
Perform initialization of SensESPBaseApp once builder configuration is done.
virtual bool destroy()
Destroy the SensESPBaseApp instance.
Item that renders its own value on the web UI status page.
void add_static_file_handlers(std::shared_ptr< HTTPServer > server)
Provide handlers for static web content.
void add_config_handlers(std::shared_ptr< HTTPServer > &server)
Handle HTTP requests to /config.
void add_button_handlers(std::shared_ptr< HTTPServer > &server)
Handle HTTP requests to /api/buttons.
const char *const kSensESPVersion
void begin_reset_info()
Reset-cause and pre-reset heap diagnostics for the status page.
const char * reset_reason_str()
std::shared_ptr< SensESPApp > sensesp_app
void add_tofu_reset_handler(std::shared_ptr< HTTPServer > &server)
void add_app_http_command_handlers(std::shared_ptr< HTTPServer > &server, std::shared_ptr< WiFiProvisioner > wifi_provisioner)
void add_base_app_http_command_handlers(std::shared_ptr< HTTPServer > &server)
uint32_t min_free_heap_before_reset()
std::shared_ptr< ConfigItemT< T > > ConfigItem(std::shared_ptr< T >)
Register a ConfigItemT with the ConfigItemBase.
void update_min_free_heap_watermark()