Skip to content

Commit

Permalink
Update to Homie Convention v2.0.1 (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
timpur authored Mar 30, 2018
1 parent bfba03d commit 99161ce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
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) {
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

0 comments on commit 99161ce

Please sign in to comment.