Compare commits

...
9 Commits
Author SHA1 Message Date
robertc2000 c835c72202 Merge pull request #3774 from cesanta/rpc
Validate RPC buffer
2026-11-12 17:50:41 +02:00
robert 52ebac833f Validate RPC buffer 2026-11-12 17:46:04 +02:00
Sergio R. Caprile 5f1aaa21eb Merge pull request #3772 from cesanta/farewellsymlinks
Remove symlinks
2026-11-12 12:05:09 -03:00
Sergio R. Caprile 1c3a7a89dd Merge pull request #3773 from cesanta/ws
Remove unnecessary Websocket sent frame
2026-11-12 12:01:00 -03:00
robert d7a4130905 Remove unncessary Websocket sent frame 2026-11-12 16:43:51 +02:00
Sergio R. Caprile 5b0675584c Remove symlinks 2026-11-12 10:59:35 -03:00
Sergio R. Caprile 21b998c882 Merge pull request #3771 from cesanta/mg_match
Improve mg_match checks
2026-11-12 10:35:30 -03:00
robert 2cab36e882 Improve mg_match checks 2026-11-12 13:43:48 +02:00
Sergio R. Caprile 3a4f044e41 nitpicks 2026-11-11 17:51:49 -03:00
139 changed files with 366 additions and 180 deletions

No files matched your search

