1#ifndef SENSESP_APP_BUILDER_H
2#define SENSESP_APP_BUILDER_H
24 String hostname_ =
"SensESP";
26 String password_ =
"";
27 String sk_server_address_ =
"";
28 uint16_t sk_server_port_ = 0;
31 std::shared_ptr<SensESPApp>
app_;
56 app_->set_wifi_password(password);
60 [[deprecated(
"Use set_wifi_client instead")]]
83 const std::vector<ClientSSIDConfig>& wifi_client_configs) {
98 const String& password) {
99 app_->set_ap_ssid(ssid);
100 app_->set_ap_password(password);
118 app_->set_wifi_password(
"");
119 app_->set_ap_ssid(
"");
120 app_->set_ap_password(
"");
150 template <
typename ProvisionerConfigT>
153 app_->set_network_provisioner_factory(
154 [config]() -> std::shared_ptr<NetworkProvisioner> {
155 return std::make_shared<typename ProvisionerConfigT::ProvisionerType>(
171 app_->set_sk_server_address(address);
172 app_->set_sk_server_port(port);
192 const char* password) {
206 std::shared_ptr<SystemStatusLed> system_status_led) {
221 auto sensor = std::make_shared<SystemHz>();
222 auto vproducer = std::static_pointer_cast<ValueProducer<float>>(sensor);
225 app_->system_hz_sensor_ = vproducer;
237 auto sensor = std::make_shared<FreeMem>();
238 auto vproducer = std::static_pointer_cast<ValueProducer<uint32_t>>(sensor);
241 app_->free_mem_sensor_ = vproducer;
253 auto sensor = std::make_shared<Uptime>();
254 auto vproducer = std::static_pointer_cast<ValueProducer<float>>(sensor);
257 app_->uptime_sensor_ = vproducer;
269 auto sensor = std::make_shared<IPAddrDev>();
270 auto vproducer = std::static_pointer_cast<ValueProducer<String>>(sensor);
273 app_->ip_address_sensor_ = vproducer;
285 auto sensor = std::make_shared<WiFiSignal>();
286 auto vproducer = std::static_pointer_cast<ValueProducer<int>>(sensor);
289 app_->wifi_signal_sensor_ = vproducer;
341 [[deprecated(
"Use set_wifi_access_point instead")]]
343 app_->set_ap_password(password);
366 ESP_LOGE(__FILENAME__,
367 "WiFi watchdog timeout %d s is out of range [1, %d]; watchdog "
372 if (
app_->network_state_producer_) {
373 ESP_LOGE(__FILENAME__,
374 "enable_wifi_watchdog() must be called before get_app(); "
375 "watchdog not enabled.");
378 app_->wifi_watchdog_timeout_s_ = timeout_s;
A class for quickly configuring a SensESP application object before wiring up your sensors.
SensESPAppBuilder * set_wifi_clients(const std::vector< ClientSSIDConfig > &wifi_client_configs)
Set multiple Wi-Fi client (STA) networks for failover.
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 * enable_wifi_watchdog(int timeout_s=180)
Restart the device after a prolonged network outage.
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.
static constexpr int kMaxTimeoutS
static bool is_valid_timeout_s(int timeout_s)
constexpr const char * kDefaultSystemInfoSensorPrefix
void connect_system_info_sensor(std::shared_ptr< ValueProducer< T > > &sensor, const String &prefix, const String &name)
Connect a system information sensor to SKOutput.