Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ jobs:
arduino-cli lib install PubSubClient@${{ env.PUB_SUB_CLIENT_VERSION }}
arduino-cli lib install SmartRC-CC1101-Driver-Lib@${{ env.SMARTRC_CC1101_VERSION }}
arduino-cli lib install WebSockets@${{ env.WEB_SOCKET_VERSION }}
arduino-cli lib install "ESP Async WebServer"
arduino-cli lib install AsyncTCP

- name: Build ${{ matrix.name }}
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ jobs:
arduino-cli lib install PubSubClient@${{ env.PUB_SUB_CLIENT_VERSION }}
arduino-cli lib install SmartRC-CC1101-Driver-Lib@${{ env.SMARTRC_CC1101_VERSION }}
arduino-cli lib install WebSockets@${{ env.WEB_SOCKET_VERSION }}
arduino-cli lib install "ESP Async WebServer"
arduino-cli lib install AsyncTCP

- name: Build ${{ matrix.name }}
run: |
Expand Down
1 change: 1 addition & 0 deletions Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <esp_task_wdt.h>
#include "ConfigSettings.h"
#include "Network.h"
#include "Somfy.h"
#include "Web.h"
#include "Sockets.h"
#include "Utils.h"
Expand Down
1 change: 0 additions & 1 deletion Somfy.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Preferences.h>
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <SPI.h>
#include <WebServer.h>
#include <esp_task_wdt.h>
#include "Utils.h"
#include "ConfigSettings.h"
Expand Down
13 changes: 7 additions & 6 deletions WResp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "WResp.h"
#include "Web.h"
void JsonSockEvent::beginEvent(WebSocketsServer *server, const char *evt, char *buff, size_t buffSize) {
this->server = server;
this->buff = buff;
Expand Down Expand Up @@ -33,22 +34,22 @@ void JsonSockEvent::_safecat(const char *val, bool escape) {
else strcat(this->buff, val);
if(escape) strcat(this->buff, "\"");
}
void JsonResponse::beginResponse(WebServer *server, char *buff, size_t buffSize) {
void JsonResponse::beginResponse(WebRequestCompat *server, char *buff, size_t buffSize) {
this->server = server;
this->buff = buff;
this->buffSize = buffSize;
this->buff[0] = 0x00;
this->_nocomma = true;
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
this->_headersSent = false;
this->response = server->beginResponseStream("application/json");
}
void JsonResponse::endResponse() {
if(strlen(buff)) this->send();
server->sendContent("", 0);
server->send(this->response);
this->response = nullptr;
}
void JsonResponse::send() {
if(!this->_headersSent) server->send_P(200, "application/json", this->buff);
else server->sendContent(this->buff);
//Serial.printf("Sent %d bytes %d\n", strlen(this->buff), this->buffSize);
if(this->response != nullptr) this->response->print(this->buff);
this->buff[0] = 0x00;
this->_headersSent = true;
}
Expand Down
10 changes: 6 additions & 4 deletions WResp.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <WebServer.h>
#include <ESPAsyncWebServer.h>
#include <WebSocketsServer.h>
#include "Somfy.h"
#ifndef wresp_h
#define wresp_h

class WebRequestCompat;

class JsonFormatter {
protected:
char *buff;
Expand Down Expand Up @@ -56,8 +57,9 @@ class JsonResponse : public JsonFormatter {
protected:
void _safecat(const char *val, bool escape = false) override;
public:
WebServer *server;
void beginResponse(WebServer *server, char *buff, size_t buffSize);
WebRequestCompat *server;
AsyncResponseStream *response = nullptr;
void beginResponse(WebRequestCompat *server, char *buff, size_t buffSize);
void endResponse();
void send();
};
Expand Down
Loading