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

Plugin's config not found. Missing .config in SPIFFS #4

Open
omerfraz opened this issue Aug 6, 2019 · 1 comment
Open

Plugin's config not found. Missing .config in SPIFFS #4

omerfraz opened this issue Aug 6, 2019 · 1 comment

Comments

@omerfraz
Copy link

omerfraz commented Aug 6, 2019

In DHTPlugin.cpp , function loadConfig() fails due to a missing config file in SPIFFS.
What is the structure of dht.config that needs to be uploaded in SPIFFS?

DHTPlugin::DHTPlugin(uint8_t pin, uint8_t type) : _dht(pin, type), Plugin(2, 2) {
DEBUG_MSG("dht", "plugin started\n");
loadConfig();
_dht.begin();
DEBUG_MSG("dht", "_dht.begin()\n");
}

In Plugin.cpp, here is the loadConfig() function

bool Plugin::loadConfig() {
File configFile = SPIFFS.open("/" + getName() + ".config", "r");
if (configFile.size() == _size) {
DEBUG_MSG(getName().c_str(), "loading config\n", _size);
configFile.read((uint8_t*)_devices, _size);
}
else if (configFile.size() == 0)
DEBUG_MSG(getName().c_str(), "config not found\n", _size);
else
DEBUG_MSG(getName().c_str(), "config size mismatch\n", _size);

for (int8_t sensor = 0; sensor<getSensors(); sensor++)
if (strlen(_devices[sensor].uuid) != UUID_LENGTH)
_devices[sensor].uuid[0] = '\0';

configFile.close();
return true;
}

@andig
Copy link
Owner

andig commented Aug 6, 2019

See

bool Plugin::loadConfig() {
. The config file just contains the serialized device structure. All configuration happens via the ui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants