Skip to content

Commit 3b1027b

Browse files
committed
Fixed bug setting connection
1 parent 9958905 commit 3b1027b

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed
Binary file not shown.

org.eclipse.kura.dnomaid.clientMqttPaho/resources/dp/clientMqttPahoDnomaid.dpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#Deployment Plugin Project File
2-
#Thu Nov 18 16:59:06 CET 2021
2+
#Sun Jan 23 18:16:55 CET 2022
33
build.ant.name=<.>/resources/dp/clientMqttPahoDnomaid_build.xml
44
build.dp.file=<.>/resources/dp/clientMqttPahoDnomaid.dp
55
build.location=
6-
bundles.0.bundle_path=<.>/META-INF/exportPlugin/plugins/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202111181658.jar
6+
bundles.0.bundle_path=<.>/META-INF/exportPlugin/plugins/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202201231816.jar
77
bundles.0.customizer=false
88
bundles.0.headers.count=0
99
bundles.0.missing=false
10-
bundles.0.name=bundles/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202111181658.jar
10+
bundles.0.name=bundles/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202201231816.jar
1111
bundles.0.symbolic_name=org.eclipse.kura.dnomaid.clientMqttPaho;singleton\:\=true
12-
bundles.0.version=1.0.0.202111181658
12+
bundles.0.version=1.0.0.202201231816
1313
bundles.count=1
1414
certificates.count=0
1515
general.signbundles=false

org.eclipse.kura.dnomaid.clientMqttPaho/src/org/eclipse/kura/dnomaid/clientMqttPaho/ClientMqttService.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@ public void run() {
9191
mqtt.subscribe();
9292
LAST_SUBSCRIBE = ConnectionConstants.getInst().getSubscribeTopic();
9393
}
94-
String publishTopic = ConnectionConstants.getInst().getPublishTopic();
95-
String publishMessage = ConnectionConstants.getInst().getPublishMessage();
96-
mqtt.publish(publishTopic, publishMessage);
97-
S_LOGGER.info("#Publish topic: "+publishTopic+" #Publish message: "+publishMessage);
98-
if (Status.getInst().isNewMessageReceived(LAST_MESSAGE_RECEIVED)) {
99-
LAST_MESSAGE_RECEIVED = Status.getInst().getLastMessageReceived();
100-
S_LOGGER.info("#Last message received: "+LAST_MESSAGE_RECEIVED);
94+
if(Status.getInst().isConnected()) {
95+
String publishTopic = ConnectionConstants.getInst().getPublishTopic();
96+
String publishMessage = ConnectionConstants.getInst().getPublishMessage();
97+
mqtt.publish(publishTopic, publishMessage);
98+
S_LOGGER.info("#Publish topic: {} #Publish message: {}",publishTopic,publishMessage);
99+
if (Status.getInst().isNewMessageReceived(LAST_MESSAGE_RECEIVED)) {
100+
LAST_MESSAGE_RECEIVED = Status.getInst().getLastMessageReceived();
101+
S_LOGGER.info("#Last message received: {}",LAST_MESSAGE_RECEIVED);
102+
}
101103
}
104+
if(!Status.getInst().noError())S_LOGGER.error("##Error connetion!!");
102105
}else {
103106
if(Status.getInst().isConnected()) {
104107
mqtt.disconnection();

org.eclipse.kura.dnomaid.clientMqttPaho/src/org/eclipse/kura/dnomaid/clientMqttPaho/mqtt/client/Connection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public MqttConnectOptions createConnectionOptions() {
6565
publishTopic = ConnectionConstants.getInst().getPublishTopic();
6666
publishQos = ConnectionConstants.getInst().getPublishQos();
6767
retained = ConnectionConstants.getInst().isRetained();
68-
conOpt = ConnectionConstants.getInst().getConOpt();
68+
conOpt = ConnectionConstants.getInst().updateConOpt();
6969
// last will message
7070
if ((!messageLWT.equals(Status.EMPTY)) || (!publishTopic.equals(Status.EMPTY))) {
7171
conOpt.setWill(publishTopic, messageLWT.getBytes(), publishQos, retained);

org.eclipse.kura.dnomaid.clientMqttPaho/src/org/eclipse/kura/dnomaid/clientMqttPaho/mqtt/global/ConnectionConstants.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,20 @@ public static synchronized ConnectionConstants getInst() {
9191
public void setPublishMessage(String publishTopic) {this.PublishMessage = publishTopic;}
9292

9393
public MqttConnectOptions getConOpt() {return conOpt;}
94+
95+
public MqttConnectOptions updateConOpt(){
96+
conOpt.setCleanSession(CleanSession);
97+
conOpt.setConnectionTimeout(TimeOut);
98+
conOpt.setKeepAliveInterval(KeepAlive);
99+
conOpt.setUserName(Username);
100+
conOpt.setPassword(Password.toCharArray());
101+
return conOpt;
102+
}
94103

95104
//Methods
96105
private void InitConOpt(){
97106
conOpt = new MqttConnectOptions();
98-
conOpt.setCleanSession(CleanSession);
99-
conOpt.setConnectionTimeout(TimeOut);
100-
conOpt.setKeepAliveInterval(KeepAlive);
101-
conOpt.setUserName(Username);
102-
conOpt.setPassword(Password.toCharArray());
107+
updateConOpt();
103108
}
104109
private void InitDefault(){
105110
Uri = URI;

0 commit comments

Comments
 (0)