How do I save my MQTT Client user name and key as variables, instead to placing them as "#define" preprocessor. Has anyone done this? I have tried making the declaration as pointer but it keeps crashing.
Adafruit_MQTT_Client *mqtt = NULL;
mqtt = new Adafruit_MQTT_Client(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME1, AIO_KEY1);
This above method crashes when I publish, seems like I have to modulate the WiFiclient along with MQTT.
Is there a simpler solution for this? Would moving to rest api (io) solve this problem?
The motivation to store the keys as variables is so that I can encrypt them and save them in a private location.
I am using a Huzzah ESP8266 Board.
Has anyone got MQTT to work without using #define keys
Moderators: adafruit_support_bill, adafruit
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- niyer
- Posts: 2
- Joined: Mon Feb 07, 2022 1:42 am
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Has anyone got MQTT to work without using #define keys
you may want to take a look at this sketch for using a WiFiManager to dynamically set the parameters, https://github.com/adafruit/Adafruit_IO ... meters.ino
- niyer
- Posts: 2
- Joined: Mon Feb 07, 2022 1:42 am
Re: Has anyone got MQTT to work without using #define keys
Thank you, brubell. Yep I ended up going with "io".
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.