File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 15621562#ifndef MY_MQTT_ETH_INIT_DELAY
15631563#define MY_MQTT_ETH_INIT_DELAY 1000
15641564#endif
1565+ /**
1566+ * @def MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT
1567+ * @brief Set a MQTT broker socket connection timeout time.
1568+ *
1569+ * This define is useful if you want to change default MQTT TCP/IP broker
1570+ * connection timeout. By default, it is 1000ms.
1571+ *
1572+ * Note that this is not supported in ESP8266 and ESP32 platforms, sorry.
1573+ *
1574+ * Example: @code #define MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT 1000 @endcode
1575+ */
1576+ #ifndef MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT
1577+ #define MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT 1000
1578+ #endif
1579+
15651580/**
15661581 * @def MY_IP_ADDRESS
15671582 * @brief Static ip address of gateway. If not defined, DHCP will be used.
23352350#define MY_MQTT_CLIENT_CERT
23362351#define MY_MQTT_CLIENT_KEY
23372352#define MY_MQTT_ETH_INIT_DELAY
2353+ #define MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT
23382354#define MY_SIGNAL_REPORT_ENABLED
23392355// general
23402356#define MY_WITH_LEDS_BLINKING_INVERSE
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ bool reconnectMQTT(void)
159159
160160 return true ;
161161 }
162- delay (1000 );
162+ delay (MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT );
163163 GATEWAY_DEBUG (PSTR (" !GWT:RMQ:FAIL\n " ));
164164 return false ;
165165}
@@ -247,7 +247,10 @@ bool gatewayTransportInit(void)
247247#else
248248 _MQTT_client.setServer (MY_CONTROLLER_URL_ADDRESS, MY_PORT);
249249#endif /* End of MY_CONTROLLER_IP_ADDRESS */
250-
250+ // ESP platform doesn't support connection timeout
251+ #if !defined(MY_GATEWAY_ESP8266) || !defined(MY_GATEWAY_ESP32)
252+ _MQTT_ethClient.setConnectionTimeout (MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT);
253+ #endif
251254 _MQTT_client.setCallback (incomingMQTT);
252255
253256#if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)
Original file line number Diff line number Diff line change @@ -258,6 +258,8 @@ MY_MQTT_PASSWORD LITERAL1
258258MY_MQTT_PUBLISH_TOPIC_PREFIX LITERAL1
259259MY_MQTT_SUBSCRIBE_TOPIC_PREFIX LITERAL1
260260MY_MQTT_USER LITERAL1
261+ MY_MQTT_ETH_CLIENT_CONNECTION_TIMEOUT LITERAL1
262+ MY_MQTT_ETH_INIT_DELAY LITERAL1
261263MY_W5100_SPI_EN LITERAL1
262264MY_WIFI_SSID LITERAL1
263265MY_WIFI_BSSID LITERAL1
You can’t perform that action at this time.
0 commit comments