Difference between revisions of "ESPEasyDevelopment"
Line 35: | Line 35: | ||
In most cases you don't need a custom config, but the framework provides these system calls to easy things if you need it: | In most cases you don't need a custom config, but the framework provides these system calls to easy things if you need it: | ||
− | To load/save data structures from/into flash: | + | To load/save data structures from/into flash when using a device plugin: |
− | LoadCustomTaskSettings(event->TaskIndex, (byte*)& | + | LoadCustomTaskSettings(event->TaskIndex, (byte*)&customConfig, sizeof(customConfig)); |
− | SaveCustomTaskSettings(event->TaskIndex, (byte*)& | + | SaveCustomTaskSettings(event->TaskIndex, (byte*)&customConfig, sizeof(customConfig)); |
+ | |||
+ | To load/save data structures from/into flash when using a controller plugin: | ||
+ | |||
+ | LoadCustomControllerSettings((byte*)&customConfig, sizeof(customConfig)); | ||
+ | SaveCustomControllerSettings((byte*)&customConfig, sizeof(customConfig)); | ||
+ | |||
+ | In these samples, the 'customConfig' is a data structure that can hold a collection of variables. |
Revision as of 15:39, 11 August 2016
You may hear some construction noise in the background...
Welcome to the developers documentation page!
To aid in contributions to the project, it may come in handy to have some background information. Still very limited, but we have to start somewhere (and we did not start from the beginning...)
General concept
ESP Easy is build upon the Arduino ESP8266 core (check out on https://github.com/esp8266). This code package provides the Arduino way of working on an ESP8266 module with many ported libraries.
ESP Easy consists of a framework that provides basic functionality and a collection of controller and device plugins. Controller plugins (_Cxxxx files) provide communication to Home Automation platform like Domoticz, OpenHAB, etc. Device plugins (_Pxxx files) provide communication to a wide collection of sensor devices and some actuators. Because ESP Easy was designed as a "wireless multi-sensor" project, the actuator part is limited.
Configuration storage
The project needs to store it's configuration and this will be done in the on board flash memory chip. In the beginning we have used the emulated EEPROM but we have abandoned that because of it's limitations and permanent RAM usage. We moved over to SPIFFS but that also introduced a rather large decrease of available RAM. So we moved over to reading/writing directly to flash memory. For convenience, we use the same area that is normally reserved for SPIFFS, so we don't have to worry about locating a suitable area. This also means that we can't use SPIFFS and compiling without reservation for SPIFFS wont work with ESP Easy.
With a minimum of 64k SPIFFS reservation and the available emulated EEPROM area, we have a total of 17 sectors available, 4k each.
This is our current layout:
Sector 0 Global settings struct Sector 1-3 Task settings (1kB per task, first 512 bytes for system, 512 remaining can be used for custom task config) Sector 4-6 Reserved for future expansion for Task settings Sector 7 Custom controller config Sector 8 Security settings Sector 9 CSS config Sector 10 Rules Sector 11-16 future use
When saving the configuration, sectors 0-7 (32k) are saved to file. This is because sector 8 contains security data. Because CSS and rules are plain text, they can be saved in other ways. Sector 0-7 contains binary data.
The framework handles most of the work so you don't have to worry about this yourself. But the layout can explain why things are limited and that's something you need to be aware of if you start to use custom data structures for configuration.
A controller plugin can have custom configuration up to 4096 bytes. A device plugin can only use 512 bytes for it's custom configuration.
In most cases you don't need a custom config, but the framework provides these system calls to easy things if you need it:
To load/save data structures from/into flash when using a device plugin:
LoadCustomTaskSettings(event->TaskIndex, (byte*)&customConfig, sizeof(customConfig)); SaveCustomTaskSettings(event->TaskIndex, (byte*)&customConfig, sizeof(customConfig));
To load/save data structures from/into flash when using a controller plugin:
LoadCustomControllerSettings((byte*)&customConfig, sizeof(customConfig)); SaveCustomControllerSettings((byte*)&customConfig, sizeof(customConfig));
In these samples, the 'customConfig' is a data structure that can hold a collection of variables.