+2 -5
View File
@@ -1959,8 +1959,6 @@ void mg_dash_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
mg_http_reply(c, 200, MG_JSON_HEADERS, "hi\n");
} else if (mg_match(hm->uri, mg_str("/api/logout"), NULL)) {
mg_handle_logout(c);
mg_ws_printf(c, WEBSOCKET_OP_TEXT, "{%m:%m}", MG_ESC("method"),
MG_ESC("logout"));
} else if (mg_match(hm->uri, mg_str("/api/websocket"), NULL)) {
d->u = u;
mg_ws_upgrade(c, hm, NULL);
@@ -15355,7 +15353,7 @@ void mg_rpc_process(struct mg_rpc_req *r) {
mg_rpc_call(r, mg_str("")); // JSON response! call "" method handler
} else {
mg_rpc_err(r, -32700, "%m", mg_print_esc, (int) r->frame.len,
r->frame.buf); // Invalid
r->frame.len ? r->frame.buf : ""); // Invalid
}
}
@@ -17114,8 +17112,7 @@ bool mg_match(struct mg_str s, struct mg_str p, struct mg_str *caps) {
if (caps && !caps->buf) caps->len = 0, caps->buf = &s.buf[j]; // Init cap
ni = i++, nj = j + 1;
} else if (nj > 0 && nj <= s.len &&
((ni < p.len && p.buf[ni] == '#') ||
(j < s.len && s.buf[j] != '/'))) {
((ni < p.len && p.buf[ni] == '#') || s.buf[nj - 1] != '/')) {
i = ni, j = nj;
if (caps && caps->buf == NULL && caps->len == 0) {
caps--, caps->len = 0; // Restart previous cap
-2
View File
@@ -599,8 +599,6 @@ void mg_dash_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
mg_http_reply(c, 200, MG_JSON_HEADERS, "hi\n");
} else if (mg_match(hm->uri, mg_str("/api/logout"), NULL)) {
mg_handle_logout(c);
mg_ws_printf(c, WEBSOCKET_OP_TEXT, "{%m:%m}", MG_ESC("method"),
MG_ESC("logout"));
} else if (mg_match(hm->uri, mg_str("/api/websocket"), NULL)) {
d->u = u;
mg_ws_upgrade(c, hm, NULL);
+1 -1
View File
@@ -47,7 +47,7 @@ void mg_rpc_process(struct mg_rpc_req *r) {
mg_rpc_call(r, mg_str("")); // JSON response! call "" method handler
} else {
mg_rpc_err(r, -32700, "%m", mg_print_esc, (int) r->frame.len,
r->frame.buf); // Invalid
r->frame.len ? r->frame.buf : ""); // Invalid
}
}
+1 -2
View File
@@ -88,8 +88,7 @@ bool mg_match(struct mg_str s, struct mg_str p, struct mg_str *caps) {
if (caps && !caps->buf) caps->len = 0, caps->buf = &s.buf[j]; // Init cap
ni = i++, nj = j + 1;
} else if (nj > 0 && nj <= s.len &&
((ni < p.len && p.buf[ni] == '#') ||
(j < s.len && s.buf[j] != '/'))) {
((ni < p.len && p.buf[ni] == '#') || s.buf[nj - 1] != '/')) {
i = ni, j = nj;
if (caps && caps->buf == NULL && caps->len == 0) {
caps--, caps->len = 0; // Restart previous cap
+34 -5
View File
@@ -3,10 +3,39 @@
PROJECTS ?= seeeduino-xiao esp32
ROOT ?= $(realpath $(CURDIR)/../..)
ARD ?= $(realpath $(CURDIR))
MONGOOSE_C = $(ROOT)/tutorials/arduino/esp32-http/mongoose.c \
$(ROOT)/tutorials/arduino/esp32-mqtt/mongoose.c \
$(ROOT)/tutorials/arduino/nano-w5500-mqtt/mongoose.c \
$(ROOT)/tutorials/arduino/sim800-mqtt/mongoose.c \
$(ROOT)/tutorials/arduino/teensy41-http/mongoose.c \
$(ROOT)/tutorials/arduino/w5500-http/mongoose.c \
$(ROOT)/tutorials/arduino/w5500-mqtt/mongoose.c \
$(ROOT)/tutorials/nxp/teensy-4.1/arduino/mongoose.c
MONGOOSE_H = $(MONGOOSE_C:.c=.h)
TEENSY_FILES = $(ROOT)/tutorials/arduino/teensy41-http/net.c $(ROOT)/tutorials/arduino/teensy41-http/net.h $(ROOT)/tutorials/arduino/teensy41-http/packed_fs.c
all: $(PROJECTS)
echo
prepare: $(MONGOOSE_C) $(MONGOOSE_H) $(TEENSY_FILES)
.PHONY: prepare
$(MONGOOSE_C): $(ROOT)/mongoose.c
cp $< $@
$(MONGOOSE_H): $(ROOT)/mongoose.h
cp $< $@
$(ROOT)/tutorials/arduino/teensy41-http/net.c: $(ROOT)/tutorials/http/device-dashboard/net.c $(ROOT)/tutorials/arduino/teensy41-http/net.h
cp $< $@
$(ROOT)/tutorials/arduino/teensy41-http/net.h: $(ROOT)/tutorials/http/device-dashboard/net.h
cp $< $@
$(ROOT)/tutorials/arduino/teensy41-http/packed_fs.c: $(ROOT)/tutorials/http/device-dashboard/packed_fs.c
cp $< $@
arduino: ENV = -v $(CWD):/root
arduino:
curl -sL http://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz | unxz | tar -xf -
@@ -28,26 +57,26 @@ teensy-board:
./arduino/arduino --install-boards teensy:avr
touch teensy-board
seeeduino-xiao: arduino seeeduino-xiao-board
seeeduino-xiao: prepare arduino seeeduino-xiao-board
cd $(ROOT)/tutorials/arduino/sim800-mqtt && $(ARD)/arduino/arduino --verbose --verify --board Seeeduino:samd:seeed_XIAO_m0 sim800-mqtt.ino
cd $(ROOT)/tutorials/arduino/w5500-http && $(ARD)/arduino/arduino --verbose --verify --board Seeeduino:samd:seeed_XIAO_m0 w5500-http.ino
cd $(ROOT)/tutorials/arduino/w5500-mqtt && $(ARD)/arduino/arduino --verbose --verify --board Seeeduino:samd:seeed_XIAO_m0 w5500-mqtt.ino
arduino-nano: arduino
arduino-nano: prepare arduino
cd $(ROOT)/tutorials/arduino/nano-w5500-mqtt && $(ARD)/arduino/arduino --pref compiler.cpp.extra_flags=-DMG_ENABLE_LOG=0 --verbose --verify --board arduino:avr:nano nano-w5500-mqtt.ino
esp32: arduino esp32-board
esp32: prepare arduino esp32-board
cd $(ROOT)/tutorials/arduino/esp32-mqtt && $(ARD)/arduino/arduino --verbose --verify --board esp32:esp32:node32s esp32-mqtt.ino
# Needs a board with 'LED_BUILTIN', yet somehow invocation is missing that definition (lack of include somehow amended by the IDE)
#cd $(ROOT)/tutorials/arduino/esp32-http && $(ARD)/arduino/arduino --verbose --verify --board esp32:esp32:esp32 esp32-http.ino
teensy41: arduino teensy-board
teensy41: prepare arduino teensy-board
cd $(ROOT)/tutorials/arduino/teensy41-http && $(ARD)/arduino/arduino --verbose --verify --board teensy41-http.ino
clean:
rm -rf arduino
rm -rf arduino $(MONGOOSE_C) $(MONGOOSE_H) $(TEENSY_FILES)
# Board support gets installed in your home dir.
# We fool make satisfying a dependency using touch above, otherwise board installation fails as it is already installed
+53 -1
View File
@@ -72,6 +72,20 @@ static void test_match(void) {
ASSERT(mg_match(mg_str_n("caabxa", 6), mg_str_n("#aa#bb#", 7), NULL) == 0);
ASSERT(mg_match(mg_str_n("a__b_c", 6), mg_str_n("a*b*c", 5), NULL) == 1);
ASSERT(mg_match(mg_str("a/b/d/c"), mg_str("a/*/c"), NULL) == false);
ASSERT(mg_match(mg_str("a/b/c"), mg_str("a/*/c"), NULL) == true);
ASSERT(mg_match(mg_str("a/b/d/c"), mg_str("a/#/c"), NULL) == true);
{
struct mg_str caps[2];
ASSERT(mg_match(mg_str("a/b/d/c"), mg_str("a/*/c"), caps) == false);
ASSERT(mg_match(mg_str("a/b/c"), mg_str("a/*/c"), caps) == true);
ASSERT(mg_strcmp(caps[0], mg_str("b")) == 0);
ASSERT(mg_strcmp(caps[1], mg_str("")) == 0);
ASSERT(mg_match(mg_str("a/b/d/c"), mg_str("a/#/c"), caps) == true);
ASSERT(mg_strcmp(caps[0], mg_str("b/d")) == 0);
ASSERT(mg_strcmp(caps[1], mg_str("")) == 0);
}
{
char *ae_value = (char *) malloc(1); // Exact size for ASAN
ae_value[0] = 'g';
@@ -4975,6 +4989,7 @@ static void test_dash(void) {
const char *url = "http://localhost:26352";
const char *ws_url = "ws://localhost:26352/api/websocket";
struct mg_mgr mgr;
struct mg_connection *listener;
struct mg_dash dash;
struct dash_ws_test ws_admin, ws_user_notify;
bool two = false;
@@ -5103,7 +5118,44 @@ static void test_dash(void) {
MG_DASH_ADD_FIELD_SET(&dash, &arr_set);
mg_mgr_init(&mgr);
mg_mem_files = mg_packed_files;
ASSERT(mg_http_listen(&mgr, url, mg_dash_ev_handler, &dash) != NULL);
listener = mg_http_listen(&mgr, url, mg_dash_ev_handler, &dash);
ASSERT(listener != NULL);
// Unauthenticated logout must leave a valid stream for the next response
{
const char *request = "GET /api/logout HTTP/1.1\r\nHost: h\r\n\r\n"
"GET /api/hi HTTP/1.1\r\nHost: h\r\n\r\n";
struct mg_dash logout_dash;
struct mg_connection c;
struct mg_http_message hm;
size_t first_len;
long n;
memset(&logout_dash, 0, sizeof(logout_dash));
logout_dash.authenticate = dash_authenticate;
memset(&c, 0, sizeof(c));
c.mgr = &mgr;
c.fn = mg_dash_ev_handler;
c.fn_data = &logout_dash;
c.pfn = listener->pfn;
c.is_accepted = 1;
mg_call(&c, MG_EV_OPEN, NULL);
mg_iobuf_add(&c.recv, 0, request, strlen(request));
n = (long) c.recv.len;
mg_call(&c, MG_EV_READ, &n);
ASSERT(!c.is_websocket && !c.is_closing && !c.is_draining);
ASSERT(c.recv.len == 0);
ASSERT(mg_http_parse((char *) c.send.buf, c.send.len, &hm) > 0);
ASSERT(mg_http_status(&hm) == 401);
ASSERT(mg_strcmp(hm.body, mg_str("Unauthorized\n")) == 0);
first_len = hm.message.len;
ASSERT(mg_http_parse((char *) c.send.buf + first_len,
c.send.len - first_len, &hm) > 0);
ASSERT(mg_http_status(&hm) == 200);
ASSERT(mg_strcmp(hm.body, mg_str("hi\n")) == 0);
ASSERT(first_len + hm.message.len == c.send.len);
mg_iobuf_free(&c.recv);
mg_iobuf_free(&c.send);
}
// Test general get / set functionality
ASSERT(fetch(&mgr, buf, url, "GET /api/get HTTP/1.0\n\n") == 200);
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../http/device-dashboard/net.c
-1
View File
@@ -1 +0,0 @@
../../http/device-dashboard/net.h
@@ -1 +0,0 @@
../../http/device-dashboard/packed_fs.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
+3 -2
View File
@@ -1,8 +1,9 @@
PROG ?= example # Program we are building
DELETE = rm -rf # Command to remove files
OUT ?= -o $(PROG) # Compiler argument for output file
SOURCES = main.c mongoose.c packed_fs.c # Source code files
CFLAGS = -W -Wall -Wextra -g -I. # Build options
REPO_ROOT ?= ../../..
SOURCES = main.c $(REPO_ROOT)/mongoose.c packed_fs.c # Source code files
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -g -I. # Build options
PACK = ./pack # Utility to pack files into a packed filesystem
# Mongoose build options. See https://mongoose.ws/docs/getting-started/build-environment/
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
+3 -2
View File
@@ -1,5 +1,6 @@
SOURCES = main.c mongoose.c # Source code files
CFLAGS = -W -Wall -Wextra -g -I. # Build options
REPO_ROOT ?= ../../../..
SOURCES = main.c $(REPO_ROOT)/mongoose.c # Source code files
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -g -I. # Build options
# O(1) Heap
SOURCES += o1heap/o1heap/o1heap.c
-1
View File
@@ -1 +0,0 @@
../../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../../mongoose.h
+3 -2
View File
@@ -1,5 +1,6 @@
SOURCES = main.c mongoose.c # Source code files
CFLAGS = -W -Wall -Wextra -g -I. # Build options
REPO_ROOT ?= ../../..
SOURCES = main.c $(REPO_ROOT)/mongoose.c # Source code files
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -g -I. # Build options
# Mongoose build options. See https://mongoose.ws/docs/getting-started/build-environment/
CFLAGS_MONGOOSE +=
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
+3 -2
View File
@@ -1,5 +1,6 @@
SOURCES = main.c mongoose.c # Source code files
CFLAGS = -W -Wall -Wextra -g -I. # Build options
REPO_ROOT ?= ../../..
SOURCES = main.c $(REPO_ROOT)/mongoose.c # Source code files
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -g -I. # Build options
# Mongoose build options. See https://mongoose.ws/docs/getting-started/build-environment/
CFLAGS_MONGOOSE +=
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
+3 -2
View File
@@ -1,8 +1,9 @@
PROG ?= example # Program we are building
DELETE = rm -rf # Command to remove files
OUT ?= -o $(PROG) # Compiler argument for output file
SOURCES = main.c mongoose.c # Source code files
CFLAGS = -W -Wall -Wextra -g -I. # Build options
REPO_ROOT ?= ../../..
SOURCES = main.c $(REPO_ROOT)/mongoose.c # Source code files
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -g -I. # Build options
# Mongoose build options. See https://mongoose.ws/docs/getting-started/build-environment/
CFLAGS_MONGOOSE += -DMG_ENABLE_LINES
-1
View File
@@ -1 +0,0 @@
../../../mongoose.c
-1
View File
@@ -1 +0,0 @@
../../../mongoose.h
+11 -1
View File
@@ -9,9 +9,18 @@ all: example
example:
true
build: Makefile $(wildcard main/*)
build: Makefile $(wildcard main/*) main/net.c main/net.h main/packed_fs.c
$(DOCKER) $(CMD)
main/net.c: ../../http/device-dashboard/net.c main/net.h
cp $< $@
main/net.h: ../../http/device-dashboard/net.h
cp $< $@
main/packed_fs.c: ../../http/device-dashboard/packed_fs.c
cp $< $@
flash:
flash: CMD = idf.py flash
flash: DA = --device $(PORT)
@@ -36,3 +45,4 @@ flash3:
clean:
test -d build && $(DOCKER) rm -rf build sdkconfig || true
rm -f main/net.c main/net.h main/packed_fs.c
@@ -2,6 +2,8 @@ idf_component_register(SRCS "main.c"
"wifi.c"
"net.c"
"packed_fs.c"
"mongoose.c")
"../../../../mongoose.c"
INCLUDE_DIRS "."
"../../../..")
component_compile_options(-DHTTP_URL="http://0.0.0.0:80")
component_compile_options(-DHTTPS_URL="https://0.0.0.0:443")
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
@@ -1 +0,0 @@
../../../http/device-dashboard/net.c
@@ -1 +0,0 @@
../../../http/device-dashboard/net.h
@@ -1 +0,0 @@
../../../http/device-dashboard/packed_fs.c
+8 -2
View File
@@ -8,9 +8,15 @@ all: example
example:
true
build: Makefile $(wildcard main/*)
build: Makefile $(wildcard main/*) main/net.c main/packed_fs.c
docker run --rm $(DA) -v $(MNT):$(MNT) -w $(CWD) espressif/idf idf.py $(CMD)
main/net.c: ../../http/uart-bridge/net.c
cp $< $@
main/packed_fs.c: ../../http/uart-bridge/packed_fs.c
cp $< $@
flash:
flash: CMD = flash
flash: DA = --device $(PORT)
@@ -29,4 +35,4 @@ flash2: bridge.hex
esputil -p $(PORT) monitor
clean:
rm -rf build
rm -rf build main/net.c main/packed_fs.c
@@ -4,5 +4,7 @@ idf_component_register(SRCS "main.c"
"cli.c"
"net.c"
"packed_fs.c"
"mongoose.c")
"../../../../mongoose.c"
INCLUDE_DIRS "."
"../../../..")
component_compile_options(-DUART_API_IMPLEMENTED=1)
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
-1
View File
@@ -1 +0,0 @@
../../../http/uart-bridge/net.c
@@ -1 +0,0 @@
../../../http/uart-bridge/packed_fs.c
+2 -2
View File
@@ -29,8 +29,8 @@ web_root/bundle.js:
curl -s https://npm.reversehttp.com/preact,preact/hooks,htm/preact,preact-router -o $@
# Generate packed filesystem for serving Web UI
packed_fs.c: $(wildcard web_root/*) $(wildcard certs/*) Makefile web_root/bundle.js
node pack.js $(addsuffix ::gzip, $(wildcard web_root/*)) certs/* > $@
packed_fs.c: $(wildcard web_root/*) $(wildcard certs/*) Makefile ../../../test/pack.js web_root/bundle.js
node ../../../test/pack.js $(addsuffix ::gzip, $(wildcard web_root/*)) certs/* > $@
mbedtls:
git clone --depth 1 -b v2.28.2 https://github.com/mbed-tls/mbedtls $@
-1
View File
@@ -1 +0,0 @@
../../../test/pack.js
+6 -2
View File
@@ -24,8 +24,12 @@ endif
all: $(PROG) # Default target. Build and run program
$(RUN) ./$(PROG) $(ARGS)
$(PROG): $(SOURCES) # Build program from sources
$(PROG): $(SOURCES) certs/ca.pem # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
certs/ca.pem: ../../../test/data/ca.pem
mkdir -p certs
cp $< $@
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls $(PACK)
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls $(PACK) certs/ca.pem
-1
View File
@@ -1 +0,0 @@
../../../../test/data/ca.pem
+4 -1
View File
@@ -27,8 +27,11 @@ all: $(PROG) # Default target. Build and run program
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
packed_fs.c: ../http-client/packed_fs.c
cp $< $@
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls packed_fs.c
# see https://mongoose.ws/tutorials/tls/#how-to-build for TLS build options
@@ -1 +0,0 @@
../http-client/packed_fs.c
+4 -1
View File
@@ -24,8 +24,11 @@ all: $(PROG) # Default target. Build and run program
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
packed_fs.c: ../http-client/packed_fs.c
cp $< $@
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls packed_fs.c
# see https://mongoose.ws/tutorials/tls/#how-to-build for TLS build options
@@ -1 +0,0 @@
../http-client/packed_fs.c
+10 -2
View File
@@ -20,14 +20,22 @@ ifeq ($(OS),Windows_NT) # Windows settings. Assume MinGW compiler. To use VC:
OUT ?= -o $(PROG) # Build output
endif
all: $(PROG) # Default target. Build and run program
CERTS = certs/ca.crt certs/ca.key certs/ca.srl certs/client.crt certs/client.csr \
certs/client.key certs/generate.sh certs/server.crt certs/server.csr \
certs/server.key
all: $(CERTS) $(PROG) # Default target. Build and run program
$(RUN) ./$(PROG) $(ARGS)
certs/%: ../../../test/certs/%
mkdir -p certs
cp $< $@
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM certs/*
vc98: CC = cl
-1
View File
@@ -1 +0,0 @@
../../../test/certs
@@ -24,8 +24,11 @@ all: $(PROG) # Default target. Build and run program
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
packed_fs.c: ../http-client/packed_fs.c
cp $< $@
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls packed_fs.c
# see https://mongoose.ws/tutorials/tls/#how-to-build for TLS build options
@@ -1 +0,0 @@
../http-client/packed_fs.c
+14 -5
View File
@@ -20,14 +20,23 @@ endif
all: $(PROG) # Default target. Build and run program
$(RUN) $(PROG) $(ARGS)
web_root/bundle.js:
curl -s https://npm.reversehttp.com/preact,preact/hooks,htm/preact,preact-router -o $@
web_root/bundle.js: ../device-dashboard/web_root/bundle.js
cp $< $@
packed_fs.c: $(wildcard web_root/*) Makefile web_root/bundle.js
node pack.js $(addsuffix ::gzip, $(wildcard web_root/*)) > $@
web_root/components.js: ../device-dashboard/web_root/components.js
cp $< $@
web_root/history.min.js: ../device-dashboard/web_root/history.min.js
cp $< $@
web_root/index.html: ../device-dashboard/web_root/index.html
cp $< $@
packed_fs.c: $(wildcard web_root/*) Makefile ../../../test/pack.js web_root/bundle.js web_root/components.js web_root/history.min.js web_root/index.html
node ../../../test/pack.js $(addsuffix ::gzip, $(wildcard web_root/*)) > $@
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) $(PACK) *.o *.obj *.exe *.dSYM
$(DELETE) $(PROG) $(PACK) *.o *.obj *.exe *.dSYM web_root/bundle.js web_root/components.js web_root/history.min.js web_root/index.html
@@ -1 +0,0 @@
../../../test/pack.js
@@ -1 +0,0 @@
../../device-dashboard/web_root/bundle.js
@@ -1 +0,0 @@
../../device-dashboard/web_root/components.js
@@ -1 +0,0 @@
../../device-dashboard/web_root/history.min.js
@@ -1 +0,0 @@
../../device-dashboard/web_root/index.html
@@ -1,4 +1,5 @@
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
REPO_ROOT ?= ../../../..
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -fno-common -Wconversion
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include
@@ -9,7 +10,7 @@ LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--
SOURCES = main.c syscalls.c startup.c
# Mongoose-specific source code files and build options. See https://mongoose.ws/docs/getting-started/build-environment/
SOURCES += mongoose.c net.c packed_fs.c
SOURCES += $(REPO_ROOT)/mongoose.c net.c packed_fs.c
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_ARMGCC -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_LINES=1
CFLAGS += -DMG_ENABLE_DRIVER_SAME54=1 -DMG_ENABLE_CUSTOM_RANDOM=1 $(CFLAGS_EXTRA)
@@ -39,6 +40,15 @@ cmsis_sam:
curl -sL https://packs.download.microchip.com/Microchip.SAME54_DFP.3.9.244.atpack -o $@.zip
mkdir $@ && cd $@ && unzip ../$@.zip
net.c: ../../../http/device-dashboard/net.c net.h
cp $< $@
net.h: ../../../http/device-dashboard/net.h
cp $< $@
packed_fs.c: ../../../http/device-dashboard/packed_fs.c
cp $< $@
# Automated test via https://vcon.io/automated-firmware-tests/. Set VCON_API_KEY and update DEVICE_URL
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/9
update: firmware.bin
@@ -50,4 +60,4 @@ test: update
grep 'READY, IP:' /tmp/output.txt # Check for network init
clean:
$(RM) firmware.* cmsis_core cmsis_sam *.zip
$(RM) firmware.* cmsis_core cmsis_sam *.zip net.c net.h packed_fs.c
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
@@ -1 +0,0 @@
../../../http/device-dashboard/net.c
@@ -1 +0,0 @@
../../../http/device-dashboard/net.h
@@ -1 +0,0 @@
../../../http/device-dashboard/packed_fs.c
@@ -1,4 +1,5 @@
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
REPO_ROOT ?= ../../../..
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -fno-common -Wconversion
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include
@@ -9,7 +10,7 @@ LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--
SOURCES = main.c syscalls.c startup.c
# Mongoose-specific source code files and build options. See https://mongoose.ws/docs/getting-started/build-environment/
SOURCES += mongoose.c
SOURCES += $(REPO_ROOT)/mongoose.c
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_ARMGCC -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_LINES=1
CFLAGS += -DMG_ENABLE_DRIVER_SAME54=1 -DMG_ENABLE_CUSTOM_RANDOM=1 $(CFLAGS_EXTRA)
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
+1 -1
View File
@@ -4,7 +4,7 @@ ROOTDIR = $(realpath $(CURDIR)/../../..)
PORT ?= /dev/ttyUSB0
DOCKER ?= docker run --rm $(DA) -v $(ROOTDIR):$(ROOTDIR) -w $(THISDIR) espressif/idf:v5.0.4
# Note that the esp32 port needs the extra .. for relative paths due to the location of its main CMakeLists.txt file
CMD ?= bash -c '$(MAKE) -C micropython/ports/esp32 submodules && $(MAKE) -C micropython/ports/esp32 USER_C_MODULES=../../../../mongoose/micropython.cmake'
CMD ?= bash -c '$(MAKE) -C micropython/ports/esp32 submodules && $(MAKE) -C micropython/ports/esp32 USER_C_MODULES=../../../../../mongoose/micropython.cmake'
all: example
@@ -1 +0,0 @@
../../mongoose/micropython.cmake
@@ -1 +0,0 @@
../../mongoose/micropython.mk
@@ -1 +0,0 @@
../../mongoose/module.c
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
@@ -4,13 +4,14 @@ add_library(usermod_mongoose INTERFACE)
# Add our source files to the lib
target_sources(usermod_mongoose INTERFACE
${CMAKE_CURRENT_LIST_DIR}/module.c
${CMAKE_CURRENT_LIST_DIR}/mongoose.c
${CMAKE_CURRENT_LIST_DIR}/../../../mongoose.c
${CMAKE_CURRENT_LIST_DIR}/main.c
)
# Add the current directory as an include directory.
target_include_directories(usermod_mongoose INTERFACE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/../../..
)
# Link our INTERFACE library to the usermod target.
@@ -2,8 +2,8 @@ CEXAMPLE_MOD_DIR := $(USERMOD_DIR)
# Add all C files to SRC_USERMOD.
SRC_USERMOD += $(CEXAMPLE_MOD_DIR)/module.c
SRC_USERMOD += $(CEXAMPLE_MOD_DIR)/mongoose.c
SRC_USERMOD += $(CEXAMPLE_MOD_DIR)/../../../mongoose.c
SRC_USERMOD += $(CEXAMPLE_MOD_DIR)/main.c
# add our module folder to include paths
CFLAGS_USERMOD += -I$(CEXAMPLE_MOD_DIR)
CFLAGS_USERMOD += -I$(CEXAMPLE_MOD_DIR) -I$(CEXAMPLE_MOD_DIR)/../../..
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
+4 -1
View File
@@ -24,8 +24,11 @@ all: $(PROG) # Default target. Build and run program
$(PROG): $(SOURCES) # Build program from sources
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
packed_fs.c: ../../http/http-client/packed_fs.c
cp $< $@
clean: # Cleanup. Delete built program and all build artifacts
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM mbedtls packed_fs.c
# see https://mongoose.ws/tutorials/tls/#how-to-build for TLS build options
@@ -1 +0,0 @@
../../http/http-client/packed_fs.c
@@ -1 +0,0 @@
../../../../mongoose.c
@@ -1 +0,0 @@
../../../../mongoose.h
@@ -1,4 +1,5 @@
CFLAGS = -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion
REPO_ROOT ?= ../../..
CFLAGS = -I$(REPO_ROOT) -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -fno-common -Wconversion -Wno-sign-conversion
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include
@@ -7,7 +8,7 @@ CFLAGS += -Icmsis_mcu/ra/fsp/src/bsp/mcu/all
CFLAGS += -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard $(CFLAGS_EXTRA)
LDFLAGS ?= -Tlink.ld -nostdlib -nostartfiles --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
SOURCES = main.c hal.c mongoose.c net.c packed_fs.c
SOURCES = main.c hal.c $(REPO_ROOT)/mongoose.c net.c packed_fs.c
# CMSIS startup and system files are deeply tied to the BSP, and we don't use it. See hal.c
# Example specific build options. See README.md
@@ -37,6 +38,15 @@ cmsis_core: # ARM CMSIS core headers
cmsis_mcu:
git clone -q --depth 1 -b v5.1.0 https://github.com/renesas/fsp $@
net.c: ../../http/device-dashboard/net.c net.h
cp $< $@
net.h: ../../http/device-dashboard/net.h
cp $< $@
packed_fs.c: ../../http/device-dashboard/packed_fs.c
cp $< $@
# Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/14
@@ -50,4 +60,4 @@ test: update
grep 'READY, IP:' /tmp/output.txt # Check for network init
clean:
$(RM) firmware.* *.su cmsis_core cmsis_mcu mbedtls *.zip
$(RM) firmware.* *.su cmsis_core cmsis_mcu mbedtls *.zip net.c net.h packed_fs.c
@@ -1 +0,0 @@
../../../mongoose.c
@@ -1 +0,0 @@
../../../mongoose.h
@@ -1 +0,0 @@
../../http/device-dashboard/net.c
@@ -1 +0,0 @@
../../http/device-dashboard/net.h
@@ -1 +0,0 @@
../../http/device-dashboard/packed_fs.c
+8 -2
View File
@@ -8,13 +8,19 @@ endif
all example:
true
build build/firmware.uf2: pico-sdk main.c net.c
build build/firmware.uf2: pico-sdk main.c net.c net.h
$(MKBUILD)
cd build && cmake -G "Unix Makefiles" .. && make
net.c: ../../mqtt/mqtt-dashboard/device/net.c net.h
cp $< $@
net.h: ../../mqtt/mqtt-dashboard/device/net.h
cp $< $@
pico-sdk:
git clone --depth 1 -b 2.1.0 https://github.com/raspberrypi/pico-sdk $@
cd $@ && git submodule update --init
clean:
$(RM) pico-sdk build
$(RM) pico-sdk build net.c net.h
-1
View File
@@ -1 +0,0 @@
../../mqtt/mqtt-dashboard/device/net.c
Loaded 100 of 139 files, more files were not shown because too many files have changed in this diff. Show more