refactor: rename report_topic to topic and update MQTT subscription logic, switched publish topic to request
This commit is contained in:
parent
68cdd8ab40
commit
9dfe75ffa2
@ -17,7 +17,7 @@ PubSubClient client(sslClient);
|
|||||||
|
|
||||||
TaskHandle_t BambuMqttTask;
|
TaskHandle_t BambuMqttTask;
|
||||||
|
|
||||||
String report_topic = "";
|
String topic = "";
|
||||||
//String request_topic = "";
|
//String request_topic = "";
|
||||||
const char* bambu_username = "bblp";
|
const char* bambu_username = "bblp";
|
||||||
const char* bambu_ip = nullptr;
|
const char* bambu_ip = nullptr;
|
||||||
@ -91,7 +91,7 @@ bool loadBambuCredentials() {
|
|||||||
bambu_accesscode = g_bambu_accesscode.c_str();
|
bambu_accesscode = g_bambu_accesscode.c_str();
|
||||||
bambu_serialnr = g_bambu_serialnr.c_str();
|
bambu_serialnr = g_bambu_serialnr.c_str();
|
||||||
|
|
||||||
report_topic = "device/" + String(bambu_serialnr) + "/report";
|
topic = "device/" + String(bambu_serialnr);
|
||||||
//request_topic = "device/" + String(bambu_serialnr) + "/request";
|
//request_topic = "device/" + String(bambu_serialnr) + "/request";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ FilamentResult findFilamentIdx(String brand, String type) {
|
|||||||
bool sendMqttMessage(const String& payload) {
|
bool sendMqttMessage(const String& payload) {
|
||||||
Serial.println("Sending MQTT message");
|
Serial.println("Sending MQTT message");
|
||||||
Serial.println(payload);
|
Serial.println(payload);
|
||||||
if (client.publish(report_topic.c_str(), payload.c_str()))
|
if (client.publish((String(topic) + "/request").c_str(), payload.c_str()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -557,7 +557,7 @@ void reconnect() {
|
|||||||
if (client.connect(clientId.c_str(), bambu_username, bambu_accesscode)) {
|
if (client.connect(clientId.c_str(), bambu_username, bambu_accesscode)) {
|
||||||
Serial.println("MQTT re/connected");
|
Serial.println("MQTT re/connected");
|
||||||
|
|
||||||
client.subscribe(report_topic.c_str());
|
client.subscribe((String(topic) + "/report").c_str());
|
||||||
bambu_connected = true;
|
bambu_connected = true;
|
||||||
oledShowTopRow();
|
oledShowTopRow();
|
||||||
} else {
|
} else {
|
||||||
@ -625,7 +625,7 @@ bool setupMqtt() {
|
|||||||
{
|
{
|
||||||
client.setCallback(mqtt_callback);
|
client.setCallback(mqtt_callback);
|
||||||
client.setBufferSize(5120);
|
client.setBufferSize(5120);
|
||||||
client.subscribe(report_topic.c_str());
|
client.subscribe((String(topic) + "/report").c_str());
|
||||||
//client.subscribe(request_topic.c_str());
|
//client.subscribe(request_topic.c_str());
|
||||||
Serial.println("MQTT-Client initialisiert");
|
Serial.println("MQTT-Client initialisiert");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user