This library contains various stuffs/helpers to Arduino like developments.
IMPORTANT NOTE : It is MANDATORY to include the fake file #include <LFUtilities.h>
in your project otherwise Arduino IDE will not find other includes.
#include <LFUtilities/Duration.h>
Abstracts duration measurement.
Duration( void )
orvoid reInit( void )
- Starts a duration measurement.unsigned long int Finished( void )
- End of measurement, return the duration in milliseconds.unsigned long int operator *( void )
- return the duration in milliseconds, up to theFini()
call or till now.
#include <LFUtilities/SafeMQTTClient.h>
MQTT's client with automatic reconnect facilities.
Notez-bien : if SERIAL_ENABLED
is defined, some debug messages are output to the serial tx.
-
SafeMQTTClient(
Client &client
- Network clientconst char *ssid, const char *pwd
- WiFi's SSID and passwordconst char *bURL, int bport
- MQTT broker URL and portconst char *clientID
- MQTT clientIDconst char *logtopic = NULL
- Root of the logging topics (if not set, no logging is done)bool clear_session = false
- Among other things, with clean session set, it's not possible to receive asynchonously messages.)
- Constructor
-
bool connectWiFi( Duration *duration = NULL, uint32_t maxtries=SMC_WIFI_MAX_RETRY )
- Connect to the WiFi network (implies connection to MQTT as well). -
bool connectMQTT( Duration *duration = NULL )
- Connect to the MQTT broker (normaly, there is no need to call it directly) -
bool connected( void )
- Are we connected to the broker ? -
void setMQTTMaxTries( uint32_t val )
- For how long are we trying to connect to the broker (seconds) -
uint32_t getMQTTMaxTries( void )
-
void publish(
String &topic,
- Topic to publish toconst char *msg
orconst uint32_t val
- what to publishbool reconnect=true
- reconnect if the network is lost)
-
void logMsg( const char *msg, bool reconnect=true )
- publish a message
- topic/Message - Log messages
- topic/WiFi - WiFi connection duration
- topic/MQTT - MQTT connection duration