Compare commits

..

No commits in common. "00576355ffe339b2d85792350fd042149e70fdbe" and "3347c4d097440b503bbaebbe83627d4ef8937d76" have entirely different histories.

2 changed files with 13 additions and 16 deletions

View File

@ -2,7 +2,6 @@
platform = espressif8266
board = esp12e
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
board_build.filesystem = littlefs
board_build.ldscript = eagle.flash.4m1m.ld
lib_deps =
@ -15,7 +14,6 @@ lib_deps =
platform = espressif8266
board = esp12e
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
board_build.filesystem = littlefs
board_build.ldscript = eagle.flash.4m1m.ld
upload_port = 192.168.4.1

View File

@ -31,20 +31,20 @@ typedef struct
std::vector<espnow_message_t> espnowMessage;
const String firmware{"1.2"};
const String firmware{"1.15"};
String espnowNetName{"DEFAULT"};
String deviceName = "ESP-NOW light " + String(ESP.getChipId(), HEX);
uint8_t ledType{ENLT_NONE};
bool ledStatus{false};
uint8_t coldWhitePin{0};
uint8_t warmWhitePin{0};
uint8_t redPin{0};
uint8_t greenPin{0};
uint8_t bluePin{0};
bool ledStatus{false};
uint8_t brightness{255};
uint16_t temperature{255};
uint8_t red{255};
@ -55,6 +55,9 @@ bool wasMqttAvailable{false};
uint8_t gatewayMAC[6]{0};
const String payloadOn{"ON"};
const String payloadOff{"OFF"};
ZHNetwork myNet;
AsyncWebServer webServer(80);
@ -170,7 +173,7 @@ void onUnicastReceiving(const char *data, const uint8_t *sender)
{
deserializeJson(json, incomingData.message);
if (json["set"])
ledStatus = json["set"] == "ON" ? true : false;
ledStatus = json["set"] == payloadOn ? true : false;
if (json["brightness"])
brightness = json["brightness"];
if (json["temperature"])
@ -214,7 +217,6 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
void loadConfig()
{
ETS_GPIO_INTR_DISABLE();
if (!LittleFS.exists("/config.json"))
saveConfig();
File file = LittleFS.open("/config.json", "r");
@ -236,13 +238,10 @@ void loadConfig()
green = json["green"];
blue = json["blue"];
file.close();
delay(50);
ETS_GPIO_INTR_ENABLE();
}
void saveConfig()
{
ETS_GPIO_INTR_DISABLE();
StaticJsonDocument<512> json;
json["firmware"] = firmware;
json["espnowNetName"] = espnowNetName;
@ -263,8 +262,6 @@ void saveConfig()
File file = LittleFS.open("/config.json", "w");
serializeJsonPretty(json, file);
file.close();
delay(50);
ETS_GPIO_INTR_ENABLE();
}
void setupWebServer()
@ -347,10 +344,12 @@ void sendConfigMessage()
esp_now_payload_data_t outgoingData{ENDT_LED, ENPT_CONFIG};
espnow_message_t message;
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
json[MCMT_DEVICE_NAME] = deviceName;
json[MCMT_DEVICE_UNIT] = 1;
json[MCMT_COMPONENT_TYPE] = HACT_LIGHT;
json[MCMT_DEVICE_CLASS] = ledType;
json["name"] = deviceName;
json["unit"] = 1;
json["type"] = HACT_LIGHT;
json["class"] = ledType;
json["payload_on"] = payloadOn;
json["payload_off"] = payloadOff;
serializeJsonPretty(json, outgoingData.message);
memcpy(&message.message, &outgoingData, sizeof(esp_now_payload_data_t));
message.id = myNet.sendUnicastMessage(message.message, gatewayMAC, true);
@ -366,7 +365,7 @@ void sendStatusMessage()
esp_now_payload_data_t outgoingData{ENDT_LED, ENPT_STATE};
espnow_message_t message;
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
json["state"] = ledStatus ? "ON" : "OFF";
json["state"] = ledStatus ? payloadOn : payloadOff;
json["brightness"] = brightness;
json["temperature"] = temperature;
json["rgb"] = String(red) + "," + String(green) + "," + String(blue);