diff --git a/examples/stm32/nucleo-f746zg-baremetal/Makefile b/examples/stm32/nucleo-f746zg-baremetal/Makefile index 1d3db013..75c647ed 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/Makefile +++ b/examples/stm32/nucleo-f746zg-baremetal/Makefile @@ -34,7 +34,7 @@ DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/5 update: firmware.bin curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$< -test: CFLAGS_EXTRA += -DUART_DEBUG=USART1 +test update: CFLAGS_EXTRA += -DUART_DEBUG=USART1 test: update curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt grep 'READY, IP:' /tmp/output.txt # Check for network init diff --git a/mongoose.c b/mongoose.c index 3422555c..3ed21ec5 100644 --- a/mongoose.c +++ b/mongoose.c @@ -7810,6 +7810,7 @@ static void mg_tcpip_rx(struct mg_tcpip_if *ifp, void *buf, size_t len) { rx_ip(ifp, &pkt); } else { MG_DEBUG((" Unknown eth type %x", mg_htons(pkt.eth->type))); + mg_hexdump(buf, len >= 16 ? 16 : len); } } @@ -7907,8 +7908,9 @@ void mg_tcpip_init(struct mg_mgr *mgr, struct mg_tcpip_if *ifp) { mgr->extraconnsize = sizeof(struct connstate); if (ifp->ip == 0) ifp->enable_dhcp_client = true; memset(ifp->gwmac, 255, sizeof(ifp->gwmac)); // Set to broadcast - mg_random(&ifp->eport, sizeof(ifp->eport)); // Randomise the initial - ifp->eport += MG_EPHEMERAL_PORT_BASE; // ephemeral port + mg_random(&ifp->eport, sizeof(ifp->eport)); // Random from 0 to 65535 + ifp->eport |= + MG_EPHEMERAL_PORT_BASE; // Random from MG_EPHEMERAL_PORT_BASE to 65535 } } diff --git a/src/tcpip/tcpip.c b/src/tcpip/tcpip.c index 9ae0ef07..0e6f1728 100644 --- a/src/tcpip/tcpip.c +++ b/src/tcpip/tcpip.c @@ -759,6 +759,7 @@ static void mg_tcpip_rx(struct mg_tcpip_if *ifp, void *buf, size_t len) { rx_ip(ifp, &pkt); } else { MG_DEBUG((" Unknown eth type %x", mg_htons(pkt.eth->type))); + mg_hexdump(buf, len >= 16 ? 16 : len); } } @@ -856,8 +857,9 @@ void mg_tcpip_init(struct mg_mgr *mgr, struct mg_tcpip_if *ifp) { mgr->extraconnsize = sizeof(struct connstate); if (ifp->ip == 0) ifp->enable_dhcp_client = true; memset(ifp->gwmac, 255, sizeof(ifp->gwmac)); // Set to broadcast - mg_random(&ifp->eport, sizeof(ifp->eport)); // Randomise the initial - ifp->eport += MG_EPHEMERAL_PORT_BASE; // ephemeral port + mg_random(&ifp->eport, sizeof(ifp->eport)); // Random from 0 to 65535 + ifp->eport |= + MG_EPHEMERAL_PORT_BASE; // Random from MG_EPHEMERAL_PORT_BASE to 65535 } }