|
SensESP 3.3.0
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, std::shared_ptr< 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 bool | to_json (JsonObject &root) override final |
| virtual bool | from_json (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 () |
| bool | is_connect_due () const |
| void | send_delta () |
| void | sendTXT (String &payload) |
| Send some processed data to the websocket. | |
| bool | is_ssl_enabled () const |
| Check if SSL/TLS is enabled. | |
| void | set_ssl_enabled (bool enabled) |
| Enable or disable SSL/TLS manually. | |
| bool | is_tofu_enabled () const |
| Check if TOFU certificate verification is enabled. | |
| void | set_tofu_enabled (bool enabled) |
| Enable or disable TOFU certificate verification. | |
| bool | has_tofu_fingerprint () const |
| Check if a TOFU fingerprint is stored. | |
| const String & | get_tofu_fingerprint () const |
| Get the stored TOFU fingerprint. | |
| void | reset_tofu_fingerprint () |
| Reset the stored TOFU certificate fingerprint. | |
| void | set_tofu_fingerprint (const String &fingerprint) |
| Set the TOFU fingerprint (called from verify callback). | |
| Public Member Functions inherited from sensesp::FileSystemSaveable | |
| FileSystemSaveable (const String &config_path) | |
| virtual bool | load () override |
| Load and populate the object from a persistent storage. | |
| virtual bool | save () override |
| Save the object to a persistent storage. | |
| virtual bool | clear () override |
| Delete the data from a persistent storage. | |
| bool | find_config_file (const String &config_path, String &filename) |
| Public Member Functions inherited from sensesp::Saveable | |
| Saveable (const String &config_path) | |
| virtual bool | refresh () |
| Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state. | |
| const String & | get_config_path () const |
| Public Member Functions inherited from sensesp::ValueProducer< SKWSConnectionState > | |
| ValueProducer () | |
| virtual const SKWSConnectionState & | get () const |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< SKWSConnectionState, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type | connect_to (std::shared_ptr< VConsumer > consumer) |
| Connect a producer to a transform with a different input type. | |
| void | emit (const SKWSConnectionState &new_value) |
| Public Member Functions inherited from sensesp::Observable | |
| Observable () | |
| Observable (Observable &&other) | |
| Move constructor. | |
| void | notify () |
| int | attach (std::function< void()> observer) |
| Attach an observer callback. | |
| void | detach (int id) |
| Remove a previously attached observer by its ID. | |
Protected Member Functions | |
| bool | take_received_updates_semaphore (unsigned long int timeout_ms=0) |
| void | release_received_updates_semaphore () |
| void | process_received_updates () |
| Loop through the received updates and process them. | |
| void | test_token (const String host, const uint16_t port) |
| void | send_access_request (const String host, const uint16_t port) |
| void | poll_access_request (const String host, const uint16_t port, const String href) |
| void | connect_ws (const String &host, const uint16_t port) |
| void | subscribe_listeners () |
| Subscribes the SK delta paths to the websocket. | |
| bool | get_mdns_service (String &server_address, uint16_t &server_port) |
| bool | detect_ssl () |
| void | set_connection_state (SKWSConnectionState state) |
| SKWSConnectionState | get_connection_state () |
| void | schedule_reconnect () |
| void | reset_reconnect_interval () |
The websocket connection to the Signal K server.
Definition at line 36 of file signalk_ws_client.h.
| sensesp::SKWSClient::SKWSClient | ( | const String & | config_path, |
| std::shared_ptr< SKDeltaQueue > | sk_delta_queue, | ||
| const String & | server_address, | ||
| uint16_t | server_port, | ||
| bool | use_mdns = true ) |
| void sensesp::SKWSClient::connect | ( | ) |
|
protected |
Definition at line 1002 of file signalk_ws_client.cpp.
|
protected |
Definition at line 535 of file signalk_ws_client.cpp.
|
finaloverridevirtual |
Deserializes the current object data from a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 1118 of file signalk_ws_client.cpp.
|
inlineprotected |
| String sensesp::SKWSClient::get_connection_status | ( | ) |
Get a String representation of the current connection state.
Definition at line 1158 of file signalk_ws_client.cpp.
|
inline |
Get the delta rx count producer object.
Definition at line 66 of file signalk_ws_client.h.
|
inline |
Return a delta update ValueProducer that produces the number of sent deltas.
Definition at line 57 of file signalk_ws_client.h.
|
protected |
|
inline |
Definition at line 47 of file signalk_ws_client.h.
|
inline |
Definition at line 48 of file signalk_ws_client.h.
|
inline |
Get the stored TOFU fingerprint.
Definition at line 135 of file signalk_ws_client.h.
|
inline |
Check if a TOFU fingerprint is stored.
Definition at line 130 of file signalk_ws_client.h.
|
inline |
Definition at line 85 of file signalk_ws_client.h.
| bool sensesp::SKWSClient::is_connected | ( | ) |
|
inline |
Check if SSL/TLS is enabled.
Definition at line 98 of file signalk_ws_client.h.
|
inline |
Check if TOFU certificate verification is enabled.
Definition at line 114 of file signalk_ws_client.h.
| void sensesp::SKWSClient::loop | ( | ) |
Definition at line 653 of file signalk_ws_client.cpp.
| void sensesp::SKWSClient::on_connected | ( | ) |
Called when the websocket connection is established.
Called in the websocket task context.
Definition at line 232 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 202 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 222 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 296 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 418 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 341 of file signalk_ws_client.cpp.
|
protected |
Definition at line 882 of file signalk_ws_client.cpp.
|
protected |
Loop through the received updates and process them.
This method is called in the main task context.
Definition at line 375 of file signalk_ws_client.cpp.
|
inlineprotected |
|
inlineprotected |
|
inline |
Reset the stored TOFU certificate fingerprint.
Call this when the server certificate has changed legitimately and you want to trust the new certificate.
Definition at line 143 of file signalk_ws_client.h.
| void sensesp::SKWSClient::restart | ( | ) |
Definition at line 1071 of file signalk_ws_client.cpp.
|
inlineprotected |
|
protected |
Definition at line 749 of file signalk_ws_client.cpp.
| void sensesp::SKWSClient::send_delta | ( | ) |
| 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 481 of file signalk_ws_client.cpp.
|
inlineprotected |
|
inline |
Enable or disable SSL/TLS manually.
Note: SSL is normally auto-detected. Use this only if you need to override the auto-detection behavior.
Definition at line 106 of file signalk_ws_client.h.
|
inline |
Enable or disable TOFU certificate verification.
When enabled, the server certificate fingerprint is captured on first connection and verified on subsequent connections.
Definition at line 122 of file signalk_ws_client.h.
|
inline |
Set the TOFU fingerprint (called from verify callback).
Definition at line 151 of file signalk_ws_client.h.
|
protected |
Subscribes the SK delta paths to the websocket.
Called in the websocket task context.
Definition at line 246 of file signalk_ws_client.cpp.
|
inlineprotected |
|
protected |
Definition at line 657 of file signalk_ws_client.cpp.
|
finaloverridevirtual |
Serializes the current object data into a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 1103 of file signalk_ws_client.cpp.
|
protected |
Definition at line 167 of file signalk_ws_client.h.
|
protected |
Definition at line 187 of file signalk_ws_client.h.
|
protected |
Definition at line 165 of file signalk_ws_client.h.
|
protected |
Definition at line 161 of file signalk_ws_client.h.
|
protected |
Definition at line 162 of file signalk_ws_client.h.
|
protected |
Definition at line 172 of file signalk_ws_client.h.
|
protected |
Definition at line 179 of file signalk_ws_client.h.
|
protected |
Definition at line 192 of file signalk_ws_client.h.
|
protected |
Definition at line 191 of file signalk_ws_client.h.
|
protected |
Emits the number of deltas sent since last report.
Definition at line 190 of file signalk_ws_client.h.
|
protected |
Definition at line 171 of file signalk_ws_client.h.
|
protected |
Definition at line 166 of file signalk_ws_client.h.
|
protected |
Definition at line 197 of file signalk_ws_client.h.
|
protected |
Definition at line 195 of file signalk_ws_client.h.
|
protected |
Definition at line 194 of file signalk_ws_client.h.
|
protected |
Definition at line 158 of file signalk_ws_client.h.
|
protected |
Definition at line 168 of file signalk_ws_client.h.
|
protected |
Definition at line 159 of file signalk_ws_client.h.
|
protected |
Definition at line 188 of file signalk_ws_client.h.
|
protected |
Definition at line 175 of file signalk_ws_client.h.
|
protected |
task_connection_state is used to track the internal task state which might be out of sync with the published connection state.
Definition at line 184 of file signalk_ws_client.h.
|
protected |
Definition at line 176 of file signalk_ws_client.h.
|
protected |
Definition at line 177 of file signalk_ws_client.h.
|
protected |
Definition at line 169 of file signalk_ws_client.h.
|
protected |
Definition at line 163 of file signalk_ws_client.h.