Move F() macro to constant usage

Add some warning in the comments above the constants so that people can be aware of the risks when changing this value.
This commit is contained in:
Christophe Gagnier 2023-10-14 16:34:56 -04:00
parent 426417a5c8
commit 37f0ae01ec
5 changed files with 17 additions and 13 deletions

View File

@ -98,8 +98,8 @@ private:
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("identifiers")] = "wled-sensor-" + String(mqttClientID);
device[F("manufacturer")] = WLED_BRAND;
device[F("model")] = WLED_PRODUCT_NAME;
device[F("manufacturer")] = F(WLED_BRAND);
device[F("model")] = F(WLED_PRODUCT_NAME);
device[F("sw_version")] = versionString;
String temp;

View File

@ -160,8 +160,8 @@ private:
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("identifiers")] = "wled-sensor-" + String(mqttClientID);
device[F("manufacturer")] = WLED_BRAND;
device[F("model")] = WLED_PRODUCT_NAME;
device[F("manufacturer")] = F(WLED_BRAND);
device[F("model")] = F(WLED_PRODUCT_NAME);
device[F("sw_version")] = versionString;
String temp;

View File

@ -299,8 +299,8 @@ void PIRsensorSwitch::publishHomeAssistantAutodiscovery()
JsonObject device = doc.createNestedObject(F("device")); // attach the sensor to the same device
device[F("name")] = serverDescription;
device[F("ids")] = String(F("wled-sensor-")) + mqttClientID;
device[F("mf")] = WLED_BRAND;
device[F("mdl")] = WLED_PRODUCT_NAME;
device[F("mf")] = F(WLED_BRAND);
device[F("mdl")] = F(WLED_PRODUCT_NAME);
device[F("sw")] = versionString;
sprintf_P(buf, PSTR("homeassistant/binary_sensor/%s/config"), uid);

View File

@ -785,8 +785,8 @@ void serializeInfo(JsonObject root)
#endif
root[F("opt")] = os;
root[F("brand")] = WLED_BRAND;
root[F("product")] = WLED_PRODUCT_NAME;
root[F("brand")] = F(WLED_BRAND);
root[F("product")] = F(WLED_PRODUCT_NAME);
root["mac"] = escapedMac;
char s[16] = "";
if (Network.isConnected())

View File

@ -12,15 +12,19 @@
// You can define custom product info from build flags.
// This is useful to allow API consumer to identify what type of WLED version
// they are interacting with.
// they are interacting with. Be aware that changing this might cause some third
// party API consumers to consider this as a non-WLED device since the values
// returned by the API and by MQTT will no longer be default. However, most
// third party only uses mDNS to validate, so this is generally fine to change.
// For example, Home Assistant will still work fine even with this value changed.
// Use like this:
// -D WLED_BRAND="F(\"Custom Brand\")"
// -D WLED_PRODUCT_NAME="F(\"Custom Product\")"
// -D WLED_BRAND="\"Custom Brand\""
// -D WLED_PRODUCT_NAME="\"Custom Product\""
#ifndef WLED_BRAND
#define WLED_BRAND F("WLED")
#define WLED_BRAND "WLED"
#endif
#ifndef WLED_PRODUCT_NAME
#define WLED_PRODUCT_NAME F("FOSS")
#define WLED_PRODUCT_NAME "FOSS"
#endif
//uncomment this if you have a "my_config.h" file you'd like to use