mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
1
This commit is contained in:
@@ -23,5 +23,5 @@ extern void hexdump(const void* mem, uint32_t len, uint8_t cols);
|
|||||||
|
|
||||||
void sendFileToWs3(const String& filename, uint8_t num);
|
void sendFileToWs3(const String& filename, uint8_t num);
|
||||||
void sendFileToWs4(const String& filename, uint8_t num);
|
void sendFileToWs4(const String& filename, uint8_t num);
|
||||||
void sendFileToWs5(const char* filename, uint8_t num);
|
void sendFileToWs5(const char* filename, uint8_t num, size_t frameSize);
|
||||||
void sendMark(const char* filename, const char* mark, uint8_t num);
|
void sendMark(const char* filename, const char* mark, uint8_t num);
|
||||||
@@ -221,8 +221,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (headerStr == "/config") {
|
if (headerStr == "/config") {
|
||||||
sendFileToWs5("/widgets.json", num);
|
sendFileToWs5("/widgets.json", num, 1024);
|
||||||
sendFileToWs5("/config.json", num);
|
sendFileToWs5("/config.json", num, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headerStr == "/gifnoc") {
|
if (headerStr == "/gifnoc") {
|
||||||
@@ -284,9 +284,8 @@ void hexdump(const void* mem, uint32_t len, uint8_t cols = 16) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//посылка данных из файла в бинарном виде
|
//посылка данных из файла в бинарном виде
|
||||||
void sendFileToWs5(const char* filename, uint8_t num) {
|
void sendFileToWs5(const char* filename, uint8_t num, size_t frameSize) {
|
||||||
sendMark(filename, "/st", num);
|
sendMark(filename, "/st", num);
|
||||||
size_t ws_buffer = 1024;
|
|
||||||
String path = filepath(filename);
|
String path = filepath(filename);
|
||||||
auto file = FileFS.open(path, "r");
|
auto file = FileFS.open(path, "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -295,7 +294,7 @@ void sendFileToWs5(const char* filename, uint8_t num) {
|
|||||||
}
|
}
|
||||||
size_t fileSize = file.size();
|
size_t fileSize = file.size();
|
||||||
SerialPrint(F("i"), F("FS"), "Send file '" + String(filename) + "', file size: " + String(fileSize));
|
SerialPrint(F("i"), F("FS"), "Send file '" + String(filename) + "', file size: " + String(fileSize));
|
||||||
uint8_t payload[ws_buffer + 1];
|
uint8_t payload[frameSize + 1];
|
||||||
int countRead = file.read(payload, sizeof(payload) - 1);
|
int countRead = file.read(payload, sizeof(payload) - 1);
|
||||||
while (countRead > 0) {
|
while (countRead > 0) {
|
||||||
payload[countRead] = 0;
|
payload[countRead] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user