m5stack / ATOM-PRINTER

M5Stack ATOM PRINTER firmware and examples
MIT License
18 stars 4 forks source link

Not retrieving messages. #9

Closed Ajb2k3 closed 1 year ago

Ajb2k3 commented 1 year ago

Thanks, its now connecting to the MQTT topic but not retrieving messages from the server.

Gitshaoxiang commented 1 year ago

did you use the mac address for the publish topic?

Ajb2k3 commented 1 year ago

No because my server uses home_sensor_data for its topic That a Core2, CM4 and M5Paper use for communication.

This is my config.h file


#ifndef _ATOM_PRINTER_CONFIG_H
#define _ATOM_PRINTER_CONFIG_H

#define DNS_PORT 53
#define BMP_BUFFER_LIMIT 1024 * 50
#define MQTT_BROKER "192.168.0.44"
#define MQTT_PORT 1883
#define MQTT_ID "printer"
#define MQTT_USER "AdamBryant"
#define MQTT_PASSPWD "**********"
#define MQTT_TOPIC "home_sensor_data"

typedef enum {
    kInit = 0,
    kWiFiConnected,
    kWiFiDisconnected,
    kMQTTConnected,
    kMQTTDisconnected,
} Atom_Printer_State_t;

#endif
Gitshaoxiang commented 1 year ago

refer to this part. if you have not set the mqtt info by the web page. it will use the mac addr for sub-topic. so you could modify this part directly

https://github.com/m5stack/ATOM-PRINTER/blob/master/examples/PRINTER_FW/ATOM_PRINTER_MQTT.cpp#L27

Ajb2k3 commented 1 year ago

I changed it on the page and the config file, will try that line next.

Gitshaoxiang commented 1 year ago

yes, that is our mistake. it actually does not use the config file define. we will update it later

Ajb2k3 commented 1 year ago

OK, so how do I fix this line?

Gitshaoxiang commented 1 year ago

already update. now you could use the config file to setting the topic

Ajb2k3 commented 1 year ago

nope, still defaulting to the MAC address

Ajb2k3 commented 1 year ago

I changed the line to:

    if (mqtt_topic == "") {
        mqtt_topic = ("_mqtt_topic" + String(random(65536)));
    }

it briefly worked in the serial console then reset back to default.

Gitshaoxiang commented 1 year ago

image image

ok. updated