SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp_app.cpp
Go to the documentation of this file.
1#include "sensesp_app.h"
2
5#include "sensesp/net/ota.h"
9
10namespace sensesp {
11
13 if (instance_ == nullptr) {
14 instance_ = new SensESPApp();
15 }
16 return (SensESPApp*)instance_;
17}
18
27 // call the parent setup()
29
30 // create the networking object
32 new Networking("/System/WiFi Settings", ssid_, wifi_password_,
34
35 if (ota_password_ != nullptr) {
36 // create the OTA object
37 ota_ = new OTA(ota_password_);
38 }
39
40 // create the HTTP server
41 this->http_server_ = new HTTPServer();
42
43 // create the SK delta object
45
46 // create the websocket client
47 this->ws_client_ = new WSClient("/System/Signal K Settings", sk_delta_queue_,
49
50 // connect the system status controller
53
54 // create the MDNS discovery object
56
57 // create the wifi disconnect watchdog
60 3 * 60 * 1000 // 180 s = 180000 ms = 3 minutes
61 ))
63 debugD("Got system status: %d", (int)input);
65 input == SystemStatus::kWifiNoAP) {
66 debugW("Unable to connect to wifi for too long; restarting.");
67 ReactESP::app->onDelay(1000, []() { ESP.restart(); });
68 }
69 }));
70
71 // create a system status led and connect it
72
73 if (system_status_led_ == NULL) {
75 }
78
79 // create the button handler
80 if (button_gpio_pin_ != -1) {
82 }
83}
84
88
90
91} // namespace sensesp
Default Button Handler for SensESPApp applications.
Definition button.h:23
Construct a new transform based on a single function.
Manages the ESP's connection to the Wifi network.
Definition networking.h:105
Signal K delta queue.
SensESPApp()
SensESPApp constructor.
Definition sensesp_app.h:69
static SensESPApp * get()
Get the singleton instance of the SensESPApp.
WSClient * ws_client_
SKDeltaQueue * sk_delta_queue_
void setup()
Perform initialization of SensESPApp once builder configuration is done.
HTTPServer * http_server_
const char * ota_password_
SystemStatusLed * system_status_led_
SystemStatusController system_status_controller_
ObservableValue< String > * get_hostname_observable()
ButtonHandler * button_handler_
const char * wifi_manager_password_
MDNSDiscovery * mdns_discovery_
friend class HTTPServer
Networking * networking_
ObservableValue< String > * hostname_
static SensESPBaseApp * instance_
static String get_hostname()
Get the current hostname.
virtual void setup()
Perform initialization of SensESPBaseApp once builder configuration is done.
Consumes the networking and websocket states and delta counts and updates the device LED accordingly....
void connect_to(ValueConsumer< T > *consumer, uint8_t input_channel=0)
The websocket connection to the Signal K server.
Definition ws_client.h:33
ValueProducer< int > & get_delta_count_producer()
Definition ws_client.h:53
static WiFiStateProducer * get_singleton()
Get the singleton instance of the WiFiStateProducer.
#define debugD(fmt,...)
Definition local_debug.h:47
#define debugW(fmt,...)
Definition local_debug.h:49
SensESPApp * sensesp_app
#define LED_PIN
Definition sensesp_app.h:8