Skip to content

Commit

Permalink
wip# Please enter the commit message for your changes. Lines starting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed May 28, 2024
1 parent 2834356 commit fdd7ad0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/gridui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ static void defaultOnPacketReceived(const std::string& cmd, rbjson::Object* pkt)
// ignore the rest
}

#ifdef RBGRIDUI_USING_ESP_IDF

extern const uint8_t index_html_start[] asm("_binary_index_html_gz_start");
extern const uint8_t index_html_end[] asm("_binary_index_html_gz_end");

extern const uint8_t combined_js_start[] asm("_binary_combined_js_gz_start");
extern const uint8_t combined_js_end[] asm("_binary_combined_js_gz_end");

not_found_response_t webserverNotFoundCallback(const char *request_path) {
not_found_response_t resp = {};
if(strcmp(request_path, "/") == 0 || strcmp(request_path, "/index.html") == 0) {
resp.data = (uint8_t*)index_html_start;
resp.size = index_html_end - index_html_start;
resp.is_gzipped = 1;
} else if(strcmp(request_path, "/combined.js") == 0) {
resp.data = (uint8_t*)combined_js_start;
resp.size = combined_js_end - combined_js_start;
resp.is_gzipped = 1;
}
return resp;
}
#else
not_found_response_t webserverNotFoundCallback(const char *request_path) {
not_found_response_t resp = {};
return resp;
}
#endif

_GridUi::_GridUi()
: m_protocol(nullptr)
, m_protocol_ours(false)
Expand Down Expand Up @@ -55,6 +83,10 @@ rb::Protocol* _GridUi::begin(const char* owner, const char* deviceName) {
return nullptr;
}

#ifdef RBGRIDUI_USING_ESP_IDF
rb_web_set_not_found_callback(webserverNotFoundCallback);
#endif

auto protocol = new rb::Protocol(owner, deviceName, "Compiled at " __DATE__ " " __TIME__, defaultOnPacketReceived);
protocol->start();

Expand Down
4 changes: 4 additions & 0 deletions src/gridui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "esp_timer.h"

#include "rbwebserver.h"

#include "builder/arm.h"
#include "builder/bar.h"
#include "builder/button.h"
Expand All @@ -35,6 +37,8 @@ namespace gridui {

class WidgetState;

not_found_response_t webserverNotFoundCallback(const char *request_path);

class _GridUi {
friend class WidgetState;

Expand Down

0 comments on commit fdd7ad0

Please sign in to comment.