рабочая для 8266 версия

This commit is contained in:
Dmitry Borisenko
2021-12-24 01:26:50 +01:00
parent 756363397b
commit dbe11162e5
5 changed files with 26 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -8,9 +8,10 @@
#include <TickerScheduler.h>
#ifdef ESP32
#include <WiFi.h>
#include "WiFi.h"
#include <HTTPClient.h>
#include <HTTPUpdate.h>
#endif
#ifdef ESP8266
@@ -34,8 +35,10 @@
#ifdef STANDARD_WEB_SOCKETS
#include <WebSocketsServer.h>
#ifdef ESP8266
#include <Hash.h>
#endif
#endif
#include <FS.h>
@@ -49,6 +52,7 @@
**********************************************************************************************************************/
extern TickerScheduler ts;
extern WiFiClient espClient;
#ifdef ASYNC_WEB_SERVER
extern AsyncWebServer server;
#endif

View File

@@ -19,4 +19,7 @@ extern void handleFileList();
#ifdef STANDARD_WEB_SOCKETS
extern void standWebSocketsInit();
extern void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length);
#ifdef ESP32
extern void hexdump(const void* mem, uint32_t len, uint8_t cols);
#endif
#endif

View File

@@ -5,6 +5,7 @@
**********************************************************************************************************************/
TickerScheduler ts(MYTEST + 1);
WiFiClient espClient;
#ifdef ASYNC_WEB_SERVER
AsyncWebServer server(80);
#endif

View File

@@ -224,7 +224,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
case WStype_BIN: {
Serial.printf("[%u] get binary length: %u\n", num, length);
hexdump(payload, length);
//hexdump(payload, length);
// send message to client
// standWebSocket.sendBIN(num, payload, length);
@@ -232,4 +232,19 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
}
}
#ifdef ESP32
void hexdump(const void* mem, uint32_t len, uint8_t cols = 16) {
const uint8_t* src = (const uint8_t*)mem;
Serial.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
for (uint32_t i = 0; i < len; i++) {
if (i % cols == 0) {
Serial.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
}
Serial.printf("%02X ", *src);
src++;
}
Serial.printf("\n");
}
#endif
#endif