Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Homie for ESP8266

An Arduino for ESP8266 implementation of [Homie](https://github.com/marvinroger/homie), an MQTT convention for the IoT.

Currently Homie for ESP8266 implements [Homie 2.0.0](https://github.com/marvinroger/homie/releases/tag/v2.0.0)
Currently Homie for ESP8266 implements [Homie 2.0.1](https://github.com/marvinroger/homie/releases/tag/v2.0.1)

## Note for v1.x users

Expand Down
2 changes: 1 addition & 1 deletion src/Homie/Boot/BootConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void BootConfig::_onDeviceInfoRequest(AsyncWebServerRequest *request) {
for (IHomieSetting* iSetting : IHomieSetting::settings) {
JsonObject& jsonSetting = jsonBuffer.createObject();

if (String(iSetting->getType()) != "unknown") {
if (strcmp(iSetting->getType(), "unknown") != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why strcmp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the core of the lib, we should try avoid using String. String will copy the chars into dynamic memory even for something as simple as this... Using String everywhere can lead to heep fragmentation.

jsonSetting["name"] = iSetting->getName();
jsonSetting["description"] = iSetting->getDescription();
jsonSetting["type"] = iSetting->getType();
Expand Down
20 changes: 16 additions & 4 deletions src/Homie/Boot/BootNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ void BootNormal::_advertise() {
switch (_advertisementProgress.globalStep) {
case AdvertisementProgress::GlobalStep::PUB_HOMIE:
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$homie")), 1, true, HOMIE_VERSION);
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_MAC;
break;
case AdvertisementProgress::GlobalStep::PUB_MAC:
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$mac")), 1, true, WiFi.macAddress().c_str());
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_NAME;
break;
case AdvertisementProgress::GlobalStep::PUB_NAME:
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$name")), 1, true, Interface::get().getConfig().get().name);
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_MAC;
break;
case AdvertisementProgress::GlobalStep::PUB_MAC:
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$mac")), 1, true, WiFi.macAddress().c_str());
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_LOCALIP;
break;
case AdvertisementProgress::GlobalStep::PUB_LOCALIP:
Expand All @@ -339,6 +339,18 @@ void BootNormal::_advertise() {
char localIpStr[MAX_IP_STRING_LENGTH];
Helpers::ipToString(localIp, localIpStr);
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$localip")), 1, true, localIpStr);
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_NODES_ATTR;
break;
}
case AdvertisementProgress::GlobalStep::PUB_NODES_ATTR:
{
String nodes;
for (HomieNode* node : HomieNode::nodes) {
nodes.concat(node->getId());
nodes.concat(F(","));
}
if (HomieNode::nodes.size() >= 1) nodes.remove(nodes.length() - 1);
packetId = Interface::get().getMqttClient().publish(_prefixMqttTopic(PSTR("/$nodes")), 1, true, nodes.c_str());
if (packetId != 0) _advertisementProgress.globalStep = AdvertisementProgress::GlobalStep::PUB_STATS_INTERVAL;
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Homie/Boot/BootNormal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class BootNormal : public Boot {
bool done = false;
enum class GlobalStep {
PUB_HOMIE,
PUB_MAC,
PUB_NAME,
PUB_MAC,
PUB_LOCALIP,
PUB_NODES_ATTR,
PUB_STATS_INTERVAL,
PUB_FW_NAME,
PUB_FW_VERSION,
Expand Down
2 changes: 1 addition & 1 deletion src/Homie/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <ESP8266WiFi.h>

namespace HomieInternals {
const char HOMIE_VERSION[] = "2.0.0";
const char HOMIE_VERSION[] = "2.0.1";
const char HOMIE_ESP8266_VERSION[] = "2.0.0";

const IPAddress ACCESS_POINT_IP(192, 168, 123, 1);
Expand Down