From c11e5a9383ebe39a12cf38c1165f9df913b30c5d Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Tue, 12 Oct 2021 18:26:20 -0600 Subject: [PATCH 1/8] Make private functions static and add missing prototypes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: mongoose/mongoose.c:180:8: warning: no previous prototype for ‘mg_dns_parse_name’ [-Wmissing-prototypes] 180 | size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst, | ^~~~~~~~~~~~~~~~~ mongoose/mongoose.c:306:6: warning: no previous prototype for ‘mg_dns_send’ [-Wmissing-prototypes] 306 | void mg_dns_send(struct mg_connection *c, const struct mg_str *name, | ^~~~~~~~~~~ mongoose/mongoose.c:925:6: warning: no previous prototype for ‘mg_http_parse_headers’ [-Wmissing-prototypes] 925 | void mg_http_parse_headers(const char *s, const char *end, | ^~~~~~~~~~~~~~~~~~~~~ mongoose/mongoose.c:1125:7: warning: no previous prototype for ‘mg_http_etag’ [-Wmissing-prototypes] 1125 | char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) { | ^~~~~~~~~~~~ mongoose/mongoose.c:2578:6: warning: no previous prototype for ‘mg_sha1_transform’ [-Wmissing-prototypes] 2578 | void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { | ^~~~~~~~~~~~~~~~~ mongoose/mongoose.c:2976:8: warning: no previous prototype for ‘mg_open_listener’ [-Wmissing-prototypes] 2976 | SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { | ^~~~~~~~~~~~~~~~ Signed-off-by: James Hilliard --- Makefile | 2 +- mongoose.c | 11 ++++++----- src/base64.c | 1 + src/dns.c | 4 ++-- src/http.c | 3 ++- src/sha1.c | 2 +- src/sock.c | 2 +- test/mongoose_custom.c | 2 ++ test/pack.c | 2 ++ 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index b17030e5..fee95c02 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SRCS = mongoose.c test/unit_test.c test/packed_fs.c HDRS = $(wildcard src/*.h) DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1 -WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion +WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wmissing-prototypes OPTS ?= -O3 -g3 INCS ?= -Isrc -I. CFLAGS ?= $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) $(EXTRA) diff --git a/mongoose.c b/mongoose.c index 9411a8a9..5952647c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -177,7 +177,7 @@ static size_t mg_dns_parse_name_depth(const uint8_t *s, size_t len, size_t ofs, return i; } -size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst, +static size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst, size_t dstlen) { return mg_dns_parse_name_depth(s, n, ofs, dst, dstlen, 0); } @@ -303,7 +303,7 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, (void) fn_data; } -void mg_dns_send(struct mg_connection *c, const struct mg_str *name, +static void mg_dns_send(struct mg_connection *c, const struct mg_str *name, uint16_t txnid, bool ipv6) { struct { struct mg_dns_header header; @@ -922,7 +922,7 @@ struct mg_str *mg_http_get_header(struct mg_http_message *h, const char *name) { return NULL; } -void mg_http_parse_headers(const char *s, const char *end, +static void mg_http_parse_headers(const char *s, const char *end, struct mg_http_header *h, int max_headers) { int i; for (i = 0; i < max_headers; i++) { @@ -1122,6 +1122,7 @@ static void restore_http_cb(struct mg_connection *c) { c->pfn = http_cb; } +char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime); char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) { snprintf(buf, len, "\"%lx." MG_INT64_FMT "\"", (unsigned long) mtime, (int64_t) size); @@ -2575,7 +2576,7 @@ static uint32_t blk0(union char64long16 *block, int i) { z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \ w = rol(w, 30); -void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { +static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { uint32_t a, b, c, d, e; union char64long16 block[1]; @@ -2973,7 +2974,7 @@ static void mg_set_non_blocking_mode(SOCKET fd) { #endif } -SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { +static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { SOCKET fd = INVALID_SOCKET; int s_err = 0; // Memoized socket error, in case closesocket() overrides it memset(addr, 0, sizeof(*addr)); diff --git a/src/base64.c b/src/base64.c index 5989f67b..605851e6 100644 --- a/src/base64.c +++ b/src/base64.c @@ -1,3 +1,4 @@ +#include "base64.h" #include static int mg_b64idx(int c) { diff --git a/src/dns.c b/src/dns.c index 6318c537..7f3575a7 100644 --- a/src/dns.c +++ b/src/dns.c @@ -63,7 +63,7 @@ static size_t mg_dns_parse_name_depth(const uint8_t *s, size_t len, size_t ofs, return i; } -size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst, +static size_t mg_dns_parse_name(const uint8_t *s, size_t n, size_t ofs, char *dst, size_t dstlen) { return mg_dns_parse_name_depth(s, n, ofs, dst, dstlen, 0); } @@ -189,7 +189,7 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, (void) fn_data; } -void mg_dns_send(struct mg_connection *c, const struct mg_str *name, +static void mg_dns_send(struct mg_connection *c, const struct mg_str *name, uint16_t txnid, bool ipv6) { struct { struct mg_dns_header header; diff --git a/src/http.c b/src/http.c index 2727d634..8d2b5526 100644 --- a/src/http.c +++ b/src/http.c @@ -172,7 +172,7 @@ struct mg_str *mg_http_get_header(struct mg_http_message *h, const char *name) { return NULL; } -void mg_http_parse_headers(const char *s, const char *end, +static void mg_http_parse_headers(const char *s, const char *end, struct mg_http_header *h, int max_headers) { int i; for (i = 0; i < max_headers; i++) { @@ -372,6 +372,7 @@ static void restore_http_cb(struct mg_connection *c) { c->pfn = http_cb; } +char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime); char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) { snprintf(buf, len, "\"%lx." MG_INT64_FMT "\"", (unsigned long) mtime, (int64_t) size); diff --git a/src/sha1.c b/src/sha1.c index d4b4655d..2719c10d 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -62,7 +62,7 @@ static uint32_t blk0(union char64long16 *block, int i) { z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \ w = rol(w, 30); -void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { +static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { uint32_t a, b, c, d, e; union char64long16 block[1]; diff --git a/src/sock.c b/src/sock.c index c59f5167..6625c77e 100644 --- a/src/sock.c +++ b/src/sock.c @@ -127,7 +127,7 @@ static void mg_set_non_blocking_mode(SOCKET fd) { #endif } -SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { +static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { SOCKET fd = INVALID_SOCKET; int s_err = 0; // Memoized socket error, in case closesocket() overrides it memset(addr, 0, sizeof(*addr)); diff --git a/test/mongoose_custom.c b/test/mongoose_custom.c index 3d882d7f..fa4de347 100644 --- a/test/mongoose_custom.c +++ b/test/mongoose_custom.c @@ -23,6 +23,7 @@ struct mg_connection *mg_connect(struct mg_mgr *mgr, const char *url, return NULL; } +void mg_connect_resolved(struct mg_connection *c); void mg_connect_resolved(struct mg_connection *c) { (void) c; } @@ -52,5 +53,6 @@ struct mg_connection *mg_mkpipe(struct mg_mgr *mgr, mg_event_handler_t fn, return NULL; } +void _fini(void); void _fini(void) { } diff --git a/test/pack.c b/test/pack.c index 183de982..a296a13f 100644 --- a/test/pack.c +++ b/test/pack.c @@ -23,9 +23,11 @@ #include static const char *code = + "const char *mg_unlist(size_t no);\n" "const char *mg_unlist(size_t no) {\n" " return packed_files[no].name;\n" "}\n" + "const char *mg_unpack(const char *name, size_t *size, time_t *mtime);\n" "const char *mg_unpack(const char *name, size_t *size, time_t *mtime) {\n" " const struct packed_file *p;\n" " for (p = packed_files; p->name != NULL; p++) {\n" From c62c8ea4ddc209417c151a68ef783a5103fbe6cb Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Wed, 20 Oct 2021 10:04:49 +0100 Subject: [PATCH 2/8] Correct licensing URL --- mongoose.c | 4 ++-- mongoose.h | 4 ++-- src/license.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mongoose.c b/mongoose.c index 9411a8a9..9abcf9fb 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5,7 +5,7 @@ // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. For the terms of this -// license, see . +// license, see http://www.gnu.org/licenses/ // // You are free to use this software under the terms of the GNU General // Public License, but WITHOUT ANY WARRANTY; without even the implied @@ -13,7 +13,7 @@ // See the GNU General Public License for more details. // // Alternatively, you can license this software under a commercial -// license, as set out in . +// license, as set out in https://www.mongoose.ws/licensing/ #include "mongoose.h" diff --git a/mongoose.h b/mongoose.h index a1d00646..c3be53d3 100644 --- a/mongoose.h +++ b/mongoose.h @@ -5,7 +5,7 @@ // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. For the terms of this -// license, see . +// license, see http://www.gnu.org/licenses/ // // You are free to use this software under the terms of the GNU General // Public License, but WITHOUT ANY WARRANTY; without even the implied @@ -13,7 +13,7 @@ // See the GNU General Public License for more details. // // Alternatively, you can license this software under a commercial -// license, as set out in . +// license, as set out in https://www.mongoose.ws/licensing/ #ifndef MONGOOSE_H #define MONGOOSE_H diff --git a/src/license.h b/src/license.h index 47a86452..c62f00f4 100644 --- a/src/license.h +++ b/src/license.h @@ -5,7 +5,7 @@ // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. For the terms of this -// license, see . +// license, see http://www.gnu.org/licenses/ // // You are free to use this software under the terms of the GNU General // Public License, but WITHOUT ANY WARRANTY; without even the implied @@ -13,4 +13,4 @@ // See the GNU General Public License for more details. // // Alternatively, you can license this software under a commercial -// license, as set out in . +// license, as set out in https://www.mongoose.ws/licensing/ From 7c5e67b27210e7dee69820d8d6594e429e154aa9 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 22 Oct 2021 08:56:45 +0100 Subject: [PATCH 3/8] Fix #1382 - use sendto for UDP send --- mongoose.c | 42 ++++++++++++++++++++++++------------------ src/dns.c | 18 +++++++++--------- src/http.c | 2 +- src/sntp.c | 3 +-- src/sock.c | 19 +++++++++++++------ 5 files changed, 48 insertions(+), 36 deletions(-) diff --git a/mongoose.c b/mongoose.c index 9abcf9fb..c11daf8c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -188,22 +188,22 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, memset(rr, 0, sizeof(*rr)); if (len < sizeof(struct mg_dns_header)) return 0; // Too small - if (len > 512) return 0; // Too large, we don't expect that - if (s >= e) return 0; // Overflow + if (len > 512) return 0; // Too large, we don't expect that + if (s >= e) return 0; // Overflow if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) return 0; s += rr->nlen + 4; if (s > e) return 0; - rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]); - rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); - if (is_question) return (size_t)(rr->nlen + 4); + rr->atype = (uint16_t) (((uint16_t) s[-4] << 8) | s[-3]); + rr->aclass = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]); + if (is_question) return (size_t) (rr->nlen + 4); s += 6; if (s > e) return 0; - rr->alen = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); + rr->alen = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]); if (s + rr->alen > e) return 0; - return (size_t)(rr->nlen + rr->alen + 10); + return (size_t) (rr->nlen + rr->alen + 10); } bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) { @@ -316,7 +316,7 @@ void mg_dns_send(struct mg_connection *c, const struct mg_str *name, pkt.header.num_questions = mg_htons(1); for (i = n = 0; i < sizeof(pkt.data) - 5; i++) { if (name->ptr[i] == '.' || i >= name->len) { - pkt.data[n] = (uint8_t)(i - n); + pkt.data[n] = (uint8_t) (i - n); memcpy(&pkt.data[n + 1], name->ptr + n, i - n); n = i + 1; } @@ -358,7 +358,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms, #if MG_ENABLE_LOG char buf[100]; #endif - d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1; + d->txnid = s_reqs ? (uint16_t) (s_reqs->txnid + 1) : 1; d->next = s_reqs; s_reqs = d; d->expire = mg_millis() + (unsigned long) ms; @@ -1475,7 +1475,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path[path_size - 1] = '\0'; // Double-check remove_double_dots(path); n = strlen(path); - LOG(LL_DEBUG, ("--> %s", path)); + LOG(LL_VERBOSE_DEBUG, ("%lu %s", c->id, path)); while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = fs->stat(path, NULL, NULL); // Does it exist? if (flags == 0) { @@ -2828,8 +2828,7 @@ void mg_sntp_send(struct mg_connection *c, unsigned long utc) { s_sntmp_next = utc + SNTP_INTERVAL_SEC; buf[0] = (3 << 6) | (4 << 3) | 3; mg_send(c, buf, sizeof(buf)); - LOG(LL_DEBUG, - ("%p request sent, ct %lu, next at %lu", c->fd, utc, s_sntmp_next)); + LOG(LL_DEBUG, ("%lu ct %lu, next at %lu", c->id, utc, s_sntmp_next)); } } @@ -2947,7 +2946,14 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client, } static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) { - long n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); + long n; + if (c->is_udp) { + union usa usa; + socklen_t slen = tousa(&c->peer, &usa); + n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen); + } else { + n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); + } return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n; } @@ -3213,12 +3219,12 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) { SOCKET fd = accept(FD(lsn), &usa.sa, &sa_len); if (fd == INVALID_SOCKET) { #if MG_ARCH == MG_ARCH_AZURERTOS - // AzureRTOS, in non-block socket mode can mark listening socket readable - // even it is not. See comment for 'select' func implementation in nx_bsd.c - // That's not an error, just should try later - if (MG_SOCK_ERRNO != EAGAIN) + // AzureRTOS, in non-block socket mode can mark listening socket readable + // even it is not. See comment for 'select' func implementation in nx_bsd.c + // That's not an error, just should try later + if (MG_SOCK_ERRNO != EAGAIN) #endif - LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); + LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); #if (!defined(_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP)) } else if ((long) fd >= FD_SETSIZE) { LOG(LL_ERROR, ("%ld > %ld", (long) fd, (long) FD_SETSIZE)); diff --git a/src/dns.c b/src/dns.c index 6318c537..32fef8ae 100644 --- a/src/dns.c +++ b/src/dns.c @@ -74,22 +74,22 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, memset(rr, 0, sizeof(*rr)); if (len < sizeof(struct mg_dns_header)) return 0; // Too small - if (len > 512) return 0; // Too large, we don't expect that - if (s >= e) return 0; // Overflow + if (len > 512) return 0; // Too large, we don't expect that + if (s >= e) return 0; // Overflow if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) return 0; s += rr->nlen + 4; if (s > e) return 0; - rr->atype = (uint16_t)(((uint16_t) s[-4] << 8) | s[-3]); - rr->aclass = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); - if (is_question) return (size_t)(rr->nlen + 4); + rr->atype = (uint16_t) (((uint16_t) s[-4] << 8) | s[-3]); + rr->aclass = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]); + if (is_question) return (size_t) (rr->nlen + 4); s += 6; if (s > e) return 0; - rr->alen = (uint16_t)(((uint16_t) s[-2] << 8) | s[-1]); + rr->alen = (uint16_t) (((uint16_t) s[-2] << 8) | s[-1]); if (s + rr->alen > e) return 0; - return (size_t)(rr->nlen + rr->alen + 10); + return (size_t) (rr->nlen + rr->alen + 10); } bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) { @@ -202,7 +202,7 @@ void mg_dns_send(struct mg_connection *c, const struct mg_str *name, pkt.header.num_questions = mg_htons(1); for (i = n = 0; i < sizeof(pkt.data) - 5; i++) { if (name->ptr[i] == '.' || i >= name->len) { - pkt.data[n] = (uint8_t)(i - n); + pkt.data[n] = (uint8_t) (i - n); memcpy(&pkt.data[n + 1], name->ptr + n, i - n); n = i + 1; } @@ -244,7 +244,7 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms, #if MG_ENABLE_LOG char buf[100]; #endif - d->txnid = s_reqs ? (uint16_t)(s_reqs->txnid + 1) : 1; + d->txnid = s_reqs ? (uint16_t) (s_reqs->txnid + 1) : 1; d->next = s_reqs; s_reqs = d; d->expire = mg_millis() + (unsigned long) ms; diff --git a/src/http.c b/src/http.c index 2727d634..7b082220 100644 --- a/src/http.c +++ b/src/http.c @@ -725,7 +725,7 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, path[path_size - 1] = '\0'; // Double-check remove_double_dots(path); n = strlen(path); - LOG(LL_DEBUG, ("--> %s", path)); + LOG(LL_VERBOSE_DEBUG, ("%lu %s", c->id, path)); while (n > 0 && path[n - 1] == '/') path[--n] = 0; // Trim trailing slashes flags = fs->stat(path, NULL, NULL); // Does it exist? if (flags == 0) { diff --git a/src/sntp.c b/src/sntp.c index dc932fbf..ad4c8a90 100644 --- a/src/sntp.c +++ b/src/sntp.c @@ -54,8 +54,7 @@ void mg_sntp_send(struct mg_connection *c, unsigned long utc) { s_sntmp_next = utc + SNTP_INTERVAL_SEC; buf[0] = (3 << 6) | (4 << 3) | 3; mg_send(c, buf, sizeof(buf)); - LOG(LL_DEBUG, - ("%p request sent, ct %lu, next at %lu", c->fd, utc, s_sntmp_next)); + LOG(LL_DEBUG, ("%lu ct %lu, next at %lu", c->id, utc, s_sntmp_next)); } } diff --git a/src/sock.c b/src/sock.c index c59f5167..11ea3426 100644 --- a/src/sock.c +++ b/src/sock.c @@ -101,7 +101,14 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client, } static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) { - long n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); + long n; + if (c->is_udp) { + union usa usa; + socklen_t slen = tousa(&c->peer, &usa); + n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen); + } else { + n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); + } return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n; } @@ -367,12 +374,12 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) { SOCKET fd = accept(FD(lsn), &usa.sa, &sa_len); if (fd == INVALID_SOCKET) { #if MG_ARCH == MG_ARCH_AZURERTOS - // AzureRTOS, in non-block socket mode can mark listening socket readable - // even it is not. See comment for 'select' func implementation in nx_bsd.c - // That's not an error, just should try later - if (MG_SOCK_ERRNO != EAGAIN) + // AzureRTOS, in non-block socket mode can mark listening socket readable + // even it is not. See comment for 'select' func implementation in nx_bsd.c + // That's not an error, just should try later + if (MG_SOCK_ERRNO != EAGAIN) #endif - LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); + LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); #if (!defined(_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP)) } else if ((long) fd >= FD_SETSIZE) { LOG(LL_ERROR, ("%ld > %ld", (long) fd, (long) FD_SETSIZE)); From 54590aaf269eaef1052362c01832d9bbb6a007f4 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 22 Oct 2021 09:14:18 +0100 Subject: [PATCH 4/8] Use UDP sendto() on win32 only --- mongoose.c | 7 ++++++- src/sock.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index c11daf8c..ddc506a9 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2947,11 +2947,16 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client, static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) { long n; +#if defined(_WIN32) + // See #1338, #1382. On Windows, UDP send() can fail despite connected. + // Use sendto() instead. But not UNIX: e.g. on Mac we'll get EISCONN if (c->is_udp) { union usa usa; socklen_t slen = tousa(&c->peer, &usa); n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen); - } else { + } else +#endif + { n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); } return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n; diff --git a/src/sock.c b/src/sock.c index 11ea3426..6e816d2a 100644 --- a/src/sock.c +++ b/src/sock.c @@ -102,11 +102,16 @@ static struct mg_connection *alloc_conn(struct mg_mgr *mgr, bool is_client, static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) { long n; +#if defined(_WIN32) + // See #1338, #1382. On Windows, UDP send() can fail despite connected. + // Use sendto() instead. But not UNIX: e.g. on Mac we'll get EISCONN if (c->is_udp) { union usa usa; socklen_t slen = tousa(&c->peer, &usa); n = sendto(FD(c), (char *) buf, len, 0, &usa.sa, slen); - } else { + } else +#endif + { n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING); } return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n; From 2430cc5aace3b716f5edee72ba2593c8e8e9b665 Mon Sep 17 00:00:00 2001 From: Alex Alashkin Date: Fri, 22 Oct 2021 12:57:15 +0300 Subject: [PATCH 5/8] Add more NXP examples and move them to nxp folder --- .github/workflows/test.yml | 104 +++++++++++++++++- .../nxp-evkbimxrt1050-lwip-freertos/Makefile | 9 ++ .../nxp-evkmimxrt1020-lwip-freertos/Makefile | 9 ++ .../nxp-evkmimxrt1024-lwip-freertos/Makefile | 9 ++ .../nxp-evkmimxrt1060-lwip-freertos/Makefile | 9 ++ .../nxp-evkmimxrt1064-lwip-freertos/Makefile | 9 ++ .../Makefile | 9 ++ .../Makefile | 9 ++ .../Makefile | 9 ++ .../nxp/nxp-frdmk64f-lwip-freertos/Makefile | 9 ++ .../{ => nxp}/nxp-frdmk66f-freertos/Makefile | 2 +- .../nxp/nxp-frdmk66f-lwip-freertos/Makefile | 9 ++ .../Makefile | 9 ++ .../Makefile | 9 ++ .../Makefile | 9 ++ .../Makefile | 9 ++ .../nxp-lpcxpresso54s018m-freertos/Makefile | 2 +- .../nxp-mimxrt1020-azurertos/Makefile | 2 +- .../nxp-mimxrt1020-freertos/Makefile | 2 +- .../nxp-twrk65f180m-lwip-freertos/Makefile | 9 ++ .../nxp-twrkv58f220m-lwip-freertos/Makefile | 9 ++ 21 files changed, 248 insertions(+), 8 deletions(-) create mode 100644 examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile rename examples/{ => nxp}/nxp-frdmk66f-freertos/Makefile (76%) create mode 100644 examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile rename examples/{ => nxp}/nxp-lpcxpresso54s018m-freertos/Makefile (76%) rename examples/{ => nxp}/nxp-mimxrt1020-azurertos/Makefile (76%) rename examples/{ => nxp}/nxp-mimxrt1020-freertos/Makefile (76%) create mode 100644 examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile create mode 100644 examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65515979..20c4bfbf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,22 +92,118 @@ jobs: steps: - uses: actions/checkout@v2 - name: nxp-mimxrt1020-azurertos - run: make -C examples/nxp-mimxrt1020-azurertos build + run: make -C examples/nxp/nxp-mimxrt1020-azurertos build nxp-frdmk66f-freertos: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: nxp-frdmk66f-freertos - run: make -C examples/nxp-frdmk66f-freertos build + run: make -C examples/nxp/nxp-frdmk66f-freertos build nxp-lpcxpresso54s018m-freertos: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: nxp-lpcxpresso54s018m-freertos - run: make -C examples/nxp-lpcxpresso54s018m-freertos build + run: make -C examples/nxp/nxp-lpcxpresso54s018m-freertos build nxp-mimxrt1020-freertos: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: nxp-mimxrt1020-freertos - run: make -C examples/nxp-mimxrt1020-freertos build \ No newline at end of file + run: make -C examples/nxp/nxp-mimxrt1020-freertos build + nxp-evkbimxrt1050-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkbimxrt1050-lwip-freertos + run: make -C examples/nxp/nxp-evkbimxrt1050-lwip-freertos build + nxp-evkmimxrt1020-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1020-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1020-lwip-freertos build + nxp-evkmimxrt1024-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1024-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1024-lwip-freertos build + nxp-evkmimxrt1060-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1060-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1060-lwip-freertos build + nxp-evkmimxrt1064-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1064-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1064-lwip-freertos build + nxp-evkmimxrt1160-cm7-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1160-cm7-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos build + nxp-evkmimxrt1170-cm4-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1170-cm4-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos build + nxp-evkmimxrt1170-cm7-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-evkmimxrt1170-cm7-lwip-freertos + run: make -C examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos build + nxp-frdmk64f-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-frdmk64f-lwip-freertos + run: make -C examples/nxp/nxp-frdmk64f-lwip-freertos build + nxp-frdmk66f-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-frdmk66f-lwip-freertos + run: make -C examples/nxp/nxp-frdmk66f-lwip-freertos build + nxp-lpcxpresso54018-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-lpcxpresso54018-lwip-freertos + run: make -C examples/nxp/nxp-lpcxpresso54018-lwip-freertos build + nxp-lpcxpresso54608-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-lpcxpresso54608-lwip-freertos + run: make -C examples/nxp/nxp-lpcxpresso54608-lwip-freertos build + nxp-lpcxpresso54618-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-lpcxpresso54618-lwip-freertos + run: make -C examples/nxp/nxp-lpcxpresso54618-lwip-freertos build + nxp-lpcxpresso54628-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-lpcxpresso54628-lwip-freertos + run: make -C examples/nxp/nxp-lpcxpresso54628-lwip-freertos build + nxp-twrk65f180m-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-twrk65f180m-lwip-freertos + run: make -C examples/nxp/nxp-twrk65f180m-lwip-freertos build + nxp-twrkv58f220m-lwip-freertos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: nxp-twrkv58f220m-lwip-freertos + run: make -C examples/nxp/nxp-twrkv58f220m-lwip-freertos build \ No newline at end of file diff --git a/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile b/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkbimxrt1050-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1020-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1024-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1060-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1064-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1160-cm7-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1170-cm4-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile b/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-evkmimxrt1170-cm7-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile b/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-frdmk64f-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp-frdmk66f-freertos/Makefile b/examples/nxp/nxp-frdmk66f-freertos/Makefile similarity index 76% rename from examples/nxp-frdmk66f-freertos/Makefile rename to examples/nxp/nxp-frdmk66f-freertos/Makefile index 1400540e..59bc811c 100644 --- a/examples/nxp-frdmk66f-freertos/Makefile +++ b/examples/nxp/nxp-frdmk66f-freertos/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/source/ + cp ./../../../mongoose.[ch] $(NAME)/source/ make -C $(NAME) build clean: diff --git a/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile b/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-frdmk66f-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-lpcxpresso54018-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-lpcxpresso54608-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-lpcxpresso54618-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-lpcxpresso54628-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp-lpcxpresso54s018m-freertos/Makefile b/examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile similarity index 76% rename from examples/nxp-lpcxpresso54s018m-freertos/Makefile rename to examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile index 1400540e..59bc811c 100644 --- a/examples/nxp-lpcxpresso54s018m-freertos/Makefile +++ b/examples/nxp/nxp-lpcxpresso54s018m-freertos/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/source/ + cp ./../../../mongoose.[ch] $(NAME)/source/ make -C $(NAME) build clean: diff --git a/examples/nxp-mimxrt1020-azurertos/Makefile b/examples/nxp/nxp-mimxrt1020-azurertos/Makefile similarity index 76% rename from examples/nxp-mimxrt1020-azurertos/Makefile rename to examples/nxp/nxp-mimxrt1020-azurertos/Makefile index 1400540e..59bc811c 100644 --- a/examples/nxp-mimxrt1020-azurertos/Makefile +++ b/examples/nxp/nxp-mimxrt1020-azurertos/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/source/ + cp ./../../../mongoose.[ch] $(NAME)/source/ make -C $(NAME) build clean: diff --git a/examples/nxp-mimxrt1020-freertos/Makefile b/examples/nxp/nxp-mimxrt1020-freertos/Makefile similarity index 76% rename from examples/nxp-mimxrt1020-freertos/Makefile rename to examples/nxp/nxp-mimxrt1020-freertos/Makefile index 1400540e..59bc811c 100644 --- a/examples/nxp-mimxrt1020-freertos/Makefile +++ b/examples/nxp/nxp-mimxrt1020-freertos/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/source/ + cp ./../../../mongoose.[ch] $(NAME)/source/ make -C $(NAME) build clean: diff --git a/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile b/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-twrk65f180m-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) diff --git a/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile b/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile new file mode 100644 index 00000000..2cc7c5b1 --- /dev/null +++ b/examples/nxp/nxp-twrkv58f220m-lwip-freertos/Makefile @@ -0,0 +1,9 @@ +NAME ?= $(notdir $(CURDIR)) + +build: + git clone --depth 1 https://github.com/mongoose-examples/$(NAME) + cp ./../../../mongoose.[ch] $(NAME)/mongoose/ + make -C $(NAME) build + +clean: + rm -rf $(NAME) From 674299146952a7b993ce05362bca1589b7874224 Mon Sep 17 00:00:00 2001 From: Alex Alashkin Date: Fri, 22 Oct 2021 13:34:44 +0300 Subject: [PATCH 6/8] Move STM32 examples to stm32 folder --- .github/workflows/test.yml | 8 +++---- .../HAL/Legacy/stm32_hal_legacy.h | 0 .../stm32-freertos-tcp/HAL/stm32f7xx_hal.c | 0 .../stm32-freertos-tcp/HAL/stm32f7xx_hal.h | 0 .../HAL/stm32f7xx_hal_conf.h | 0 .../HAL/stm32f7xx_hal_cortex.c | 0 .../HAL/stm32f7xx_hal_cortex.h | 0 .../HAL/stm32f7xx_hal_def.h | 0 .../HAL/stm32f7xx_hal_gpio.c | 0 .../HAL/stm32f7xx_hal_gpio.h | 0 .../HAL/stm32f7xx_hal_gpio_ex.h | 0 .../HAL/stm32f7xx_hal_rcc.h | 0 .../HAL/stm32f7xx_hal_rcc_ex.h | 0 .../{ => stm32}/stm32-freertos-tcp/Makefile | 22 +++++++++---------- .../{ => stm32}/stm32-freertos-tcp/README.md | 0 .../{ => stm32}/stm32-freertos-tcp/main.c | 0 .../stm32-freertos-tcp/openocd.cfg | 0 .../stm32f7/FreeRTOSConfig.h | 0 .../stm32f7/FreeRTOSIPConfig.h | 0 .../stm32-freertos-tcp/stm32f7/boot.s | 0 .../stm32-freertos-tcp/stm32f7/cmsis_gcc.h | 0 .../stm32-freertos-tcp/stm32f7/core_cm7.h | 0 .../stm32-freertos-tcp/stm32f7/core_cmFunc.h | 0 .../stm32-freertos-tcp/stm32f7/core_cmInstr.h | 0 .../stm32-freertos-tcp/stm32f7/core_cmSimd.h | 0 .../stm32-freertos-tcp/stm32f7/device.h | 0 .../stm32-freertos-tcp/stm32f7/link.ld | 0 .../stm32-freertos-tcp/stm32f7/portmacro.h | 0 .../stm32-freertos-tcp/stm32f7/stm32f746xx.h | 0 .../stm32-freertos-tcp/stm32f7/stm32f7xx.h | 0 .../stm32f7/system_stm32f7xx.h | 0 .../{ => stm32}/stm32-nucleo-f429z/Makefile | 2 +- .../{ => stm32}/stm32-nucleo-f746z/Makefile | 2 +- .../{ => stm32}/stm32-nucleo-h743z/Makefile | 2 +- 34 files changed, 18 insertions(+), 18 deletions(-) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal.c (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/Makefile (85%) rename examples/{ => stm32}/stm32-freertos-tcp/README.md (100%) rename examples/{ => stm32}/stm32-freertos-tcp/main.c (100%) rename examples/{ => stm32}/stm32-freertos-tcp/openocd.cfg (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/boot.s (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/cmsis_gcc.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/core_cm7.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/core_cmFunc.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/core_cmInstr.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/core_cmSimd.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/device.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/link.ld (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/portmacro.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/stm32f746xx.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/stm32f7xx.h (100%) rename examples/{ => stm32}/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h (100%) rename examples/{ => stm32}/stm32-nucleo-f429z/Makefile (67%) rename examples/{ => stm32}/stm32-nucleo-f746z/Makefile (67%) rename examples/{ => stm32}/stm32-nucleo-h743z/Makefile (67%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65515979..d9bdac66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,25 +68,25 @@ jobs: steps: - uses: actions/checkout@v2 - name: stm32-freertos-tcp - run: make -C examples/stm32-freertos-tcp build + run: make -C examples/stm32/stm32-freertos-tcp build stm32-nucleo-f746z: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: stm32-nucleo-f746z - run: make -C examples/stm32-nucleo-f746z build + run: make -C examples/stm32/stm32-nucleo-f746z build stm32-nucleo-f429z: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: stm32-nucleo-f429z - run: make -C examples/stm32-nucleo-f429z build + run: make -C examples/stm32/stm32-nucleo-f429z build stm32-nucleo-h743z: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: stm32-nucleo-h743z - run: make -C examples/stm32-nucleo-h743z build + run: make -C examples/stm32/stm32-nucleo-h743z build nxp-mimxrt1020-azurertos: runs-on: ubuntu-latest steps: diff --git a/examples/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h b/examples/stm32/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h rename to examples/stm32/stm32-freertos-tcp/HAL/Legacy/stm32_hal_legacy.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.c similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.c rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.c diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_conf.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.c diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_cortex.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_def.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.c diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_gpio_ex.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc.h diff --git a/examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h b/examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h similarity index 100% rename from examples/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h rename to examples/stm32/stm32-freertos-tcp/HAL/stm32f7xx_hal_rcc_ex.h diff --git a/examples/stm32-freertos-tcp/Makefile b/examples/stm32/stm32-freertos-tcp/Makefile similarity index 85% rename from examples/stm32-freertos-tcp/Makefile rename to examples/stm32/stm32-freertos-tcp/Makefile index 323a664f..5c08a57a 100644 --- a/examples/stm32-freertos-tcp/Makefile +++ b/examples/stm32/stm32-freertos-tcp/Makefile @@ -1,13 +1,13 @@ # FreeRTOS/{FreeRTOS-Kernel V10.4.3,FreeRTOS-Plus-TCP V2.3.2} PROG = firmware ARCH = stm32f7 -PROJECT_ROOT_PATH = $(realpath $(CURDIR)/../..) +PROJECT_ROOT_PATH = $(realpath $(CURDIR)/../../..) DOCKER ?= docker run --rm -v $(PROJECT_ROOT_PATH):$(PROJECT_ROOT_PATH) -w $(CURDIR) mdashnet/armgcc FREERTOS_KERNEL_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-kernel FREERTOS_PLUS_TCP_PATH ?= $(PROJECT_ROOT_PATH)/test/freertos-tcp MONGOOSE_FLAGS = -DMG_ARCH=MG_ARCH_FREERTOS_TCP -MCU_FLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=softfp -mfpu=vfpv4 +MCU_FLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=softfp -mfpu=vfpv4 #-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard INCLUDES = -I$(PROJECT_ROOT_PATH) -I$(ARCH) -I$(FREERTOS_KERNEL_PATH)/include -I$(FREERTOS_PLUS_TCP_PATH)/include @@ -36,19 +36,19 @@ SOURCES += $(FREERTOS_KERNEL_PATH)/portable/MemMang/heap_5.c SOURCES += $(FREERTOS_KERNEL_PATH)/portable/GCC/ARM_CM7/r0p1/port.c # FreeRTOS TCP stack sources -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_ARP.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DHCP.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DNS.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_IP.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Sockets.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Stream_Buffer.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_ARP.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DHCP.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_DNS.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_IP.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Sockets.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_Stream_Buffer.c SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_IP.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_WIN.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_UDP_IP.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_TCP_WIN.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/FreeRTOS_UDP_IP.c SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/Common/phyHandling.c SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/BufferManagement/BufferAllocation_1.c SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/NetworkInterface.c -SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c +SOURCES += $(FREERTOS_PLUS_TCP_PATH)/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c OBJECTS = obj/boot.o $(SOURCES:%.c=obj/%.o) diff --git a/examples/stm32-freertos-tcp/README.md b/examples/stm32/stm32-freertos-tcp/README.md similarity index 100% rename from examples/stm32-freertos-tcp/README.md rename to examples/stm32/stm32-freertos-tcp/README.md diff --git a/examples/stm32-freertos-tcp/main.c b/examples/stm32/stm32-freertos-tcp/main.c similarity index 100% rename from examples/stm32-freertos-tcp/main.c rename to examples/stm32/stm32-freertos-tcp/main.c diff --git a/examples/stm32-freertos-tcp/openocd.cfg b/examples/stm32/stm32-freertos-tcp/openocd.cfg similarity index 100% rename from examples/stm32-freertos-tcp/openocd.cfg rename to examples/stm32/stm32-freertos-tcp/openocd.cfg diff --git a/examples/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h b/examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSConfig.h diff --git a/examples/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h b/examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/FreeRTOSIPConfig.h diff --git a/examples/stm32-freertos-tcp/stm32f7/boot.s b/examples/stm32/stm32-freertos-tcp/stm32f7/boot.s similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/boot.s rename to examples/stm32/stm32-freertos-tcp/stm32f7/boot.s diff --git a/examples/stm32-freertos-tcp/stm32f7/cmsis_gcc.h b/examples/stm32/stm32-freertos-tcp/stm32f7/cmsis_gcc.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/cmsis_gcc.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/cmsis_gcc.h diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cm7.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cm7.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/core_cm7.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cm7.h diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmFunc.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmFunc.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/core_cmFunc.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmFunc.h diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmInstr.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmInstr.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/core_cmInstr.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmInstr.h diff --git a/examples/stm32-freertos-tcp/stm32f7/core_cmSimd.h b/examples/stm32/stm32-freertos-tcp/stm32f7/core_cmSimd.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/core_cmSimd.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/core_cmSimd.h diff --git a/examples/stm32-freertos-tcp/stm32f7/device.h b/examples/stm32/stm32-freertos-tcp/stm32f7/device.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/device.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/device.h diff --git a/examples/stm32-freertos-tcp/stm32f7/link.ld b/examples/stm32/stm32-freertos-tcp/stm32f7/link.ld similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/link.ld rename to examples/stm32/stm32-freertos-tcp/stm32f7/link.ld diff --git a/examples/stm32-freertos-tcp/stm32f7/portmacro.h b/examples/stm32/stm32-freertos-tcp/stm32f7/portmacro.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/portmacro.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/portmacro.h diff --git a/examples/stm32-freertos-tcp/stm32f7/stm32f746xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/stm32f746xx.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/stm32f746xx.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/stm32f746xx.h diff --git a/examples/stm32-freertos-tcp/stm32f7/stm32f7xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/stm32f7xx.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/stm32f7xx.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/stm32f7xx.h diff --git a/examples/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h b/examples/stm32/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h similarity index 100% rename from examples/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h rename to examples/stm32/stm32-freertos-tcp/stm32f7/system_stm32f7xx.h diff --git a/examples/stm32-nucleo-f429z/Makefile b/examples/stm32/stm32-nucleo-f429z/Makefile similarity index 67% rename from examples/stm32-nucleo-f429z/Makefile rename to examples/stm32/stm32-nucleo-f429z/Makefile index fe9aa4ed..92b4174e 100644 --- a/examples/stm32-nucleo-f429z/Makefile +++ b/examples/stm32/stm32-nucleo-f429z/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ + cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ make -C $(NAME) build clean: diff --git a/examples/stm32-nucleo-f746z/Makefile b/examples/stm32/stm32-nucleo-f746z/Makefile similarity index 67% rename from examples/stm32-nucleo-f746z/Makefile rename to examples/stm32/stm32-nucleo-f746z/Makefile index fe9aa4ed..92b4174e 100644 --- a/examples/stm32-nucleo-f746z/Makefile +++ b/examples/stm32/stm32-nucleo-f746z/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ + cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ make -C $(NAME) build clean: diff --git a/examples/stm32-nucleo-h743z/Makefile b/examples/stm32/stm32-nucleo-h743z/Makefile similarity index 67% rename from examples/stm32-nucleo-h743z/Makefile rename to examples/stm32/stm32-nucleo-h743z/Makefile index fe9aa4ed..92b4174e 100644 --- a/examples/stm32-nucleo-h743z/Makefile +++ b/examples/stm32/stm32-nucleo-h743z/Makefile @@ -2,7 +2,7 @@ NAME ?= $(notdir $(CURDIR)) build: git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ + cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ make -C $(NAME) build clean: From 65fd834654aa29f910e3e677f3efd80f6f5cd7d9 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 22 Oct 2021 13:58:51 +0100 Subject: [PATCH 7/8] Increate mqtt test timeout --- mongoose.c | 1 + test/unit_test.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index d7a51082..38bebb6e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -25,6 +25,7 @@ void mg_connect_resolved(struct mg_connection *); #ifdef MG_ENABLE_LINES #line 1 "src/base64.c" #endif + #include static int mg_b64idx(int c) { diff --git a/test/unit_test.c b/test/unit_test.c index 42391149..9e5f26d8 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -340,11 +340,11 @@ static void test_mqtt(void) { opts.will_topic = mg_str("mg_will_topic"); opts.will_message = mg_str("mg_will_messsage"); c = mg_mqtt_connect(&mgr, url, &opts, mqtt_cb, buf); - for (i = 0; i < 100 && buf[0] == 0; i++) mg_mgr_poll(&mgr, 10); + for (i = 0; i < 200 && buf[0] == 0; i++) mg_mgr_poll(&mgr, 10); ASSERT(buf[0] == 'X'); mg_mqtt_sub(c, &topic, 1); mg_mqtt_pub(c, &topic, &data, 1, false); - for (i = 0; i < 100 && buf[1] == 0; i++) mg_mgr_poll(&mgr, 10); + for (i = 0; i < 200 && buf[1] == 0; i++) mg_mgr_poll(&mgr, 10); ASSERT(strcmp(buf, "Xx/f12/hi") == 0); mg_mgr_free(&mgr); From fb90c504a695719d9eb097a31988c88fb0700b39 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 22 Oct 2021 14:00:31 +0100 Subject: [PATCH 8/8] Remove private.h --- Makefile | 2 +- mongoose.c | 5 ----- mongoose.h | 1 + src/net.h | 1 + src/private.h | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 src/private.h diff --git a/Makefile b/Makefile index fee95c02..6a06ec33 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ uninstall: rm -rf $(DESTDIR)$(PREFIX)/lib/libmongoose.a $(DESTDIR)$(PREFIX)/lib/libmongoose.so.$(VERSION) $(DESTDIR)$(PREFIX)/include/mongoose.h $(DESTDIR)$(PREFIX)/lib/libmongoose.so mongoose.c: Makefile $(wildcard src/*) - (cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/private.h src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@ + (cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@ mongoose.h: $(HDRS) Makefile (cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/config.h src/arch.h src/arch_*.h src/str.h src/log.h src/timer.h src/util.h src/fs.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/ws.h src/sntp.h src/mqtt.h src/dns.h | sed -e 's,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@ diff --git a/mongoose.c b/mongoose.c index 38bebb6e..4b18ad6b 100644 --- a/mongoose.c +++ b/mongoose.c @@ -17,11 +17,6 @@ #include "mongoose.h" -#ifdef MG_ENABLE_LINES -#line 1 "src/private.h" -#endif -void mg_connect_resolved(struct mg_connection *); - #ifdef MG_ENABLE_LINES #line 1 "src/base64.c" #endif diff --git a/mongoose.h b/mongoose.h index c3be53d3..8a73373d 100644 --- a/mongoose.h +++ b/mongoose.h @@ -819,6 +819,7 @@ struct mg_connection *mg_listen(struct mg_mgr *, const char *url, mg_event_handler_t fn, void *fn_data); struct mg_connection *mg_connect(struct mg_mgr *, const char *url, mg_event_handler_t fn, void *fn_data); +void mg_connect_resolved(struct mg_connection *); bool mg_send(struct mg_connection *, const void *, size_t); int mg_printf(struct mg_connection *, const char *fmt, ...); int mg_vprintf(struct mg_connection *, const char *fmt, va_list ap); diff --git a/src/net.h b/src/net.h index 0950db9c..527bf78d 100644 --- a/src/net.h +++ b/src/net.h @@ -67,6 +67,7 @@ struct mg_connection *mg_listen(struct mg_mgr *, const char *url, mg_event_handler_t fn, void *fn_data); struct mg_connection *mg_connect(struct mg_mgr *, const char *url, mg_event_handler_t fn, void *fn_data); +void mg_connect_resolved(struct mg_connection *); bool mg_send(struct mg_connection *, const void *, size_t); int mg_printf(struct mg_connection *, const char *fmt, ...); int mg_vprintf(struct mg_connection *, const char *fmt, va_list ap); diff --git a/src/private.h b/src/private.h deleted file mode 100644 index eeb40939..00000000 --- a/src/private.h +++ /dev/null @@ -1 +0,0 @@ -void mg_connect_resolved(struct mg_connection *);