Wed, 10 Jun 2020 09:43:51 +0200
SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
0 | 1 | /** |
2 | * @file websocket_server.h | |
3 | * @brief Websocket server functions. | |
4 | * @author Blake Felt - blake.w.felt@gmail.com` | |
5 | */ | |
6 | ||
7 | #ifdef __cplusplus | |
8 | extern "C" { | |
9 | #endif | |
10 | ||
11 | #ifndef WEBSOCKET_SERVER_H | |
12 | #define WEBSOCKET_SERVER_H | |
13 | ||
14 | #include "websocket.h" | |
15 | ||
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
16 | #define WEBSOCKET_SERVER_MAX_CLIENTS CONFIG_WEBSOCKET_SERVER_MAX_CLIENTS ///< Maximum allowed clients |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
17 | #define WEBSOCKET_SERVER_QUEUE_SIZE CONFIG_WEBSOCKET_SERVER_QUEUE_SIZE ///< Webserver requests queue size |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
18 | #define WEBSOCKET_SERVER_QUEUE_TIMEOUT CONFIG_WEBSOCKET_SERVER_QUEUE_TIMEOUT ///< Queue timeout |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
19 | #define WEBSOCKET_SERVER_TASK_STACK_DEPTH CONFIG_WEBSOCKET_SERVER_TASK_STACK_DEPTH ///< Task stack size |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
20 | #define WEBSOCKET_SERVER_TASK_PRIORITY CONFIG_WEBSOCKET_SERVER_TASK_PRIORITY ///< Task priority |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
21 | #define WEBSOCKET_SERVER_PINNED CONFIG_WEBSOCKET_SERVER_PINNED ///< Pinned to a CPU |
0 | 22 | #if WEBSOCKET_SERVER_PINNED |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
23 | #define WEBSOCKET_SERVER_PINNED_CORE CONFIG_WEBSOCKET_SERVER_PINNED_CORE ///< If pinned, which CPU |
0 | 24 | #endif |
25 | ||
26 | /** | |
27 | * @brief Starts the server. | |
28 | * @return 1 if started, 0 if the server was already started. | |
29 | */ | |
30 | int ws_server_start(); | |
31 | ||
32 | /** | |
33 | * @brief Stops the server. | |
34 | * @return 1 if stopped, 0 if the server was not running. | |
35 | */ | |
36 | int ws_server_stop(); | |
37 | ||
38 | /** | |
39 | * @brief Adds a client, returns the client's number in the server. | |
40 | * @param conn The network connection. | |
41 | * @param msg The message received from the client. | |
42 | * @param len The length of the message. | |
43 | * @param url The url of the connection. | |
44 | * @param callback The callback function. | |
45 | * @return Negative if an error, else the connection number. | |
46 | */ | |
47 | int ws_server_add_client(struct netconn* conn, | |
48 | char* msg, | |
49 | uint16_t len, | |
50 | char* url, | |
51 | void (*callback)(uint8_t num, WEBSOCKET_TYPE_t type, char* msg, uint64_t len)); | |
52 | ||
53 | /** | |
54 | * @brief Adds a client, returns the client's number in the server. | |
55 | * @param conn The network connection. | |
56 | * @param msg The message received from the client. | |
57 | * @param len The length of the message. | |
58 | * @param url The url of the connection. | |
59 | * @param protocol The protocol requested by the client. | |
60 | * @param callback The callback function. | |
61 | * @return Negative if an error, else the connection number. | |
62 | */ | |
63 | int ws_server_add_client_protocol(struct netconn* conn, | |
64 | char* msg, | |
65 | uint16_t len, | |
66 | char* url, | |
67 | char* protocol, | |
68 | void (*callback)(uint8_t num, WEBSOCKET_TYPE_t type, char* msg, uint64_t len)); | |
69 | ||
70 | /** | |
71 | * @brief Returns the number of connected clients to url | |
72 | * @param url The url to check. | |
73 | * @return The number of connected clients. | |
74 | */ | |
75 | int ws_server_len_url(char* url); | |
76 | ||
77 | /** | |
78 | * @brief Returns the total number of connected clients. | |
79 | * @return The number of connected clients. | |
80 | */ | |
81 | int ws_server_len_all(); | |
82 | ||
83 | /** | |
84 | * @brief Removes the client with the set number | |
85 | * @param num The client number. | |
86 | * @return 1 if success, else 0. | |
87 | */ | |
88 | int ws_server_remove_client(int num); | |
89 | ||
90 | /** | |
91 | * @brief Removes all clients connected to the specified url. | |
92 | * @param url The connection url. | |
93 | * @return The number of clients removed. | |
94 | */ | |
95 | int ws_server_remove_clients(char* url); | |
96 | ||
97 | /** | |
98 | * @brief Removes all clients from the server. | |
99 | * @return The number of clients removed. | |
100 | */ | |
101 | int ws_server_remove_all(); | |
102 | ||
103 | /** | |
104 | * @brief Send text to client with the set number. | |
105 | * @param num The client connection number. | |
106 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
107 | * @param len The length of the message to send. |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
108 | * @return 1 if message send. |
0 | 109 | */ |
110 | int ws_server_send_text_client(int num,char* msg,uint64_t len); | |
111 | int ws_server_send_text_client_from_callback(int num,char* msg,uint64_t len); | |
112 | ||
113 | /** | |
114 | * @brief Sends text to all clients with the set url. | |
115 | * @param url The clients url. | |
116 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
117 | * @param len The length of the message to send. |
0 | 118 | * @return The number of clients the message was send to. |
119 | */ | |
120 | int ws_server_send_text_clients(char* url,char* msg,uint64_t len); | |
121 | int ws_server_send_text_clients_from_callback(char* url,char* msg,uint64_t len); | |
122 | ||
123 | /** | |
124 | * @brief Sends text to all clients. | |
125 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
126 | * @param len The length of the message to send. |
0 | 127 | * @return The number of clients the message was send to. |
128 | */ | |
129 | int ws_server_send_text_all(char* msg,uint64_t len); | |
130 | int ws_server_send_text_all_from_callback(char* msg,uint64_t len); | |
131 | ||
132 | /** | |
133 | * @brief Send binary message to client with the set number. | |
134 | * @param num The client connection number. | |
135 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
136 | * @param len The length of the message to send. |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
137 | * @return 1 if message send. |
0 | 138 | */ |
139 | int ws_server_send_bin_client(int num,char* msg,uint64_t len); | |
140 | int ws_server_send_bin_client_from_callback(int num,char* msg,uint64_t len); | |
141 | ||
142 | /** | |
143 | * @brief Sends binary message to all clients with the set url. | |
144 | * @param url The clients url. | |
145 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
146 | * @param len The length of the message to send. |
0 | 147 | * @return The number of clients the message was send to. |
148 | */ | |
149 | int ws_server_send_bin_clients(char* url,char* msg,uint64_t len); | |
150 | ||
151 | /** | |
152 | * @brief Sends binary message to all clients. | |
153 | * @param msg The message to send. | |
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
154 | * @param len The length of the message to send. |
0 | 155 | * @return The number of clients the message was send to. |
156 | */ | |
157 | int ws_server_send_bin_all(char* msg,uint64_t len); | |
158 | ||
30
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
159 | /** |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
160 | * @brief Websocket ping (not working yet) |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
161 | * @param num The connection number |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
162 | * @return 1 if succeeded. |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
163 | */ |
3cc32f97410c
Swapped MLT and HLT SSR pins to match he real hardware. More doxygen changes.
Michiel Broek <mbroek@mbse.eu>
parents:
0
diff
changeset
|
164 | int ws_server_ping(int num); |
0 | 165 | |
166 | #endif | |
167 | ||
168 | #ifdef __cplusplus | |
169 | } | |
170 | #endif |