Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization, economy: flash:-112b; ram in realtime: -200b #378

Open
wants to merge 1 commit into
base: ver4dev
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions include/Const.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,29 @@ enum TimerTask_t {
WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK,
TIME,
TIME_SYNC,
UPTIME,
// TIME_SYNC, // не используется
// UPTIME, // не используется
UDP, // UDPP
TIMES, // периодические секундные проверки
PTASK,
ST,
END
};

// задачи которые надо протащить через loop
enum NotAsyncActions {
do_ZERO,
do_MQTTPARAMSCHANGED,
do_LAST,
};
// // задачи которые надо протащить через loop // не используется
// enum NotAsyncActions {
// do_ZERO,
// do_MQTTPARAMSCHANGED,
// do_LAST
// };

// состояния обновления
enum UpdateStates { UPDATE_COMPLETED, UPDATE_FAILED, PATH_ERROR };

enum distination {
TO_MQTT,
TO_WS,
TO_MQTT_WS,
TO_MQTT_WS
};

#define WS_BROADCAST -1
// #define WS_BROADCAST -1 // не используется
2 changes: 1 addition & 1 deletion include/ESPConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ extern std::list<IoTItem*> IoTItems; // вектор ссылок базово

extern void configure(String path);
void clearConfigure();
extern IoTItem* myIoTItem;
// extern IoTItem* myIoTItem; // экономим память, используется в одном месте
4 changes: 2 additions & 2 deletions include/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ bool publishChartFileToMqtt(String path, String id, int maxCount);
void publishWidgets();

void mqttCallback(char* topic, uint8_t* payload, size_t length);
void handleMqttStatus(bool send);
void handleMqttStatus(bool send, int state);
// void handleMqttStatus(bool send);
void handleMqttStatus(bool send, int state = -1);

const String getStateStr(int e);

Expand Down
1 change: 1 addition & 0 deletions src/ESPConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void configure(String path) {
SerialPrint(F("E"), F("Config"), "json error " + subtype);
continue;
} else {
IoTItem* myIoTItem;
//(IoTItem*) - getAPI вернула ссылку, что бы ее привести к классу IoTItem используем
myIoTItem = (IoTItem*)getAPI(subtype, jsonArrayElement);
if (myIoTItem) {
Expand Down
3 changes: 2 additions & 1 deletion src/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*****************************************глобальные объекты классов***************************************************
**********************************************************************************************************************/

TickerScheduler ts(END + 1);
// TickerScheduler ts(END + 1); // зачем на 1 больше?
TickerScheduler ts(END);
WiFiClient espClient;
PubSubClient mqtt(espClient);

Expand Down
15 changes: 9 additions & 6 deletions src/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,17 @@ bool publishChartFileToMqtt(String path, String id, int maxCount) {
return true;
}

void handleMqttStatus(bool send) {
String stateStr = getStateStr(mqtt.state());
// Serial.println(stateStr);
jsonWriteStr_(errorsHeapJson, F("mqtt"), stateStr);
if (!send) sendStringToWs("errors", errorsHeapJson, -1);
}
// void handleMqttStatus(bool send) {
// String stateStr = getStateStr(mqtt.state());
// // Serial.println(stateStr);
// jsonWriteStr_(errorsHeapJson, F("mqtt"), stateStr);
// if (!send) sendStringToWs("errors", errorsHeapJson, -1);
// }

void handleMqttStatus(bool send, int state) {
if (state == -1) {
state = mqtt.state();
}
String stateStr = getStateStr(state);
// Serial.println(stateStr);
jsonWriteStr_(errorsHeapJson, F("mqtt"), stateStr);
Expand Down
2 changes: 1 addition & 1 deletion src/classes/IoTItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ unsigned long IoTItem::getRtcUnixTime() {

//=========================================================================================================================================

IoTItem* myIoTItem;
// IoTItem* myIoTItem; // экономим память, используется в одном месте

// поиск элемента модуля в существующей конфигурации
IoTItem* findIoTItem(const String& name) {
Expand Down