SensESP 3.0.0-beta.3
Universal Signal K sensor toolkit ESP32
|
The websocket connection to the Signal K server. More...
#include <sensesp/signalk/signalk_ws_client.h>
Public Member Functions | |
SKWSClient (const String &config_path, SKDeltaQueue *sk_delta_queue, const String &server_address, uint16_t server_port, bool use_mdns=true) | |
const String | get_server_address () const |
uint16_t | get_server_port () const |
virtual void | get_configuration (JsonObject &root) override final |
virtual bool | set_configuration (const JsonObject &config) override final |
ValueProducer< int > & | get_delta_tx_count_producer () |
ValueProducer< int > & | get_delta_rx_count_producer () |
Get the delta rx count producer object. | |
String | get_connection_status () |
Get a String representation of the current connection state. | |
void | on_disconnected () |
Called when the websocket connection is disconnected. | |
void | on_error () |
Called when the websocket connection encounters an error. | |
void | on_connected () |
Called when the websocket connection is established. | |
void | on_receive_delta (uint8_t *payload, size_t length) |
Called when the websocket receives a delta. | |
void | on_receive_updates (JsonDocument &message) |
Called when a delta update is received. | |
void | on_receive_put (JsonDocument &message) |
Called when a PUT event is received. | |
void | connect () |
void | loop () |
bool | is_connected () |
void | restart () |
void | send_delta () |
void | sendTXT (String &payload) |
Send some processed data to the websocket. | |
Public Member Functions inherited from sensesp::Configurable | |
Configurable (String config_path="", String description="", int sort_order=1000) | |
virtual bool | is_async () |
Return true if the Configurable is asynchronous. | |
bool | requires_restart () |
Return true if the Configurable requires restart after saving. | |
void | set_requires_restart (bool requires_restart) |
Set the requires_restart flag. | |
virtual ConfigurableResult | async_get_configuration () |
Initiate an asynchronous request to get the current configuration. | |
virtual ConfigurableResult | poll_get_result (JsonObject &config) |
Return the current status of the last async_get_configuration() call. | |
virtual ConfigurableResult | async_set_configuration (const JsonObject &config) |
Initiate an asynchronous request to set the configuration. | |
virtual ConfigurableResult | poll_set_result () |
Return the current status of the last async set_configuration call. | |
virtual String | get_config_schema () |
String | get_description () |
Configurable * | set_description (String description) |
Set the description of the Configurable. | |
int | get_sort_order () |
Configurable * | set_sort_order (int sort_order) |
virtual void | save_configuration () |
virtual void | clear_configuration () |
Clear existing configuration data. | |
Public Member Functions inherited from sensesp::ValueProducer< SKWSConnectionState > | |
ValueProducer () | |
ValueProducer (const SKWSConnectionState &initial_value) | |
virtual const SKWSConnectionState & | get () const |
void | connect_to (ValueConsumer< SKWSConnectionState > *consumer) |
void | connect_to (ValueConsumer< SKWSConnectionState > &consumer) |
void | connect_to (ValueConsumer< CT > *consumer) |
Connect a producer to a consumer of a different type. | |
void | connect_to (ValueConsumer< CT > &consumer) |
Transform< SKWSConnectionState, T2 > * | connect_to (Transform< SKWSConnectionState, T2 > *consumer_producer) |
Transform< SKWSConnectionState, T2 > * | connect_to (Transform< SKWSConnectionState, T2 > &consumer_producer) |
Transform< TT, T2 > * | connect_to (Transform< TT, T2 > *consumer_producer) |
Connect a producer to a transform with a different input type. | |
Transform< TT, T2 > * | connect_to (Transform< TT, T2 > &consumer_producer) |
void | emit (const SKWSConnectionState &new_value) |
Public Member Functions inherited from sensesp::Observable | |
Observable () | |
Observable (Observable &&other) | |
Move constructor. | |
void | notify () |
void | attach (std::function< void()> observer) |
Additional Inherited Members | |
Static Public Member Functions inherited from sensesp::Configurable | |
static std::vector< Configurable * > | get_configurables () |
Get configurables. | |
static Configurable * | get_configurable (String key) |
Get a single Configurable by key. | |
Public Attributes inherited from sensesp::Configurable | |
const String | config_path_ {} |
Protected Member Functions inherited from sensesp::Configurable | |
virtual void | load_configuration () |
Protected Attributes inherited from sensesp::Configurable | |
String | description_ = "" |
int | sort_order_ = 1000 |
bool | requires_restart_ = false |
Flag to indicate if the Configurable requires a restart after saving the configuration. | |
Protected Attributes inherited from sensesp::ValueProducer< SKWSConnectionState > | |
SKWSConnectionState | output |
Static Protected Attributes inherited from sensesp::Configurable | |
static std::map< String, Configurable * > | configurables_ |
The websocket connection to the Signal K server.
Definition at line 34 of file signalk_ws_client.h.
sensesp::SKWSClient::SKWSClient | ( | const String & | config_path, |
SKDeltaQueue * | sk_delta_queue, | ||
const String & | server_address, | ||
uint16_t | server_port, | ||
bool | use_mdns = true ) |
void sensesp::SKWSClient::connect | ( | ) |
|
finaloverridevirtual |
Returns the current configuration data as a JsonObject. In general, the current state of local member variables are saved to a new object created with JsonDocument::as<JsonObject>() and returned.
Reimplemented from sensesp::Configurable.
Definition at line 688 of file signalk_ws_client.cpp.
String sensesp::SKWSClient::get_connection_status | ( | ) |
Get a String representation of the current connection state.
Definition at line 726 of file signalk_ws_client.cpp.
|
inline |
Get the delta rx count producer object.
Definition at line 63 of file signalk_ws_client.h.
|
inline |
Return a delta update ValueProducer that produces the number of sent deltas.
Definition at line 54 of file signalk_ws_client.h.
|
inline |
Definition at line 44 of file signalk_ws_client.h.
|
inline |
Definition at line 45 of file signalk_ws_client.h.
bool sensesp::SKWSClient::is_connected | ( | ) |
Definition at line 664 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::loop | ( | ) |
void sensesp::SKWSClient::on_connected | ( | ) |
Called when the websocket connection is established.
Called in the websocket task context.
Definition at line 154 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::on_disconnected | ( | ) |
Called when the websocket connection is disconnected.
This method is called in the websocket task context.
Definition at line 124 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::on_error | ( | ) |
Called when the websocket connection encounters an error.
Called in the websocket task context.
Definition at line 144 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::on_receive_delta | ( | uint8_t * | payload, |
size_t | length ) |
Called when the websocket receives a delta.
Called in the websocket task context.
payload |
Definition at line 212 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::on_receive_put | ( | JsonDocument & | message | ) |
Called when a PUT event is received.
Called in the websocket task context.
message |
Definition at line 322 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::on_receive_updates | ( | JsonDocument & | message | ) |
Called when a delta update is received.
Called in the websocket task context.
message |
Definition at line 251 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::restart | ( | ) |
Definition at line 668 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::send_delta | ( | ) |
Definition at line 675 of file signalk_ws_client.cpp.
void sensesp::SKWSClient::sendTXT | ( | String & | payload | ) |
Send some processed data to the websocket.
Sends the specified payload to the server over the websocket this client is connected to. If no connection currently exist, the call is safely ignored.
Called in the websocket task context.
payload |
Definition at line 371 of file signalk_ws_client.cpp.
|
finaloverridevirtual |
Sets the current state of local member variables using the data stored in config.
Reimplemented from sensesp::Configurable.
Definition at line 698 of file signalk_ws_client.cpp.