Skip to content
New issue

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

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

Already on GitHub? # to your account

Source change required for JsonDocument #15

Open
wernerpaulin opened this issue Nov 9, 2024 · 2 comments
Open

Source change required for JsonDocument #15

wernerpaulin opened this issue Nov 9, 2024 · 2 comments

Comments

@wernerpaulin
Copy link

When changing to JsonDocument, I had to change the code to iterate over the json configs:
JsonArray configurations = doc["Configurations"].as();
if (configurations.size() == 0) {
return NO_UPDATE_PROFILE_FOUND;
}

    // Step through the configurations looking for a match
    for (JsonObject config : configurations)
    {
        String CBoard = config["Board"].isNull() ? "" : String((const char *)config["Board"]);
        String CDevice = config["Device"].isNull() ? "" : String((const char *)config["Device"]);
        CVersion = config["Version"].isNull() ? "" : String((const char *)config["Version"]);
        String CConfig = config["Config"].isNull() ? "" : String((const char *)config["Config"]);

        if ((CBoard.isEmpty() || CBoard == BoardName) &&
            (CDevice.isEmpty() || CDevice == DeviceName) &&
            (CConfig.isEmpty() || CConfig == ConfigName))
        {
            if (CVersion.isEmpty() || CVersion > String(CurrentVersion) ||
                (DowngradesAllowed && CVersion != String(CurrentVersion)))
                return Action == DONT_DO_UPDATE ? UPDATE_AVAILABLE : DoOTAUpdate(config["URL"], Action);
            foundProfile = true;
        }
    }
    return foundProfile ? NO_UPDATE_AVAILABLE : NO_UPDATE_PROFILE_FOUND;
@mrcodetastic
Copy link

Pull request #16 fixes this issue and others. Hoping the maintainer can merge.

@mrcodetastic
Copy link

Have implemented in my fork @ https://github.com/mrcodetastic/ESP32-OTA-Pull/tree/main

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

No branches or pull requests

2 participants