iopsys-feed/obuspa/patches/0013-mqtt-retry-param-change.patch
2024-06-13 14:09:52 +05:30

76 lines
2.1 KiB
Diff

diff --git a/src/core/device_mqtt.c b/src/core/device_mqtt.c
index 7438e59..231d941 100755
--- a/src/core/device_mqtt.c
+++ b/src/core/device_mqtt.c
@@ -1612,14 +1612,23 @@ int NotifyChange_MQTTRequestProblemInfo(dm_req_t *req, char *value)
int NotifyChange_MQTTConnectRetryTime(dm_req_t *req, char *value)
{
mqtt_conn_params_t *mp;
+ bool schedule_reconnect = false;
// Determine mqtt client to be updated
mp = FindMqttParamsByInstance(inst1);
USP_ASSERT(mp != NULL);
// Set the new value.
+ if ((mp->retry.connect_retrytime != val_uint) && (mp->enable)) {
+ schedule_reconnect = true;
+ }
+
mp->retry.connect_retrytime = val_uint;
+ if (schedule_reconnect) {
+ ScheduleMqttReconnect(mp);
+ }
+
return USP_ERR_OK;
}
@@ -1638,14 +1647,23 @@ int NotifyChange_MQTTConnectRetryTime(dm_req_t *req, char *value)
int NotifyChange_MQTTConnectRetryIntervalMultiplier(dm_req_t *req, char *value)
{
mqtt_conn_params_t *mp;
+ bool schedule_reconnect = false;
// Determine mqtt client to be updated
mp = FindMqttParamsByInstance(inst1);
USP_ASSERT(mp != NULL);
+ if ((mp->retry.interval_multiplier != val_int) && (mp->enable)) {
+ schedule_reconnect = true;
+ }
+
// Set the new value.
mp->retry.interval_multiplier = val_int;
+ if (schedule_reconnect) {
+ ScheduleMqttReconnect(mp);
+ }
+
return USP_ERR_OK;
}
@@ -1664,14 +1682,23 @@ int NotifyChange_MQTTConnectRetryIntervalMultiplier(dm_req_t *req, char *value)
int NotifyChange_MQTTConnectRetryMaxInterval(dm_req_t *req, char *value)
{
mqtt_conn_params_t *mp;
+ bool schedule_reconnect = false;
// Determine mqtt client to be updated
mp = FindMqttParamsByInstance(inst1);
USP_ASSERT(mp != NULL);
+ if ((mp->retry.max_interval != val_uint) && (mp->enable)) {
+ schedule_reconnect = true;
+ }
+
// Set the new value.
mp->retry.max_interval = val_uint;
+ if (schedule_reconnect) {
+ ScheduleMqttReconnect(mp);
+ }
+
return USP_ERR_OK;
}