SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::WSClient Class Reference

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

#include <sensesp/net/ws_client.h>

Inheritance diagram for sensesp::WSClient:
[legend]

Public Member Functions

 WSClient (String config_path, SKDeltaQueue *sk_delta_queue, String server_address, uint16_t server_port)
 
virtual void start () override
 
const String get_server_address () const
 
const uint16_t get_server_port () const
 
virtual void get_configuration (JsonObject &doc) override final
 
virtual bool set_configuration (const JsonObject &config) override final
 
virtual String get_config_schema () override
 
ValueProducer< int > & get_delta_count_producer ()
 
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 (uint8_t *payload)
 Called when the websocket connection is established.
 
void on_receive_delta (uint8_t *payload)
 Called when the websocket receives a delta.
 
void on_receive_updates (DynamicJsonDocument &message)
 Called when a delta update is received.
 
void on_receive_put (DynamicJsonDocument &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)
 
String get_description ()
 
void set_description (String description)
 Set the description of the Configurable.
 
int get_sort_order ()
 
void set_sort_order (int sort_order)
 
virtual void save_configuration ()
 
- Public Member Functions inherited from sensesp::Startable
 Startable (int priority=0)
 
const int get_start_priority ()
 
void set_start_priority (int priority)
 
- Public Member Functions inherited from sensesp::ValueProducer< WSConnectionState >
 ValueProducer ()
 
virtual const WSConnectionStateget () const
 
void connect_to (ValueConsumer< WSConnectionState > *consumer, uint8_t input_channel=0)
 
void connect_to (ValueConsumer< CT > *consumer, uint8_t input_channel=0)
 Connect a producer to a consumer of a different type.
 
Transform< WSConnectionState, T2 > * connect_to (Transform< WSConnectionState, T2 > *consumer_producer, uint8_t input_channel=0)
 
Transform< TT, T2 > * connect_to (Transform< TT, T2 > *consumer_producer, uint8_t input_channel=0)
 Connect a producer to a transform with a different input type.
 
void emit (WSConnectionState 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::Startable
static void start_all ()
 
- 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
 
- Protected Attributes inherited from sensesp::ValueProducer< WSConnectionState >
WSConnectionState output
 

Detailed Description

The websocket connection to the Signal K server.

See also
SensESPApp

Definition at line 31 of file ws_client.h.

Constructor & Destructor Documentation

◆ WSClient()

sensesp::WSClient::WSClient ( String  config_path,
SKDeltaQueue sk_delta_queue,
String  server_address,
uint16_t  server_port 
)

Definition at line 77 of file ws_client.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ connect()

void sensesp::WSClient::connect ( )

Definition at line 379 of file ws_client.cpp.

Here is the caller graph for this function:

◆ get_config_schema()

String sensesp::WSClient::get_config_schema ( )
overridevirtual

Returns a configuration schema that specifies the key/value pairs that can be expected when calling get_configuration(), or are expected by set_configuration(). The schema will be in JSON Schema format

See also
https://json-schema.org

Reimplemented from sensesp::Configurable.

Definition at line 660 of file ws_client.cpp.

◆ get_configuration()

void sensesp::WSClient::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 640 of file ws_client.cpp.

◆ get_connection_status()

String sensesp::WSClient::get_connection_status ( )

Get a String representation of the current connection state.

Returns
String

Definition at line 690 of file ws_client.cpp.

◆ get_delta_count_producer()

ValueProducer< int > & sensesp::WSClient::get_delta_count_producer ( )
inline

Return a delta update ValueProducer that produces the number of sent deltas (ordinarily always 1)

Definition at line 53 of file ws_client.h.

Here is the caller graph for this function:

◆ get_server_address()

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

Definition at line 42 of file ws_client.h.

◆ get_server_port()

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

Definition at line 43 of file ws_client.h.

◆ is_connected()

bool sensesp::WSClient::is_connected ( )

Definition at line 617 of file ws_client.cpp.

◆ loop()

void sensesp::WSClient::loop ( )

Definition at line 610 of file ws_client.cpp.

Here is the caller graph for this function:

◆ on_connected()

void sensesp::WSClient::on_connected ( uint8_t payload)

Called when the websocket connection is established.

Called in the websocket task context.

Parameters
payload

Definition at line 152 of file ws_client.cpp.

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

◆ on_disconnected()

void sensesp::WSClient::on_disconnected ( )

Called when the websocket connection is disconnected.

This method is called in the websocket task context.

Definition at line 120 of file ws_client.cpp.

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

◆ on_error()

void sensesp::WSClient::on_error ( )

Called when the websocket connection encounters an error.

Called in the websocket task context.

Definition at line 140 of file ws_client.cpp.

Here is the caller graph for this function:

◆ on_receive_delta()

void sensesp::WSClient::on_receive_delta ( uint8_t payload)

Called when the websocket receives a delta.

Called in the websocket task context.

Parameters
payload

Definition at line 209 of file ws_client.cpp.

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

◆ on_receive_put()

void sensesp::WSClient::on_receive_put ( DynamicJsonDocument message)

Called when a PUT event is received.

Called in the websocket task context.

Parameters
message

Definition at line 311 of file ws_client.cpp.

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

◆ on_receive_updates()

void sensesp::WSClient::on_receive_updates ( DynamicJsonDocument message)

Called when a delta update is received.

Called in the websocket task context.

Parameters
message

Definition at line 243 of file ws_client.cpp.

Here is the caller graph for this function:

◆ restart()

void sensesp::WSClient::restart ( )

Definition at line 621 of file ws_client.cpp.

◆ send_delta()

void sensesp::WSClient::send_delta ( )

Definition at line 628 of file ws_client.cpp.

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

◆ sendTXT()

void sensesp::WSClient::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 359 of file ws_client.cpp.

◆ set_configuration()

bool sensesp::WSClient::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 662 of file ws_client.cpp.

◆ start()

void sensesp::WSClient::start ( )
overridevirtual

Called during the initialization process. Override this method to add runtime initialization code to your class

Reimplemented from sensesp::Startable.

Definition at line 102 of file ws_client.cpp.

Here is the call graph for this function:

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