mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 23:46:37 +02:00
Merge branch 'main' of https://github.com/grindylow/ahoy
This commit is contained in:
commit
c35c86210f
8 changed files with 125 additions and 14 deletions
|
@ -27,6 +27,7 @@ class mqtt {
|
|||
DPRINTLN(DBG_VERBOSE, F("mqtt.h:setup"));
|
||||
mAddressSet = true;
|
||||
mClient->setServer(broker, port);
|
||||
mClient->setBufferSize(MQTT_MAX_PACKET_SIZE);
|
||||
|
||||
mPort = port;
|
||||
snprintf(mUser, MQTT_USER_LEN, "%s", user);
|
||||
|
@ -36,14 +37,17 @@ class mqtt {
|
|||
|
||||
void sendMsg(const char *topic, const char *msg) {
|
||||
//DPRINTLN(DBG_VERBOSE, F("mqtt.h:sendMsg"));
|
||||
if(mAddressSet) {
|
||||
char top[64];
|
||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||
char top[64];
|
||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||
sendMsg2(top, msg);
|
||||
}
|
||||
|
||||
void sendMsg2(const char *topic, const char *msg) {
|
||||
if(mAddressSet) {
|
||||
if(!mClient->connected())
|
||||
reconnect();
|
||||
if(mClient->connected())
|
||||
mClient->publish(top, msg);
|
||||
mClient->publish(topic, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue