-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Connection failed #160
Comments
In the Adafruit_MQTT.h header file, could you please uncomment MQTT_DEBUG. |
I have an idea what you need to save into/load from eeprom in my point of view is see the source code in https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/examples/mqtt_esp8266/mqtt_esp8266.ino in declarative part Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT); in setup() //retreive username and key from eeprom usern = String(username); const char *usernew = usern.c_str(); next to make feeds become changeable on setup() u need to add method on Adafruit_MQTT.h and Adafruit_MQTT.cpp class Adafruit_MQTT_Subscribe { open cpp now in your setup() before mqtt.connect(usernew, keynew); you can do same with subscribe for publish part. let's make apps with more flexible |
You are misunderstanding how to use heap. You instantiate GLB_MQTTClient, GLB_MQTT_Publish, GLB_MQTT_Subcribe twice on a heap, and so you have small memory leak, you lost pointers to classes instatiated in declarative section. For the first declare only a pointers and then instantiate an object in a initNormalConnection(). code excerpt: `WiFiClientSecure GLB_secureClient; void initNormalConnection() GLB_secureClient = WiFiClientSecure(); GLB_MQTTClient = new Adafruit_MQTT_Client(&GLB_secureClient, BROKER_HOST, BROKER_PORT); ...` |
Adafruit_MQTT library is awesome but i have got a problem with it.
I use it in Arduino with NodeMCU (ESP8266).
Everything is okey with example code. (TLS connection).
Everything is also ok when i put topic direct value: "sometopic/abc/adbc" to input param.
But My program has to check some configs to get MQTT topic from EEPROM so it can't assign TOPIC when initialize variable at head of file.
So i created new pointer for new value.
I got Connection failed when i use
This is my basic code:
Variable's addresses was changed.
The output of the address:
What could be the problem?
The text was updated successfully, but these errors were encountered: