PubSub
Internal PubSub API. More...
Data Structures | |
struct | pubsub_conn |
PubSub connection structure. More... | |
Functions | |
csp_socket_t * | kprv_server_setup (uint8_t port, uint8_t num_connections) |
Performs the neccesary setup for the telemetry server to begin receiving subscriber connections. More... | |
bool | kprv_server_accept (csp_socket_t *socket, pubsub_conn *conn) |
Attempts to accept a subscriber connection. More... | |
bool | kprv_server_socket_accept (csp_socket_t *socket, pubsub_conn *conn) |
Attempts to accept a subscriber connection over a tcp socket. More... | |
void | kprv_subscriber_socket_close (pubsub_conn *conn) |
Performs shutdown and cleanup of tcp socket based connections. More... | |
bool | kprv_subscriber_connect (pubsub_conn *conn, uint8_t address, uint8_t port) |
Used by a telemetry subscriber to connect to the publishing server. More... | |
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. More... | |
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. More... | |
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. More... | |
bool | kprv_send_csp (const pubsub_conn *conn, const void *data, uint16_t length) |
Wrapper function for sending data via a csp connection. More... | |
Function Documentation
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.
- Parameters
-
conn pubsub_conn to receive from buffer buffer to store data in buffer_size expected size of buffer port expected port for data to come in on
- Returns
- bool true if successful, otherwise false
bool kprv_send_csp | ( | const pubsub_conn * | conn, |
const void * | data, | ||
uint16_t | length | ||
) |
Wrapper function for sending data via a csp connection.
- Parameters
-
conn pubsub_conn containing a valid csp_conn_t * data void pointer to data to be sent length length of the data to be sent
- Returns
- bool true if successful, otherwise false
bool kprv_server_accept | ( | csp_socket_t * | socket, |
pubsub_conn * | conn | ||
) |
Attempts to accept a subscriber connection.
- Parameters
-
socket pointer to socket handle conn pointer to pubsub_conn where connection info will be stored
- Returns
- bool true if successful, otherwise false
csp_socket_t* kprv_server_setup | ( | uint8_t | port, |
uint8_t | num_connections | ||
) |
Performs the neccesary setup for the telemetry server to begin receiving subscriber connections.
- Parameters
-
port port to bind server to num_connections number of connections for server to listen to
- Returns
- csp_socket_t * pointer to created socket handle
bool kprv_server_socket_accept | ( | csp_socket_t * | socket, |
pubsub_conn * | conn | ||
) |
Attempts to accept a subscriber connection over a tcp socket.
- Parameters
-
socket pointer to csp socket handle. conn pointer to pubsub_conn where connection info will be stored
- Returns
- bool true if successful, otherwise false
bool kprv_subscriber_connect | ( | pubsub_conn * | conn, |
uint8_t | address, | ||
uint8_t | port | ||
) |
Used by a telemetry subscriber to connect to the publishing server.
- Parameters
-
conn pointer to pubsub_conn where connection info will be stored address address of server port port of server
- Returns
- bool true if successful, otherwise false
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.
- Parameters
-
conn pubsub_conn to receive from buffer buffer to store data in buffer_size expected size of buffer port expected port for data to come in on
- Returns
- bool true if successful, otherwise false
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_socket_connect | ( | pubsub_conn * | conn, |
uint8_t | address, | ||
uint8_t | port | ||
) |
Used by a client to connect to a server using a tcp socket.
- Parameters
-
conn pointer to pubsub_conn where connection info will be stored address address of server port port of server
- Returns
- bool true if successful, otherwise false