add comments

This commit is contained in:
Dawid Chyrzynski
2020-11-28 22:18:33 +01:00
parent adf798363b
commit 2e1386a232
2 changed files with 29 additions and 0 deletions
+5
View File
@@ -114,6 +114,11 @@ void HAMqtt::loop()
}
}
bool HAMqtt::isConnected()
{
return _mqtt->connected();
}
void HAMqtt::connectToServer()
{
if (_lastConnectionAttemptAt > 0 &&
+24
View File
@@ -15,14 +15,38 @@ public:
HAMqtt(Client& netClient);
HAMqtt(Client& netClient, HADevice& device);
/**
* Sets parameters of the connection to the MQTT broker.
* The library will try to connect to the broker in first loop cycle.
* Please note that the library automatically reconnects to the broker if connection is lost.
*
* @param serverIp IP address of the MQTT broker.
* @param serverPort Port of the MQTT broker.
* @param username Username for authentication.
* @param password Password for authentication.
*/
bool begin(
const IPAddress& serverIp,
const uint16_t& serverPort,
const char* username = nullptr,
const char* password = nullptr
);
/**
* ArduinoHA's ticker.
*/
void loop();
/**
* Returns true if connection to the MQTT broker is established.
*/
bool isConnected();
/**
* Sets prefix for Home Assistant discovery.
* It needs to match prefix set in the HA admin panel.
* The default prefix is "homeassistant".
*/
inline void setDiscoveryPrefix(const char* prefix)
{ _discoveryPrefix = prefix; }