mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-06-27 16:01:01 +02:00
Compare commits
1 Commits
master
...
printf_deb
Author | SHA1 | Date | |
---|---|---|---|
83a87f7877 |
2
.github/workflows/arduino-lint.yaml
vendored
2
.github/workflows/arduino-lint.yaml
vendored
@ -5,6 +5,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: arduino/arduino-lint-action@v2
|
- uses: arduino/arduino-lint-action@v1
|
||||||
with:
|
with:
|
||||||
library-manager: update
|
library-manager: update
|
||||||
|
@ -47,7 +47,6 @@ a WebSocket Server and Client for Arduino based on RFC6455.
|
|||||||
### wss / SSL ###
|
### wss / SSL ###
|
||||||
supported for:
|
supported for:
|
||||||
- wss client on the ESP8266
|
- wss client on the ESP8266
|
||||||
- wss / SSL for ESP32 in client mode
|
|
||||||
- wss / SSL is not natively supported in WebSocketsServer however it is possible to achieve secure websockets
|
- wss / SSL is not natively supported in WebSocketsServer however it is possible to achieve secure websockets
|
||||||
by running the device behind an SSL proxy. See [Nginx](examples/Nginx/esp8266.ssl.reverse.proxy.conf) for a
|
by running the device behind an SSL proxy. See [Nginx](examples/Nginx/esp8266.ssl.reverse.proxy.conf) for a
|
||||||
sample Nginx server configuration file to enable this.
|
sample Nginx server configuration file to enable this.
|
||||||
|
@ -54,7 +54,7 @@ void socketIOEvent(socketIOmessageType_t type, uint8_t * payload, size_t length)
|
|||||||
|
|
||||||
// Message Includes a ID for a ACK (callback)
|
// Message Includes a ID for a ACK (callback)
|
||||||
if(id) {
|
if(id) {
|
||||||
// create JSON message for Socket.IO (ack)
|
// creat JSON message for Socket.IO (ack)
|
||||||
DynamicJsonDocument docOut(1024);
|
DynamicJsonDocument docOut(1024);
|
||||||
JsonArray array = docOut.to<JsonArray>();
|
JsonArray array = docOut.to<JsonArray>();
|
||||||
|
|
||||||
@ -130,11 +130,11 @@ void loop() {
|
|||||||
if(now - messageTimestamp > 2000) {
|
if(now - messageTimestamp > 2000) {
|
||||||
messageTimestamp = now;
|
messageTimestamp = now;
|
||||||
|
|
||||||
// create JSON message for Socket.IO (event)
|
// creat JSON message for Socket.IO (event)
|
||||||
DynamicJsonDocument doc(1024);
|
DynamicJsonDocument doc(1024);
|
||||||
JsonArray array = doc.to<JsonArray>();
|
JsonArray array = doc.to<JsonArray>();
|
||||||
|
|
||||||
// add event name
|
// add evnet name
|
||||||
// Hint: socket.on('event_name', ....
|
// Hint: socket.on('event_name', ....
|
||||||
array.add("event_name");
|
array.add("event_name");
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ void loop() {
|
|||||||
JsonObject param1 = array.createNestedObject();
|
JsonObject param1 = array.createNestedObject();
|
||||||
param1["now"] = (uint32_t) now;
|
param1["now"] = (uint32_t) now;
|
||||||
|
|
||||||
// JSON to String (serialization)
|
// JSON to String (serializion)
|
||||||
String output;
|
String output;
|
||||||
serializeJson(doc, output);
|
serializeJson(doc, output);
|
||||||
|
|
||||||
|
@ -50,7 +50,10 @@
|
|||||||
DEBUG_ESP_PORT.flush(); \
|
DEBUG_ESP_PORT.flush(); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// #define DEBUG_WEBSOCKETS(...) os_printf( __VA_ARGS__ )
|
#ifdef DEBUG_PORT
|
||||||
|
#define DEBUG_WEBSOCKETS(...) websocket_debug_printf(__VA_ARGS__)
|
||||||
|
void websocket_debug_printf(const char * format, ...);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
32
src/debug.cpp
Normal file
32
src/debug.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
#include "WebSockets.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_PORT
|
||||||
|
|
||||||
|
void websocket_debug_printf(const char * format, ...) {
|
||||||
|
va_list arg;
|
||||||
|
va_start(arg, format);
|
||||||
|
char temp[64];
|
||||||
|
char * buffer = temp;
|
||||||
|
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
if(len > sizeof(temp) - 1) {
|
||||||
|
buffer = new(std::nothrow) char[len + 1];
|
||||||
|
if(!buffer) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
va_start(arg, format);
|
||||||
|
vsnprintf(buffer, len + 1, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
}
|
||||||
|
len = DEBUG_PORT.write((const uint8_t *)buffer, len);
|
||||||
|
if(buffer != temp) {
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
DEBUG_PORT.flush();
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -73,7 +73,7 @@ def get_library_json_version():
|
|||||||
|
|
||||||
def get_header_versions():
|
def get_header_versions():
|
||||||
data = {}
|
data = {}
|
||||||
define = re.compile('^#define WEBSOCKETS_VERSION_?(.*) "?([0-9\.]*)"?$')
|
define = re.compile('^#define WEBSOCKETS_VERSION_?(.*) "?([0-9\\.]*)"?$')
|
||||||
with open(f'{base_dir}/src/WebSocketsVersion.h', 'r') as f:
|
with open(f'{base_dir}/src/WebSocketsVersion.h', 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
m = define.match(line)
|
m = define.match(line)
|
||||||
|
Reference in New Issue
Block a user