Skip to content

Commit

Permalink
Fixed bug setting connection
Browse files Browse the repository at this point in the history
  • Loading branch information
DnomaidGit committed Jan 23, 2022
1 parent 9958905 commit 3b1027b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#Deployment Plugin Project File
#Thu Nov 18 16:59:06 CET 2021
#Sun Jan 23 18:16:55 CET 2022
build.ant.name=<.>/resources/dp/clientMqttPahoDnomaid_build.xml
build.dp.file=<.>/resources/dp/clientMqttPahoDnomaid.dp
build.location=
bundles.0.bundle_path=<.>/META-INF/exportPlugin/plugins/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202111181658.jar
bundles.0.bundle_path=<.>/META-INF/exportPlugin/plugins/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202201231816.jar
bundles.0.customizer=false
bundles.0.headers.count=0
bundles.0.missing=false
bundles.0.name=bundles/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202111181658.jar
bundles.0.name=bundles/org.eclipse.kura.dnomaid.clientMqttPaho_1.0.0.202201231816.jar
bundles.0.symbolic_name=org.eclipse.kura.dnomaid.clientMqttPaho;singleton\:\=true
bundles.0.version=1.0.0.202111181658
bundles.0.version=1.0.0.202201231816
bundles.count=1
certificates.count=0
general.signbundles=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ public void run() {
mqtt.subscribe();
LAST_SUBSCRIBE = ConnectionConstants.getInst().getSubscribeTopic();
}
String publishTopic = ConnectionConstants.getInst().getPublishTopic();
String publishMessage = ConnectionConstants.getInst().getPublishMessage();
mqtt.publish(publishTopic, publishMessage);
S_LOGGER.info("#Publish topic: "+publishTopic+" #Publish message: "+publishMessage);
if (Status.getInst().isNewMessageReceived(LAST_MESSAGE_RECEIVED)) {
LAST_MESSAGE_RECEIVED = Status.getInst().getLastMessageReceived();
S_LOGGER.info("#Last message received: "+LAST_MESSAGE_RECEIVED);
if(Status.getInst().isConnected()) {
String publishTopic = ConnectionConstants.getInst().getPublishTopic();
String publishMessage = ConnectionConstants.getInst().getPublishMessage();
mqtt.publish(publishTopic, publishMessage);
S_LOGGER.info("#Publish topic: {} #Publish message: {}",publishTopic,publishMessage);
if (Status.getInst().isNewMessageReceived(LAST_MESSAGE_RECEIVED)) {
LAST_MESSAGE_RECEIVED = Status.getInst().getLastMessageReceived();
S_LOGGER.info("#Last message received: {}",LAST_MESSAGE_RECEIVED);
}
}
if(!Status.getInst().noError())S_LOGGER.error("##Error connetion!!");
}else {
if(Status.getInst().isConnected()) {
mqtt.disconnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public MqttConnectOptions createConnectionOptions() {
publishTopic = ConnectionConstants.getInst().getPublishTopic();
publishQos = ConnectionConstants.getInst().getPublishQos();
retained = ConnectionConstants.getInst().isRetained();
conOpt = ConnectionConstants.getInst().getConOpt();
conOpt = ConnectionConstants.getInst().updateConOpt();
// last will message
if ((!messageLWT.equals(Status.EMPTY)) || (!publishTopic.equals(Status.EMPTY))) {
conOpt.setWill(publishTopic, messageLWT.getBytes(), publishQos, retained);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,20 @@ public static synchronized ConnectionConstants getInst() {
public void setPublishMessage(String publishTopic) {this.PublishMessage = publishTopic;}

public MqttConnectOptions getConOpt() {return conOpt;}

public MqttConnectOptions updateConOpt(){
conOpt.setCleanSession(CleanSession);
conOpt.setConnectionTimeout(TimeOut);
conOpt.setKeepAliveInterval(KeepAlive);
conOpt.setUserName(Username);
conOpt.setPassword(Password.toCharArray());
return conOpt;
}

//Methods
private void InitConOpt(){
conOpt = new MqttConnectOptions();
conOpt.setCleanSession(CleanSession);
conOpt.setConnectionTimeout(TimeOut);
conOpt.setKeepAliveInterval(KeepAlive);
conOpt.setUserName(Username);
conOpt.setPassword(Password.toCharArray());
updateConOpt();
}
private void InitDefault(){
Uri = URI;
Expand Down

0 comments on commit 3b1027b

Please sign in to comment.