Shipping dashboard in the pack

This commit is contained in:
cpq
2026-04-22 17:22:13 +01:00
parent d1f312236a
commit d1848c0ae3
3 changed files with 22 additions and 51 deletions
@@ -1,35 +0,0 @@
// SPDX-FileCopyrightText: 2026 Cesanta Software Limited
// SPDX-License-Identifier: GPL-2.0-only or commercial
//
// See guides:
// https://mongoose.ws/docs/guides/web-dashboard-guide/ - device dashboard
#include "mongoose.h"
#if MG_ARCH == MG_ARCH_UNIX || MG_ARCH == MG_ARCH_WIN32
#define HTTP_ADDR "http://0.0.0.0:8000"
#else
#define HTTP_ADDR "http://0.0.0.0:80"
#endif
static struct mg_mgr s_mgr;
// Connection event handler function
static void http_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_HTTP_MSG) { // New HTTP request received
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_match(hm->uri, mg_str("/api/hello"), NULL)) {
mg_http_reply(c, 200, "", "{%m:%d}\n", MG_ESC("status"), 1);
} else {
mg_http_reply(c, 200, "", "Hello from Mongoose %s\n", MG_VERSION);
}
}
}
void mongoose_init(void) {
mg_mgr_init(&s_mgr);
mg_http_listen(&s_mgr, HTTP_ADDR, http_ev_handler, NULL);
}
void mongoose_poll(void) {
mg_mgr_poll(&s_mgr, 1);
}
@@ -7,7 +7,7 @@
<license>License.txt</license> <license>License.txt</license>
<supportContact>https://mongoose.ws/contact/</supportContact> <supportContact>https://mongoose.ws/contact/</supportContact>
<releases> <releases>
<release date="2026-04-22" version="7.21.1">See https://github.com/cesanta/mongoose/releases/tag/7.21</release> <release date="2026-04-22" version="7.21.2">See https://github.com/cesanta/mongoose/releases/tag/7.21</release>
<release date="2026-04-08" version="7.21.0">See https://github.com/cesanta/mongoose/releases/tag/7.21</release> <release date="2026-04-08" version="7.21.0">See https://github.com/cesanta/mongoose/releases/tag/7.21</release>
<release date="2024-03-01" version="7.13.0">See https://github.com/cesanta/mongoose/releases/tag/7.13</release> <release date="2024-03-01" version="7.13.0">See https://github.com/cesanta/mongoose/releases/tag/7.13</release>
</releases> </releases>
@@ -21,13 +21,14 @@
</description> </description>
</taxonomy> </taxonomy>
<components> <components>
<component Cclass="Network" Cgroup="Mongoose" Cversion="7.21.1" maxInstances="1"> <component Cclass="Network" Cgroup="Mongoose" Cversion="7.21.2" maxInstances="1">
<description>Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA</description> <description>Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA</description>
<files> <files>
<file category="header" name="Mongoose/mongoose.h" /> <file category="header" name="Mongoose/mongoose.h" />
<file category="sourceC" name="Mongoose/mongoose.c" /> <file category="sourceC" name="Mongoose/mongoose.c" />
<file category="sourceC" name="App/mongoose_app.c" attr="config" version="7.21.1" /> <file category="sourceC" name="App/mongoose_app.c" attr="config" version="7.21.2" />
<file category="header" name="App/mongoose_config.h" attr="config" version="7.21.1" /> <file category="sourceC" name="App/dashboard.html.c" attr="config" version="7.21.2" />
<file category="header" name="App/mongoose_config.h" attr="config" version="7.21.2" />
</files> </files>
</component> </component>
</components> </components>
+17 -12
View File
@@ -1,10 +1,10 @@
VERSION = 7.21.1 VERSION = 7.21.2
PACKPATH = Mongoose REPO_ROOT = ../..
FILES = $(PACKPATH) App Cesanta.I-CUBE-Mongoose.pdsc License.txt Release_Notes.html FILES = Mongoose App Cesanta.I-CUBE-Mongoose.pdsc License.txt Release_Notes.html
all: Cesanta.I-CUBE-Mongoose.$(VERSION).pack all: Cesanta.I-CUBE-Mongoose.$(VERSION).pack
Cesanta.I-CUBE-Mongoose.$(VERSION).pack: $(FILES) $(PACKPATH)/mongoose.h $(PACKPATH)/mongoose.c Cesanta.I-CUBE-Mongoose.$(VERSION).pack: $(FILES) Mongoose/mongoose.h Mongoose/mongoose.c App/mongoose_app.c App/dashboard.html.c
zip -r $@ $^ zip -r $@ $^
# Get packchk from https://github.com/Open-CMSIS-Pack/cmsis-toolbox # Get packchk from https://github.com/Open-CMSIS-Pack/cmsis-toolbox
@@ -13,13 +13,18 @@ check: Cesanta.I-CUBE-Mongoose.$(VERSION).pack
packchk Cesanta.I-CUBE-Mongoose.pdsc packchk Cesanta.I-CUBE-Mongoose.pdsc
License.txt: License.txt:
cp ../../LICENSE $@ cp $(REPO_ROOT)/LICENSE $@
$(PACKPATH): Mongoose:
mkdir -p $(PACKPATH) mkdir -p Mongoose
$(PACKPATH)/mongoose.h: $(PACKPATH) App/mongoose_app.c:
cp ../../mongoose.h $@ cp $(REPO_ROOT)/tutorials/device-dashboard/mongoose_app.c $@
$(PACKPATH)/mongoose.c: $(PACKPATH) App/dashboard.html.c:
cp ../../mongoose.c $@ make -C $(REPO_ROOT)/tutorials/device-dashboard dashboard.html.c
cp $(REPO_ROOT)/tutorials/device-dashboard/dashboard.html.c $@
Mongoose/mongoose.h: Mongoose
cp $(REPO_ROOT)/mongoose.h $@
Mongoose/mongoose.c: Mongoose
cp $(REPO_ROOT)/mongoose.c $@
clean: clean:
rm -rf *.pack License.txt $(PACKPATH) rm -rf *.pack License.txt Mongoose App/*.{html,js,c}