Mon, 29 Oct 2018 19:37:14 +0100
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
/** * @file websocket_server.h * @brief Websocket server functions. * @author Blake Felt - blake.w.felt@gmail.com` */ #ifdef __cplusplus extern "C" { #endif #ifndef WEBSOCKET_SERVER_H #define WEBSOCKET_SERVER_H #include "websocket.h" #define WEBSOCKET_SERVER_MAX_CLIENTS CONFIG_WEBSOCKET_SERVER_MAX_CLIENTS ///< Maximum allowed clients #define WEBSOCKET_SERVER_QUEUE_SIZE CONFIG_WEBSOCKET_SERVER_QUEUE_SIZE ///< Webserver requests queue size #define WEBSOCKET_SERVER_QUEUE_TIMEOUT CONFIG_WEBSOCKET_SERVER_QUEUE_TIMEOUT ///< Queue timeout #define WEBSOCKET_SERVER_TASK_STACK_DEPTH CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH ///< Task stack size #define WEBSOCKET_SERVER_TASK_PRIORITY CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY ///< Task priority #define WEBSOCKET_SERVER_PINNED CONFIG_WEBSOCKET_SERVER_PINNED ///< Pinned to a CPU #if WEBSOCKET_SERVER_PINNED #define WEBSOCKET_SERVER_PINNED_CORE CONFIG_WEBSOCKET_SERVER_PINNED_CORE ///< If pinned, which CPU #endif /** * @brief Starts the server. * @return 1 if started, 0 if the server was already started. */ int ws_server_start(); /** * @brief Stops the server. * @return 1 if stopped, 0 if the server was not running. */ int ws_server_stop(); /** * @brief Adds a client, returns the client's number in the server. * @param conn The network connection. * @param msg The message received from the client. * @param len The length of the message. * @param url The url of the connection. * @param callback The callback function. * @return Negative if an error, else the connection number. */ int ws_server_add_client(struct netconn* conn, char* msg, uint16_t len, char* url, void (*callback)(uint8_t num, WEBSOCKET_TYPE_t type, char* msg, uint64_t len)); /** * @brief Adds a client, returns the client's number in the server. * @param conn The network connection. * @param msg The message received from the client. * @param len The length of the message. * @param url The url of the connection. * @param protocol The protocol requested by the client. * @param callback The callback function. * @return Negative if an error, else the connection number. */ int ws_server_add_client_protocol(struct netconn* conn, char* msg, uint16_t len, char* url, char* protocol, void (*callback)(uint8_t num, WEBSOCKET_TYPE_t type, char* msg, uint64_t len)); /** * @brief Returns the number of connected clients to url * @param url The url to check. * @return The number of connected clients. */ int ws_server_len_url(char* url); /** * @brief Returns the total number of connected clients. * @return The number of connected clients. */ int ws_server_len_all(); /** * @brief Removes the client with the set number * @param num The client number. * @return 1 if success, else 0. */ int ws_server_remove_client(int num); /** * @brief Removes all clients connected to the specified url. * @param url The connection url. * @return The number of clients removed. */ int ws_server_remove_clients(char* url); /** * @brief Removes all clients from the server. * @return The number of clients removed. */ int ws_server_remove_all(); /** * @brief Send text to client with the set number. * @param num The client connection number. * @param msg The message to send. * @param len The length of the message to send. * @return 1 if message send. */ int ws_server_send_text_client(int num,char* msg,uint64_t len); int ws_server_send_text_client_from_callback(int num,char* msg,uint64_t len); /** * @brief Sends text to all clients with the set url. * @param url The clients url. * @param msg The message to send. * @param len The length of the message to send. * @return The number of clients the message was send to. */ int ws_server_send_text_clients(char* url,char* msg,uint64_t len); int ws_server_send_text_clients_from_callback(char* url,char* msg,uint64_t len); /** * @brief Sends text to all clients. * @param msg The message to send. * @param len The length of the message to send. * @return The number of clients the message was send to. */ int ws_server_send_text_all(char* msg,uint64_t len); int ws_server_send_text_all_from_callback(char* msg,uint64_t len); /** * @brief Send binary message to client with the set number. * @param num The client connection number. * @param msg The message to send. * @param len The length of the message to send. * @return 1 if message send. */ int ws_server_send_bin_client(int num,char* msg,uint64_t len); int ws_server_send_bin_client_from_callback(int num,char* msg,uint64_t len); /** * @brief Sends binary message to all clients with the set url. * @param url The clients url. * @param msg The message to send. * @param len The length of the message to send. * @return The number of clients the message was send to. */ int ws_server_send_bin_clients(char* url,char* msg,uint64_t len); /** * @brief Sends binary message to all clients. * @param msg The message to send. * @param len The length of the message to send. * @return The number of clients the message was send to. */ int ws_server_send_bin_all(char* msg,uint64_t len); /** * @brief Websocket ping (not working yet) * @param num The connection number * @return 1 if succeeded. */ int ws_server_ping(int num); #endif #ifdef __cplusplus } #endif