From 961cc1394858b87dcb6b95768d6538f18640c8b9 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 2 Feb 2023 10:33:00 +0000 Subject: [PATCH] Nits: fix DNS resolution message. Add Makefile comment for testing targets --- .../stm32/nucleo-f429zi-baremetal/Makefile | 18 +++++++++++++----- mongoose.c | 3 ++- src/dns.c | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/stm32/nucleo-f429zi-baremetal/Makefile b/examples/stm32/nucleo-f429zi-baremetal/Makefile index 2d2456ee..f608d958 100644 --- a/examples/stm32/nucleo-f429zi-baremetal/Makefile +++ b/examples/stm32/nucleo-f429zi-baremetal/Makefile @@ -23,14 +23,22 @@ flash: firmware.bin # Requires env variable VCON_API_KEY set DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/2 -test: EXTRA_CFLAGS += -DUART_DEBUG=UART1 -test: update - curl --fail -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt - grep 'Ethernet: up' /tmp/output.txt - grep 'MQTT connected' /tmp/output.txt +# Upload firmware to a remote test device update: firmware.bin curl --fail -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$< +# Read serial port on a remote test device for 5 seconds, store in a +# temporary file, and check the output for expected patterns +test: EXTRA_CFLAGS += -DUART_DEBUG=UART1 +test: update + curl --fail -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt + grep 'Ethernet: up' /tmp/output.txt # Check for network init + grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success + +# Read serial port on a remote test device for 5 seconds +tx: + curl -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 + clean: @rm -rf firmware.* *.su diff --git a/mongoose.c b/mongoose.c index 7825edc8..392b2acc 100644 --- a/mongoose.c +++ b/mongoose.c @@ -273,7 +273,8 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, if (dm.resolved) { dm.addr.port = d->c->rem.port; // Save port d->c->rem = dm.addr; // Copy resolved address - MG_DEBUG(("%lu %s is %M", d->c->id, dm.name, mg_print_ip, &c->rem)); + MG_DEBUG( + ("%lu %s is %M", d->c->id, dm.name, mg_print_ip, &d->c->rem)); mg_connect_resolved(d->c); #if MG_ENABLE_IPV6 } else if (dm.addr.is_ip6 == false && dm.name[0] != '\0' && diff --git a/src/dns.c b/src/dns.c index 37e5b851..a1c5c96b 100644 --- a/src/dns.c +++ b/src/dns.c @@ -161,7 +161,8 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, if (dm.resolved) { dm.addr.port = d->c->rem.port; // Save port d->c->rem = dm.addr; // Copy resolved address - MG_DEBUG(("%lu %s is %M", d->c->id, dm.name, mg_print_ip, &c->rem)); + MG_DEBUG( + ("%lu %s is %M", d->c->id, dm.name, mg_print_ip, &d->c->rem)); mg_connect_resolved(d->c); #if MG_ENABLE_IPV6 } else if (dm.addr.is_ip6 == false && dm.name[0] != '\0' &&