Skip to content

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

@omerfraz

Description

@omerfraz

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions