1#ifndef SENSESP_APP_BUILDER_H
2#define SENSESP_APP_BUILDER_H
23 String hostname_ =
"SensESP";
25 String password_ =
"";
26 String sk_server_address_ =
"";
27 uint16_t sk_server_port_ = 0;
30 std::shared_ptr<SensESPApp>
app_;
55 app_->set_wifi_password(password);
59 [[deprecated(
"Use set_wifi_client instead")]]
74 const String& password) {
75 app_->set_ap_ssid(ssid);
76 app_->set_ap_password(password);
94 app_->set_wifi_password(
"");
95 app_->set_ap_ssid(
"");
96 app_->set_ap_password(
"");
126 template <
typename ProvisionerConfigT>
129 app_->set_network_provisioner_factory(
130 [config]() -> std::shared_ptr<NetworkProvisioner> {
131 return std::make_shared<typename ProvisionerConfigT::ProvisionerType>(
147 app_->set_sk_server_address(address);
148 app_->set_sk_server_port(port);
160 app_->set_hostname(hostname);
168 const char* password) {
169 app_->set_admin_user(username, password);
182 std::shared_ptr<SystemStatusLed> system_status_led) {
183 app_->set_system_status_led(system_status_led);
197 auto sensor = std::make_shared<SystemHz>();
198 auto vproducer = std::static_pointer_cast<ValueProducer<float>>(sensor);
201 app_->system_hz_sensor_ = vproducer;
213 auto sensor = std::make_shared<FreeMem>();
214 auto vproducer = std::static_pointer_cast<ValueProducer<uint32_t>>(sensor);
217 app_->free_mem_sensor_ = vproducer;
229 auto sensor = std::make_shared<Uptime>();
230 auto vproducer = std::static_pointer_cast<ValueProducer<float>>(sensor);
233 app_->uptime_sensor_ = vproducer;
245 auto sensor = std::make_shared<IPAddrDev>();
246 auto vproducer = std::static_pointer_cast<ValueProducer<String>>(sensor);
249 app_->ip_address_sensor_ = vproducer;
261 auto sensor = std::make_shared<WiFiSignal>();
262 auto vproducer = std::static_pointer_cast<ValueProducer<int>>(sensor);
265 app_->wifi_signal_sensor_ = vproducer;
276 app_->set_button_pin(pin);
303 app_->enable_ota(password);
317 [[deprecated(
"Use set_wifi_access_point instead")]]
319 app_->set_ap_password(password);
325 app_->system_status_controller_
330 ESP_LOGD(__FILENAME__,
"Got system status: %d", (
int)input);
333 ESP_LOGW(__FILENAME__,
334 "Unable to connect to wifi for too long; restarting.");
335 event_loop()->onDelay(1000, []() { ESP.restart(); });
Implements debounce code for a button or switch.
Provides an easy way of calling a function based on the output of any ValueProducer.
const SensESPAppBuilder * enable_wifi_watchdog()
SensESPAppBuilder()
Construct a new SensESPApp Builder object.
SensESPAppBuilder * set_admin_user(const char *username, const char *password)
Set admin username and password for the web interface.
SensESPAppBuilder * set_hostname(String hostname) override final
Set the device hostname.
SensESPAppBuilder * disable_wifi()
Clear the default WiFi STA/AP settings.
SensESPAppBuilder * set_ethernet(ProvisionerConfigT config)
Configure the app to use a non-WiFi NetworkProvisioner.
SensESPAppBuilder * set_system_status_led(std::shared_ptr< SystemStatusLed > system_status_led)
Set the system status led object.
SensESPAppBuilder * set_sk_server(String address, uint16_t port)
Set the Signal K server address and port.
SensESPAppBuilder * set_wifi(String ssid, String password)
std::shared_ptr< SensESPApp > app_
SensESPAppBuilder * set_wifi_client(String ssid, String password)
Set the Wi-Fi network SSID and password.
SensESPAppBuilder * set_wifi_manager_password(const char *password)
Set the wifi manager password.
SensESPAppBuilder * enable_ip_address_sensor(String prefix=kDefaultSystemInfoSensorPrefix)
Report the IP address of the device.
SensESPAppBuilder * enable_free_mem_sensor(String prefix=kDefaultSystemInfoSensorPrefix)
Enable the free memory sensor.
SensESPAppBuilder * set_wifi_access_point(const String &ssid, const String &password)
Set the wifi access point object SSID and password.
SensESPAppBuilder * set_button_pin(int pin)
Set the button GPIO pin.
std::shared_ptr< SensESPApp > get_app()
Get the SensESPApp object.
SensESPAppBuilder * enable_system_hz_sensor(String prefix=kDefaultSystemInfoSensorPrefix)
Enable the System Hz sensor.
SensESPAppBuilder * enable_system_info_sensors(String prefix=kDefaultSystemInfoSensorPrefix)
Enable all built-in system info sensors.
SensESPAppBuilder * enable_uptime_sensor(String prefix=kDefaultSystemInfoSensorPrefix)
Report the system uptime in seconds since the last reboot.
SensESPAppBuilder * enable_wifi_signal_sensor(String prefix=kDefaultSystemInfoSensorPrefix)
Report the Wi-Fi signal strength.
SensESPAppBuilder * enable_ota(const char *password)
Enable over-the-air updates for the device.
static std::shared_ptr< SensESPApp > get()
Get the singleton instance of the SensESPApp.
Abstract base class for other SensESP*AppBuilder classes.
std::shared_ptr< reactesp::EventLoop > event_loop()
void connect_system_info_sensor(std::shared_ptr< ValueProducer< T > > &sensor, const String &prefix, const String &name)
Connect a system information sensor to SKOutput.
constexpr const char * kDefaultSystemInfoSensorPrefix