mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-17 10:43:24 +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()
|
void MQTT::reconnect()
|
||||||
{
|
{
|
||||||
// pubSub.setServer("devsrv.ezdevice.net", 1883); or 192.168.10.188
|
// 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)
|
if (*radioConfig.preferences.mqtt_server)
|
||||||
serverAddr = radioConfig.preferences.mqtt_server; // Override the default
|
serverAddr = radioConfig.preferences.mqtt_server; // Override the default
|
||||||
@ -70,15 +71,16 @@ void MQTT::reconnect()
|
|||||||
String server = String(serverAddr);
|
String server = String(serverAddr);
|
||||||
int delimIndex = server.indexOf(':');
|
int delimIndex = server.indexOf(':');
|
||||||
if (delimIndex > 0) {
|
if (delimIndex > 0) {
|
||||||
String host = server.substring(0, delimIndex);
|
|
||||||
String port = server.substring(delimIndex+1, server.length());
|
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 {
|
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);
|
auto myStatus = (statusTopic + owner.id);
|
||||||
bool connected = pubSub.connect(owner.id, "meshdev", "large4cats", myStatus.c_str(), 1, true, "offline");
|
bool connected = pubSub.connect(owner.id, "meshdev", "large4cats", myStatus.c_str(), 1, true, "offline");
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
Loading…
Reference in New Issue
Block a user