fix code style

This commit is contained in:
Links
2022-04-05 19:10:57 +02:00
parent 8d76469e90
commit ab9af162b2
5 changed files with 48 additions and 48 deletions

View File

@ -42,13 +42,13 @@ extern "C" {
#include <esp_system.h> #include <esp_system.h>
#if ESP_IDF_VERSION_MAJOR >= 4 #if ESP_IDF_VERSION_MAJOR >= 4
#if ( ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(1, 0, 6) ) #if(ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(1, 0, 6))
#include "sha/sha_parallel_engine.h" #include "sha/sha_parallel_engine.h"
#else
#include <esp32/sha.h>
#endif
#else #else
#include <hwcrypto/sha.h> #include <esp32/sha.h>
#endif
#else
#include <hwcrypto/sha.h>
#endif #endif
#else #else
@ -472,7 +472,7 @@ void WebSockets::handleWebsocketPayloadCb(WSclient_t * client, bool ok, uint8_t
payload[header->payloadLen] = 0x00; payload[header->payloadLen] = 0x00;
if(header->mask) { if(header->mask) {
//decode XOR // decode XOR
for(size_t i = 0; i < header->payloadLen; i++) { for(size_t i = 0; i < header->payloadLen; i++) {
payload[i] = (payload[i] ^ header->maskKey[i % 4]); payload[i] = (payload[i] ^ header->maskKey[i % 4]);
} }
@ -526,7 +526,7 @@ void WebSockets::handleWebsocketPayloadCb(WSclient_t * client, bool ok, uint8_t
// reset input // reset input
client->cWsRXsize = 0; client->cWsRXsize = 0;
#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC)
//register callback for next message // register callback for next message
handleWebsocketWaitFor(client, 2); handleWebsocketWaitFor(client, 2);
#endif #endif
@ -644,9 +644,9 @@ bool WebSockets::readCb(WSclient_t * client, uint8_t * out, size_t n, WSreadWait
t = millis(); t = millis();
out += len; out += len;
n -= len; n -= len;
//DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); // DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n);
} else { } else {
//DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n); // DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n);
} }
if(n > 0) { if(n > 0) {
WEBSOCKETS_YIELD(); WEBSOCKETS_YIELD();
@ -698,7 +698,7 @@ size_t WebSockets::write(WSclient_t * client, uint8_t * out, size_t n) {
out += len; out += len;
n -= len; n -= len;
total += len; total += len;
//DEBUG_WEBSOCKETS("write %d left %d!\n", len, n); // DEBUG_WEBSOCKETS("write %d left %d!\n", len, n);
} else { } else {
DEBUG_WEBSOCKETS("WS write %d failed left %d!\n", len, n); DEBUG_WEBSOCKETS("WS write %d failed left %d!\n", len, n);
} }

View File

@ -86,7 +86,7 @@
#define WEBSOCKETS_YIELD_MORE() #define WEBSOCKETS_YIELD_MORE()
#else #else
//atmega328p has only 2KB ram! // atmega328p has only 2KB ram!
#define WEBSOCKETS_MAX_DATA_SIZE (1024) #define WEBSOCKETS_MAX_DATA_SIZE (1024)
// moves all Header strings to Flash // moves all Header strings to Flash
#define WEBSOCKETS_SAVE_RAM #define WEBSOCKETS_SAVE_RAM

View File

@ -154,11 +154,11 @@ class WebSocketsClient : protected WebSockets {
#endif #endif
/** /**
* called for sending a Event to the app * called for sending a Event to the app
* @param type WStype_t * @param type WStype_t
* @param payload uint8_t * * @param payload uint8_t *
* @param length size_t * @param length size_t
*/ */
virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) { virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) {
if(_cbEvent) { if(_cbEvent) {
_cbEvent(type, payload, length); _cbEvent(type, payload, length);

View File

@ -621,8 +621,8 @@ WSclient_t * WebSocketsServerCore::handleNewClient(WEBSOCKETS_NETWORK_CLASS * tc
#endif #endif
// no client! => create dummy! // no client! => create dummy!
WSclient_t dummy = WSclient_t(); WSclient_t dummy = WSclient_t();
client = & dummy; client = &dummy;
client->tcp = tcpClient; client->tcp = tcpClient;
dropNativeClient(client); dropNativeClient(client);
} }
@ -663,7 +663,7 @@ void WebSocketsServerCore::handleClientData(void) {
if(clientIsConnected(client)) { if(clientIsConnected(client)) {
int len = client->tcp->available(); int len = client->tcp->available();
if(len > 0) { if(len > 0) {
//DEBUG_WEBSOCKETS("[WS-Server][%d][handleClientData] len: %d\n", client->num, len); // DEBUG_WEBSOCKETS("[WS-Server][%d][handleClientData] len: %d\n", client->num, len);
switch(client->status) { switch(client->status) {
case WSC_HEADER: { case WSC_HEADER: {
String headerLine = client->tcp->readStringUntil('\n'); String headerLine = client->tcp->readStringUntil('\n');
@ -717,7 +717,7 @@ void WebSocketsServerCore::handleHeader(WSclient_t * client, String * headerLine
// cut URL out // cut URL out
client->cUrl = headerLine->substring(4, headerLine->indexOf(' ', 4)); client->cUrl = headerLine->substring(4, headerLine->indexOf(' ', 4));
//reset non-websocket http header validation state for this client // reset non-websocket http header validation state for this client
client->cHttpHeadersValid = true; client->cHttpHeadersValid = true;
client->cMandatoryHeadersCount = 0; client->cMandatoryHeadersCount = 0;

View File

@ -132,10 +132,10 @@ class WebSocketsServerCore : protected WebSockets {
void handleHBPing(WSclient_t * client); // send ping in specified intervals void handleHBPing(WSclient_t * client); // send ping in specified intervals
/** /**
* called if a non Websocket connection is coming in. * called if a non Websocket connection is coming in.
* Note: can be override * Note: can be override
* @param client WSclient_t * ptr to the client struct * @param client WSclient_t * ptr to the client struct
*/ */
virtual void handleNonWebsocketConnection(WSclient_t * client) { virtual void handleNonWebsocketConnection(WSclient_t * client) {
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] no Websocket connection close.\n", client->num); DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] no Websocket connection close.\n", client->num);
client->tcp->write( client->tcp->write(
@ -151,10 +151,10 @@ class WebSocketsServerCore : protected WebSockets {
} }
/** /**
* called if a non Authorization connection is coming in. * called if a non Authorization connection is coming in.
* Note: can be override * Note: can be override
* @param client WSclient_t * ptr to the client struct * @param client WSclient_t * ptr to the client struct
*/ */
virtual void handleAuthorizationFailed(WSclient_t * client) { virtual void handleAuthorizationFailed(WSclient_t * client) {
client->tcp->write( client->tcp->write(
"HTTP/1.1 401 Unauthorized\r\n" "HTTP/1.1 401 Unauthorized\r\n"
@ -170,12 +170,12 @@ class WebSocketsServerCore : protected WebSockets {
} }
/** /**
* called for sending a Event to the app * called for sending a Event to the app
* @param num uint8_t * @param num uint8_t
* @param type WStype_t * @param type WStype_t
* @param payload uint8_t * * @param payload uint8_t *
* @param length size_t * @param length size_t
*/ */
virtual void runCbEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { virtual void runCbEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
if(_cbEvent) { if(_cbEvent) {
_cbEvent(num, type, payload, length); _cbEvent(num, type, payload, length);
@ -183,19 +183,19 @@ class WebSocketsServerCore : protected WebSockets {
} }
/* /*
* Called at client socket connect handshake negotiation time for each http header that is not * Called at client socket connect handshake negotiation time for each http header that is not
* a websocket specific http header (not Connection, Upgrade, Sec-WebSocket-*) * a websocket specific http header (not Connection, Upgrade, Sec-WebSocket-*)
* If the custom httpHeaderValidationFunc returns false for any headerName / headerValue passed, the * If the custom httpHeaderValidationFunc returns false for any headerName / headerValue passed, the
* socket negotiation is considered invalid and the upgrade to websockets request is denied / rejected * socket negotiation is considered invalid and the upgrade to websockets request is denied / rejected
* This mechanism can be used to enable custom authentication schemes e.g. test the value * This mechanism can be used to enable custom authentication schemes e.g. test the value
* of a session cookie to determine if a user is logged on / authenticated * of a session cookie to determine if a user is logged on / authenticated
*/ */
virtual bool execHttpHeaderValidation(String headerName, String headerValue) { virtual bool execHttpHeaderValidation(String headerName, String headerValue) {
if(_httpHeaderValidationFunc) { if(_httpHeaderValidationFunc) {
//return the value of the custom http header validation function // return the value of the custom http header validation function
return _httpHeaderValidationFunc(headerName, headerValue); return _httpHeaderValidationFunc(headerName, headerValue);
} }
//no custom http header validation so just assume all is good // no custom http header validation so just assume all is good
return true; return true;
} }
@ -205,14 +205,14 @@ class WebSocketsServerCore : protected WebSockets {
/** /**
* drop native tcp connection (client->tcp) * drop native tcp connection (client->tcp)
*/ */
void dropNativeClient(WSclient_t * client); void dropNativeClient(WSclient_t * client);
private: private:
/* /*
* returns an indicator whether the given named header exists in the configured _mandatoryHttpHeaders collection * returns an indicator whether the given named header exists in the configured _mandatoryHttpHeaders collection
* @param headerName String ///< the name of the header being checked * @param headerName String ///< the name of the header being checked
*/ */
bool hasMandatoryHeader(String headerName); bool hasMandatoryHeader(String headerName);
}; };