mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-25 05:46:59 +02:00
* send values using mqtt
* only send command 0x80 to inverter, all replies 0x01, 0x02, 0x03 and 0x84 are received
This commit is contained in:
parent
c00be7bb35
commit
58d79beb8c
3 changed files with 52 additions and 14 deletions
|
@ -31,9 +31,8 @@ class mqtt {
|
|||
|
||||
void sendMsg(const char *topic, const char *msg) {
|
||||
if(mAddressSet) {
|
||||
uint8_t len = MQTT_TOPIC_LEN + strlen(msg);
|
||||
char top[len];
|
||||
snprintf(top, len, "%s/%s", mTopic, topic);
|
||||
char top[64];
|
||||
snprintf(top, 64, "%s/%s", mTopic, topic);
|
||||
|
||||
if(!mClient->connected())
|
||||
reconnect();
|
||||
|
@ -69,12 +68,10 @@ class mqtt {
|
|||
void reconnect(void) {
|
||||
if(!mClient->connected()) {
|
||||
String mqttId = "ESP-" + String(random(0xffff), HEX);
|
||||
if((strlen(mUser) > 0) && (strlen(mPwd) > 0)) {
|
||||
if((strlen(mUser) > 0) && (strlen(mPwd) > 0))
|
||||
mClient->connect(mqttId.c_str(), mUser, mPwd);
|
||||
}
|
||||
else {
|
||||
else
|
||||
mClient->connect(mqttId.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue