From 026a768d2b8b09fed2629b6228d00fd69e7cbe40 Mon Sep 17 00:00:00 2001 From: Nuertey Odzeyem Date: Fri, 27 May 2022 09:58:38 -0500 Subject: [PATCH] Solved the issue below which I also used to observe a long time ago when I would be doing MQTT testing. Also see this thread below on me instructing other folks on how to solve it on their setups. https://github.com/ARMmbed/mbed-mqtt/issues/30 Nuertey-Dragonfly-Cellular-LightControl Application - Beginning... Mbed OS version: 6.15.1 Built: May 27 2022, 07:58:10 Running LEDLightControl::Setup() ... [00000179ms][INFO][STE1]: power_up: PHY Addr 0 AutoNeg 1 [00000254ms][DBG ][STE1]: MAC Addr 00:80:e1:37:00:25 [00000325ms][INFO][STE1]: ETH buffers : 4 Rx 4 Tx [00001871ms][INFO][STE1]: PHY ID 7C130 [00001939ms][INFO][STE1]: low_level_init_successful Connecting to network ... [00002207ms][INFO][STE1]: emac_link_state_cb set to true Global IP address set! Running LEDLightControl::ConnectToSocket() ... Particular Network Interface IP address: 10.42.0.58 Particular Network Interface Netmask: 255.255.255.0 Particular Network Interface Gateway: 10.42.0.1 Particular Network Interface MAC Address: 00:80:e1:37:00:25 Connecting to "10.42.0.1" as resolved to: "10.42.0.1:7" ... Error! TCPSocket.connect() to EchoServer returned: [-3004] -> "not connected to a network" --- LEDLightControl.h | 1 + Utilities.h | 11 +++++++++-- mbed_app.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/LEDLightControl.h b/LEDLightControl.h index aa190e2..8a5bb5e 100644 --- a/LEDLightControl.h +++ b/LEDLightControl.h @@ -442,6 +442,7 @@ void LEDLightControl::ConnectToSocket() // event again should network conditions become better favorable. return; } + m_TheSocketAddress.set_port(m_EchoServerPort); if (m_TheTransportSocketType == TransportSocket_t::TCP) diff --git a/Utilities.h b/Utilities.h index cde60b9..82cbc30 100644 --- a/Utilities.h +++ b/Utilities.h @@ -155,8 +155,15 @@ namespace Utilities // user can choose to specify IP addresses directly in the mbed_app.json // echo-server-hostname field. This will facilitate testing with // locally hosted Echo Servers, which by necessity, do not have - // DNS names. - ipAddress.emplace(address.c_str()); + // DNS names. + + // In which case the following is how we can ensure that the requisite + // SocketAddress object that is normally created during FQDN resolution, + // is manually constructed and propagated back to the User: + SocketAddress tempSockAddress(address.c_str(), 0); + *pTheSocketAddress = tempSockAddress; + + ipAddress.emplace(address.c_str()); } } diff --git a/mbed_app.json b/mbed_app.json index 216975d..5ec4829 100644 --- a/mbed_app.json +++ b/mbed_app.json @@ -7,7 +7,7 @@ "sock-type": "NUERTEY_TCP", "echo-server-hostname": { "help": "Echo server host name.", - "value": "\"10.50.10.25\"" + "value": "\"10.42.0.1\"" }, "echo-server-port": { "help": "Echo server port number.",