mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-02 18:59:56 +00:00
Fix invalid heap reference fixed by @flux242
This commit is contained in:
parent
5f323e8bd1
commit
596befff74
@ -62,7 +62,8 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient)
|
||||
void MQTT::reconnect()
|
||||
{
|
||||
// pubSub.setServer("devsrv.ezdevice.net", 1883); or 192.168.10.188
|
||||
const char *serverAddr = "mqtt.meshtastic.org:1883"; // default hostname
|
||||
const char *serverAddr = "mqtt.meshtastic.org"; // default hostname
|
||||
int serverPort = 1883; // default server port
|
||||
|
||||
if (*radioConfig.preferences.mqtt_server)
|
||||
serverAddr = radioConfig.preferences.mqtt_server; // Override the default
|
||||
@ -70,15 +71,16 @@ void MQTT::reconnect()
|
||||
String server = String(serverAddr);
|
||||
int delimIndex = server.indexOf(':');
|
||||
if (delimIndex > 0) {
|
||||
String host = server.substring(0, delimIndex);
|
||||
String port = server.substring(delimIndex+1, server.length());
|
||||
pubSub.setServer(host.c_str(), port.toInt());
|
||||
server[delimIndex] = 0;
|
||||
serverPort = port.toInt();
|
||||
pubSub.setServer(server.c_str(), serverPort);
|
||||
}
|
||||
else {
|
||||
pubSub.setServer(serverAddr, 1883);
|
||||
pubSub.setServer(serverAddr, serverPort);
|
||||
}
|
||||
|
||||
DEBUG_MSG("Connecting to MQTT server\n", serverAddr);
|
||||
DEBUG_MSG("Connecting to MQTT server %s, port: %d\n", server.c_str(), serverPort);
|
||||
auto myStatus = (statusTopic + owner.id);
|
||||
bool connected = pubSub.connect(owner.id, "meshdev", "large4cats", myStatus.c_str(), 1, true, "offline");
|
||||
if (connected) {
|
||||
|
Loading…
Reference in New Issue
Block a user