|
@@ -22,6 +22,7 @@ export struct HomeView {
|
|
|
private mqttAsyncClient: MqttClient | null = null;
|
|
|
// Set Client Configuration
|
|
|
@State subscribeTopic: string = BusinessConstant.mqttSubscribeTopic;
|
|
|
+ @State subscribeTopic2: string = BusinessConstant.mqttSubscribeTopic2;
|
|
|
@State publishTopic: string = BusinessConstant.mqttPublishTopic;
|
|
|
@State payload: string = '';
|
|
|
@State url: string = BusinessConstant.mqttUrl;
|
|
@@ -1112,6 +1113,30 @@ export struct HomeView {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ if (this.subscribeTopic === this.subscribeTopic2) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let subscribeOption2: MqttSubscribeOptions = {
|
|
|
+ topic: this.subscribeTopic2,
|
|
|
+ qos: 2
|
|
|
+ }
|
|
|
+ if (await this.isConnected()) {
|
|
|
+ if (this.isPromise) {
|
|
|
+ this.mqttAsyncClient.subscribe(subscribeOption2).then((data: MqttResponse) => {
|
|
|
+ console.info('hhtest', "subscribe success result:" + JSON.stringify(data));
|
|
|
+ }).catch((err: MqttResponse) => {
|
|
|
+ console.info('hhtest', "subscribe fail result:" + JSON.stringify(err));
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.mqttAsyncClient.subscribe(subscribeOption2, (err: Error, data: MqttResponse) => {
|
|
|
+ if (!err) {
|
|
|
+ console.info('hhtest', "subscribe result:" + JSON.stringify(data));
|
|
|
+ } else {
|
|
|
+ console.info('hhtest', "subscribe error:" + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
messageArrived(): undefined | void {
|
|
@@ -1124,7 +1149,7 @@ export struct HomeView {
|
|
|
// this.showLog(msg);
|
|
|
let dataStr = JSON.stringify(data);
|
|
|
console.info('hhtest', "messageArrived message:" + dataStr);
|
|
|
- if (dataStr.indexOf('Assemble_500W') !== -1) {
|
|
|
+ if (dataStr.indexOf(this.subscribeTopic2) === -1) {
|
|
|
return
|
|
|
}
|
|
|
let updateData: MqttUploadData = JSON.parse(data.payload) as MqttUploadData;
|