diff --git a/src/MQTT_Reader06.ino b/src/MQTT_Reader06.ino index 2b538ec..94a87e6 100644 --- a/src/MQTT_Reader06.ino +++ b/src/MQTT_Reader06.ino @@ -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 mqttPass[32] = "mqttpassword"; // to access the the MQTT broker, if broker is configured that way 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"; /* Configuration for access point mode -> can be anything you like*/ @@ -559,8 +559,16 @@ void connect() { 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); - Serial.println("connected!"); + Serial.println(F("connected!")); + Serial.print(F("subscribed to topic: ")); + Serial.println(subTopic); StatusToDisplay(MQTT_RFID); }