SensESP 3.0.0-beta.3
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::SKWSClient Class Reference

The websocket connection to the Signal K server. More...

#include <sensesp/signalk/signalk_ws_client.h>

Inheritance diagram for sensesp::SKWSClient:
[legend]

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 ()
 
Configurableset_description (String description)
 Set the description of the Configurable.
 
int get_sort_order ()
 
Configurableset_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 SKWSConnectionStateget () 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 Configurableget_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_
 

Detailed Description

The websocket connection to the Signal K server.

See also
SensESPApp

Definition at line 34 of file signalk_ws_client.h.

Constructor & Destructor Documentation

◆ SKWSClient()

sensesp::SKWSClient::SKWSClient ( const String & config_path,
SKDeltaQueue * sk_delta_queue,
const String & server_address,
uint16_t server_port,
bool use_mdns = true )

Definition at line 77 of file signalk_ws_client.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ connect()

void sensesp::SKWSClient::connect ( )

Definition at line 393 of file signalk_ws_client.cpp.

Here is the caller graph for this function:

◆ get_configuration()

void sensesp::SKWSClient::get_configuration ( JsonObject & configObject)
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.

◆ get_connection_status()

String sensesp::SKWSClient::get_connection_status ( )

Get a String representation of the current connection state.

Returns
String

Definition at line 726 of file signalk_ws_client.cpp.

◆ get_delta_rx_count_producer()

ValueProducer< int > & sensesp::SKWSClient::get_delta_rx_count_producer ( )
inline

Get the delta rx count producer object.

Returns
ValueProducer<int>&

Definition at line 63 of file signalk_ws_client.h.

◆ get_delta_tx_count_producer()

ValueProducer< int > & sensesp::SKWSClient::get_delta_tx_count_producer ( )
inline

Return a delta update ValueProducer that produces the number of sent deltas.

Definition at line 54 of file signalk_ws_client.h.

Here is the caller graph for this function:

◆ get_server_address()

const String sensesp::SKWSClient::get_server_address ( ) const
inline

Definition at line 44 of file signalk_ws_client.h.

◆ get_server_port()

uint16_t sensesp::SKWSClient::get_server_port ( ) const
inline

Definition at line 45 of file signalk_ws_client.h.

◆ is_connected()

bool sensesp::SKWSClient::is_connected ( )

Definition at line 664 of file signalk_ws_client.cpp.

◆ loop()

void sensesp::SKWSClient::loop ( )

◆ on_connected()

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.

Here is the call graph for this function:

◆ on_disconnected()

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.

Here is the call graph for this function:

◆ on_error()

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.

◆ on_receive_delta()

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.

Parameters
payload

Definition at line 212 of file signalk_ws_client.cpp.

Here is the call graph for this function:

◆ on_receive_put()

void sensesp::SKWSClient::on_receive_put ( JsonDocument & message)

Called when a PUT event is received.

Called in the websocket task context.

Parameters
message

Definition at line 322 of file signalk_ws_client.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_receive_updates()

void sensesp::SKWSClient::on_receive_updates ( JsonDocument & message)

Called when a delta update is received.

Called in the websocket task context.

Parameters
message

Definition at line 251 of file signalk_ws_client.cpp.

Here is the caller graph for this function:

◆ restart()

void sensesp::SKWSClient::restart ( )

Definition at line 668 of file signalk_ws_client.cpp.

◆ send_delta()

void sensesp::SKWSClient::send_delta ( )

Definition at line 675 of file signalk_ws_client.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendTXT()

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.

Parameters
payload

Definition at line 371 of file signalk_ws_client.cpp.

Here is the caller graph for this function:

◆ set_configuration()

bool sensesp::SKWSClient::set_configuration ( const JsonObject & config)
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.


The documentation for this class was generated from the following files: