mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-06 15:51:25 +00:00
Add MQTT module to STM32 pack
This commit is contained in:
1 parent
4a5d2f04b3
commit
3eb38aeb4f
8 files changed
+182
-133
No files matched your search
@@ -2,12 +2,13 @@
|
||||
<package schemaVersion="1.7.40" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
|
||||
<vendor>Cesanta</vendor>
|
||||
<name>I-CUBE-Mongoose</name>
|
||||
<description>Mongoose - TCP/IP stack + TLS + HTTP + WebSocket + MQTT + Firmware OTA</description>
|
||||
<url>https://mongoose.ws/</url>
|
||||
<description>Mongoose - a lightweight networking library providing TCP/IP stack, TLS, HTTP (Embedded Web Server), WebSocket, MQTT, and Firmware OTA updates. Build production-ready web device dashboards and MQTT cloud connectivity without stitching multiple components together.
|
||||
</description>
|
||||
<url>https://mongoose.ws/downloads/stm32pack/</url>
|
||||
<license>License.txt</license>
|
||||
<supportContact>https://mongoose.ws/contact/</supportContact>
|
||||
<releases>
|
||||
<release date="2026-04-22" version="7.21.3">See https://github.com/cesanta/mongoose/releases/tag/7.21</release>
|
||||
<release date="2026-04-24" version="7.21.4">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>
|
||||
</releases>
|
||||
@@ -21,7 +22,7 @@
|
||||
</condition>
|
||||
</conditions>
|
||||
<components>
|
||||
<component Cclass="Mongoose" Cgroup="Networking Core" Cversion="7.21.3" maxInstances="1">
|
||||
<component Cclass="Mongoose" Cgroup="Networking Core" Cversion="7.21.4" maxInstances="1">
|
||||
<description>Networking Core</description>
|
||||
<files>
|
||||
<file category="header" name="mongoose.h" />
|
||||
@@ -29,12 +30,18 @@
|
||||
<file category="header" name="mongoose_config.h"/>
|
||||
</files>
|
||||
</component>
|
||||
<component Cclass="Mongoose" Cgroup="Web Device Dashboard" Cversion="7.21.3" condition="MongooseCore" maxInstances="1">
|
||||
<component Cclass="Mongoose" Cgroup="Web Device Dashboard" Cversion="7.21.4" condition="MongooseCore" maxInstances="1">
|
||||
<description>Web Device Dashboard</description>
|
||||
<files>
|
||||
<file category="sourceC" name="mongoose_dashboard.c"/>
|
||||
<file category="sourceC" name="dashboard.html.c"/>
|
||||
</files>
|
||||
</component>
|
||||
<component Cclass="Mongoose" Cgroup="MQTT Client" Cversion="7.21.4" condition="MongooseCore" maxInstances="1">
|
||||
<description>MQTT Client</description>
|
||||
<files>
|
||||
<file category="sourceC" name="mongoose_mqtt.c"/>
|
||||
</files>
|
||||
</component>
|
||||
</components>
|
||||
</package>
|
||||
@@ -1,11 +1,10 @@
|
||||
VERSION = 7.21.3
|
||||
VERSION = 7.21.4
|
||||
REPO_ROOT = ../..
|
||||
FILES = Cesanta.I-CUBE-Mongoose.pdsc Release_Notes.html mongoose_config.h README.md
|
||||
GENERATED = License.txt \
|
||||
mongoose.h mongoose.c \
|
||||
mongoose_dashboard.c dashboard.html.c
|
||||
# STM32CubeMX/Cesanta.I-CUBE-Mongoose.$(VERSION)_Configs.xml \
|
||||
# STM32CubeMX/Cesanta.I-CUBE-Mongoose.$(VERSION)_Modes.xml
|
||||
mongoose_dashboard.c dashboard.html.c \
|
||||
mongoose_mqtt.c dashboard.html.c
|
||||
|
||||
all: Cesanta.I-CUBE-Mongoose.$(VERSION).pack
|
||||
|
||||
@@ -27,6 +26,9 @@ Mongoose:
|
||||
mongoose_dashboard.c:
|
||||
cp $(REPO_ROOT)/tutorials/device-dashboard/mongoose_dashboard.c $@
|
||||
|
||||
mongoose_mqtt.c:
|
||||
cp $(REPO_ROOT)/tutorials/mqtt/mqtt-client/mongoose_mqtt.c $@
|
||||
|
||||
dashboard.html.c:
|
||||
make -C $(REPO_ROOT)/tutorials/device-dashboard dashboard.html.c
|
||||
cp $(REPO_ROOT)/tutorials/device-dashboard/dashboard.html.c $@
|
||||
@@ -37,11 +39,5 @@ mongoose.h: Mongoose
|
||||
mongoose.c: Mongoose
|
||||
cp $(REPO_ROOT)/mongoose.c $@
|
||||
|
||||
STM32CubeMX/Cesanta.I-CUBE-Mongoose.${VERSION}_Modes.xml: STM32CubeMX/m.xml
|
||||
sed s,__VERSION__,$(VERSION),g $^ > $@
|
||||
|
||||
STM32CubeMX/Cesanta.I-CUBE-Mongoose.${VERSION}_Configs.xml: STM32CubeMX/c.xml
|
||||
sed s,__VERSION__,$(VERSION),g $^ > $@
|
||||
|
||||
clean:
|
||||
rm -rf *.pack STM32CubeMX/*.$(VERSION)_*.xml $(GENERATED)
|
||||
@@ -101,6 +101,8 @@ Hi from Mongoose! Tick 38187
|
||||
|
||||
## Add full device dashboard
|
||||
|
||||
Enable "Mongoose Web Device Dashboard" component in CubeMX. Regenerate code.
|
||||
|
||||
Remove the hello world server if you added it. Modify your while loop
|
||||
to look like this:
|
||||
|
||||
@@ -119,3 +121,27 @@ while (1)
|
||||
|
||||
Rebuild, reflash your board and enjoy the fully functional device dashboard
|
||||
that you can tailor to your firmware.
|
||||
|
||||
## Add MQTT Client
|
||||
|
||||
Enable "Mongoose MQTT Client" component in CubeMX. Regenerate code.
|
||||
|
||||
Add MQTT init and poll to your while loop:
|
||||
|
||||
```c
|
||||
/* USER CODE BEGIN WHILE */
|
||||
struct mg_mgr mgr;
|
||||
mg_mgr_init(&mgr);
|
||||
mg_mqtt_init(&mgr);
|
||||
|
||||
while (1)
|
||||
{
|
||||
mg_mgr_poll(&mgr, 1);
|
||||
mg_mqtt_poll(&mgr);
|
||||
/* USER CODE END WHILE */
|
||||
```
|
||||
|
||||
Rebuild, reflash your board. This MQTT Client connects to the
|
||||
HiveMQ public MQTT broker - see `mongoose_mqtt.c` file for details.
|
||||
Also it add a JSON-RPC "ota.update" function via MQTT, so you can
|
||||
update your firmware over MQTT, see https://mongoose.ws/mqtt/
|
||||
Reference in new issue
Block a user