From d1f312236a3980119effe0f33c5bbeb1c1c62b7d Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 22 Apr 2026 08:18:14 +0100 Subject: [PATCH] Move SubeMX pack creation --- mongoose.h | 3 ++ resources/I-CUBE-Mongoose/App/mongoose_app.c | 35 +++++++++++++++++++ .../I-CUBE-Mongoose/App/mongoose_config.h | 6 ++++ .../Cesanta.I-CUBE-Mongoose.pdsc | 34 ++++++++++++++++++ resources/I-CUBE-Mongoose/Makefile | 25 +++++++++++++ resources/I-CUBE-Mongoose/Release_Notes.html | 5 +++ src/dash.h | 3 ++ 7 files changed, 111 insertions(+) create mode 100644 resources/I-CUBE-Mongoose/App/mongoose_app.c create mode 100644 resources/I-CUBE-Mongoose/App/mongoose_config.h create mode 100644 resources/I-CUBE-Mongoose/Cesanta.I-CUBE-Mongoose.pdsc create mode 100644 resources/I-CUBE-Mongoose/Makefile create mode 100644 resources/I-CUBE-Mongoose/Release_Notes.html diff --git a/mongoose.h b/mongoose.h index fb6ebb17..f6e80774 100644 --- a/mongoose.h +++ b/mongoose.h @@ -3411,6 +3411,9 @@ static inline void mg_dash_ev_handler(struct mg_connection *c, int ev, } } } + +extern void mongoose_init(void); +extern void mongoose_poll(void); // Copyright (c) 2023 Cesanta Software Limited // All rights reserved diff --git a/resources/I-CUBE-Mongoose/App/mongoose_app.c b/resources/I-CUBE-Mongoose/App/mongoose_app.c new file mode 100644 index 00000000..88154be7 --- /dev/null +++ b/resources/I-CUBE-Mongoose/App/mongoose_app.c @@ -0,0 +1,35 @@ +// 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); +} diff --git a/resources/I-CUBE-Mongoose/App/mongoose_config.h b/resources/I-CUBE-Mongoose/App/mongoose_config.h new file mode 100644 index 00000000..e94d746f --- /dev/null +++ b/resources/I-CUBE-Mongoose/App/mongoose_config.h @@ -0,0 +1,6 @@ +// Mongoose configuration file. For full list of build options, see +// https://mongoose.ws/docs/getting-started/build-options/ + +#pragma once + +#define MG_ARCH MG_ARCH_CUBE diff --git a/resources/I-CUBE-Mongoose/Cesanta.I-CUBE-Mongoose.pdsc b/resources/I-CUBE-Mongoose/Cesanta.I-CUBE-Mongoose.pdsc new file mode 100644 index 00000000..2c42ea75 --- /dev/null +++ b/resources/I-CUBE-Mongoose/Cesanta.I-CUBE-Mongoose.pdsc @@ -0,0 +1,34 @@ + + + Cesanta + I-CUBE-Mongoose + Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA + https://mongoose.ws/ + License.txt + https://mongoose.ws/contact/ + + See https://github.com/cesanta/mongoose/releases/tag/7.21 + See https://github.com/cesanta/mongoose/releases/tag/7.21 + See https://github.com/cesanta/mongoose/releases/tag/7.13 + + + CUBE_RULES_COMPLIANT + IMPLEMENTED_WITH_STM32CUBEMX + + + + Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA + + + + + Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA + + + + + + + + + diff --git a/resources/I-CUBE-Mongoose/Makefile b/resources/I-CUBE-Mongoose/Makefile new file mode 100644 index 00000000..c82e92d2 --- /dev/null +++ b/resources/I-CUBE-Mongoose/Makefile @@ -0,0 +1,25 @@ +VERSION = 7.21.1 +PACKPATH = Mongoose +FILES = $(PACKPATH) App Cesanta.I-CUBE-Mongoose.pdsc License.txt Release_Notes.html + +all: Cesanta.I-CUBE-Mongoose.$(VERSION).pack + +Cesanta.I-CUBE-Mongoose.$(VERSION).pack: $(FILES) $(PACKPATH)/mongoose.h $(PACKPATH)/mongoose.c + zip -r $@ $^ + +# Get packchk from https://github.com/Open-CMSIS-Pack/cmsis-toolbox +check: Cesanta.I-CUBE-Mongoose.$(VERSION).pack + grep $(VERSION) Cesanta.I-CUBE-Mongoose.pdsc || exit 1 + packchk Cesanta.I-CUBE-Mongoose.pdsc + +License.txt: + cp ../../LICENSE $@ +$(PACKPATH): + mkdir -p $(PACKPATH) +$(PACKPATH)/mongoose.h: $(PACKPATH) + cp ../../mongoose.h $@ +$(PACKPATH)/mongoose.c: $(PACKPATH) + cp ../../mongoose.c $@ + +clean: + rm -rf *.pack License.txt $(PACKPATH) diff --git a/resources/I-CUBE-Mongoose/Release_Notes.html b/resources/I-CUBE-Mongoose/Release_Notes.html new file mode 100644 index 00000000..f845da52 --- /dev/null +++ b/resources/I-CUBE-Mongoose/Release_Notes.html @@ -0,0 +1,5 @@ + + + + + diff --git a/src/dash.h b/src/dash.h index 3fdd4f4d..8871e586 100644 --- a/src/dash.h +++ b/src/dash.h @@ -266,3 +266,6 @@ static inline void mg_dash_ev_handler(struct mg_connection *c, int ev, } } } + +extern void mongoose_init(void); +extern void mongoose_poll(void);