@@ -43,6 +43,7 @@ export class MqttClientComponent implements OnInit {
43
43
focussedMessage = new ShowedMessage ( '' , '' )
44
44
proto : ProtoInfo = new ProtoInfo ( '' , '' , '' , '' )
45
45
currentIndex : number
46
+ publishingTopic : string
46
47
publishingMessage : string
47
48
publishingQos : number
48
49
mqttConfig = 'mqttConfig.json'
@@ -440,7 +441,7 @@ export class MqttClientComponent implements OnInit {
440
441
const payload = myMessage . create ( JSON . parse ( self . publishingMessage ) )
441
442
const str = myMessage . encode ( payload ) . finish ( )
442
443
console . log ( str . join ( ' ,' ) )
443
- client . publish ( self . subscribeTo . topics [ 0 ] , str , self . publishingQos ? self . publishingQos : '0' )
444
+ client . publish ( self . publishingTopic , str , self . publishingQos ? self . publishingQos : '0' )
444
445
self . showSnackBar ( 'Message published on MQTT.' )
445
446
}
446
447
} )
@@ -451,7 +452,7 @@ export class MqttClientComponent implements OnInit {
451
452
// ======================================================================= //
452
453
453
454
publishHex ( ) {
454
- client . publish ( this . subscribeTo . topics [ 0 ] , this . fromHexToString ( this . publishingMessage ) , this . publishingQos ? this . publishingQos : '0' )
455
+ client . publish ( this . publishingTopic , this . fromHexToString ( this . publishingMessage ) , this . publishingQos ? this . publishingQos : '0' )
455
456
this . showSnackBar ( 'Message published on MQTT.' )
456
457
}
457
458
@@ -460,7 +461,7 @@ export class MqttClientComponent implements OnInit {
460
461
// ======================================================================= //
461
462
462
463
publishString ( ) {
463
- client . publish ( this . subscribeTo . topics [ 0 ] , this . publishingMessage , this . publishingQos ? this . publishingQos : '0' )
464
+ client . publish ( this . publishingTopic , this . publishingMessage , this . publishingQos ? this . publishingQos : '0' )
464
465
this . showSnackBar ( 'Message published on MQTT.' )
465
466
}
466
467
@@ -532,6 +533,7 @@ export class MqttClientComponent implements OnInit {
532
533
storage . get ( dataPath + this . topicFile )
533
534
. then ( data => {
534
535
this . subscribeTo . topics = data . topics
536
+ this . publishingTopic = data . topics
535
537
this . cd . detectChanges ( )
536
538
} )
537
539
. catch ( err => {
@@ -552,7 +554,7 @@ export class MqttClientComponent implements OnInit {
552
554
console . error ( err )
553
555
} )
554
556
}
555
- } )
557
+ } )
556
558
557
559
this . configurationForm = this . _formBuilder . group ( {
558
560
mqttBrokerAddress : this . _formBuilder . control ,
0 commit comments