: Split this file into csp and csp-socket files? 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
connpubsub_conn to receive from
bufferbuffer to store data in
buffer_sizeexpected size of buffer
portexpected 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
connpubsub_conn containing a valid csp_conn_t *
datavoid pointer to data to be sent
lengthlength 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
socketpointer to socket handle
connpointer 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
portport to bind server to
num_connectionsnumber 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
socketpointer to csp socket handle.
connpointer 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
connpointer to pubsub_conn where connection info will be stored
addressaddress of server
portport 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
connpubsub_conn to receive from
bufferbuffer to store data in
buffer_sizeexpected size of buffer
portexpected 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
connpointer 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
connpointer to pubsub_conn where connection info will be stored
addressaddress of server
portport of server
Returns
bool true if successful, otherwise false