Pubsub¶
-
csp_socket_t *
kprv_server_setup
(uint8_t port, uint8_t num_connections)¶ Performs the necessary setup for the telemetry server to begin receiving subscriber connections.
- Return
- csp_socket_t * pointer to created socket handle
- Parameters
port
: port to bind server tonum_connections
: number of connections for server to listen to
-
bool
kprv_server_accept
(csp_socket_t *socket, pubsub_conn *conn)¶ Attempts to accept a subscriber connection.
- Return
- bool true if successful, otherwise false
- Parameters
socket
: pointer to socket handleconn
: pointer to pubsub_conn where connection info will be stored
-
bool
kprv_server_socket_accept
(csp_socket_t *socket, pubsub_conn *conn)¶ Attempts to accept a subscriber connection over a tcp socket.
- Return
- bool true if successful, otherwise false
- Parameters
socket
: pointer to csp socket handle.conn
: pointer to pubsub_conn where connection info will be stored
-
void
kprv_subscriber_socket_close
(pubsub_conn *conn)¶ Performs shutdown and cleanup of tcp socket based connections.
- Parameters
conn
: pointer to pubsub_conn where connection info is stored
-
bool
kprv_subscriber_connect
(pubsub_conn *conn, uint8_t address, uint8_t port)¶ Used by a telemetry subscriber to connect to the publishing server.
- Return
- bool true if successful, otherwise false
- Parameters
conn
: pointer to pubsub_conn where connection info will be storedaddress
: address of serverport
: port of server
-
bool
kprv_subscriber_socket_connect
(pubsub_conn *conn, uint8_t address, uint8_t port)¶ Used by a client to connect to a server using a tcp socket.
- Return
- bool true if successful, otherwise false
- Parameters
conn
: pointer to pubsub_conn where connection info will be storedaddress
: address of serverport
: port of server
-
bool
kprv_publisher_read
(const pubsub_conn *conn, void *buffer, int buffer_size, uint8_t port)¶ Attempts to receive data over the specified pubsub_conn.
- Return
- bool true if successful, otherwise false
- Parameters
conn
: pubsub_conn to receive frombuffer
: buffer to store data inbuffer_size
: expected size of bufferport
: expected port for data to come in on
-
bool
kprv_subscriber_read
(const pubsub_conn *conn, void *buffer, int buffer_size, uint8_t port)¶ Attempts to receive data over the specified pubsub_conn.
- Return
- bool true if successful, otherwise false
- Parameters
conn
: pubsub_conn to receive frombuffer
: buffer to store data inbuffer_size
: expected size of bufferport
: expected port for data to come in on
-
bool
kprv_send_csp
(const pubsub_conn *conn, const void *data, uint16_t length)¶ Wrapper function for sending data via a csp connection.
- Return
- bool true if successful, otherwise false
- Parameters
conn
: pubsub_conn containing a valid csp_conn_t *data
: void pointer to data to be sentlength
: length of the data to be sent
-
struct
pubsub_conn
¶ - #include <pubsub.h>
PubSub connection structure ...