mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Implement mqttEnabled
This commit is contained in:
parent
7983e8a0d7
commit
076c1f1b4d
@ -203,6 +203,8 @@ void mqtt_subscribe(void* context, const char* topic)
|
||||
|
||||
int mqttPublish(const char* topic, const char* payload, size_t len, bool retain)
|
||||
{
|
||||
if(!mqttEnabled) return MQTT_ERR_DISABLED;
|
||||
|
||||
if(!mqttIsConnected()) {
|
||||
mqttFailedCount++;
|
||||
return MQTT_ERR_NO_CONN;
|
||||
@ -311,7 +313,9 @@ void mqttStart()
|
||||
// }
|
||||
|
||||
printf("%s %d\n", __FILE__, __LINE__);
|
||||
if(mqttServer.length() > 0) {
|
||||
mqttEnabled = strlen(mqttServer) > 0 && mqttPort > 0;
|
||||
|
||||
if(mqttEnabled) {
|
||||
conn_opts.will = &will_opts;
|
||||
conn_opts.will->message = "offline";
|
||||
conn_opts.will->qos = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user