Anpassung des "subription topics"

This commit is contained in:
JorBi 2020-10-16 10:17:31 +02:00
parent 3d50346a2e
commit b52f0b20ec

View File

@ -103,7 +103,7 @@ char broker[16] = "192.168.2.13"; // IP adresse of the MQTT br
char mqttUser[32] = "mqttuser"; // to access the the MQTT broker, if broker is configured that way char mqttUser[32] = "mqttuser"; // to access the the MQTT broker, if broker is configured that way
char mqttPass[32] = "mqttpassword"; // to access the the MQTT broker, if broker is configured that way char mqttPass[32] = "mqttpassword"; // to access the the MQTT broker, if broker is configured that way
char ReaderID[5] ; //= "000"; // identifyer for the reader. char ReaderID[5] ; //= "000"; // identifyer for the reader.
const char* subTopic = "/cmnd/reader"; // MQTT Topic where to find commands for the reader char subTopic[18] = "/cmnd/reader/"; // MQTT Topic where to find commands for the reader + ReaderID + 0x00
char ConType [3] = "0"; char ConType [3] = "0";
/* Configuration for access point mode -> can be anything you like*/ /* Configuration for access point mode -> can be anything you like*/
@ -559,8 +559,16 @@ void connect() {
Serial.println(MQTTclient.state()); Serial.println(MQTTclient.state());
} }
} }
byte topicLenght=sizeof(subTopic);
topicLenght=topicLenght-1;
for (int i=0; i<3 ;i++){
subTopic[(topicLenght-4)+i]=ReaderID[i];
}
subTopic[topicLenght]=0x00;
MQTTclient.subscribe(subTopic); MQTTclient.subscribe(subTopic);
Serial.println("connected!"); Serial.println(F("connected!"));
Serial.print(F("subscribed to topic: "));
Serial.println(subTopic);
StatusToDisplay(MQTT_RFID); StatusToDisplay(MQTT_RFID);
} }