1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-26 04:33:47 +00:00

Add OTA support to ESP-IDF webserver (#9264)

This commit is contained in:
J. Nick Koston
2025-06-30 22:21:11 -05:00
committed by GitHub
parent e3ccb9b46c
commit 16ef5a9377
17 changed files with 788 additions and 44 deletions

View File

@@ -1,5 +1,7 @@
#ifdef USE_ESP_IDF
#include <memory>
#include <cstring>
#include <cctype>
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "http_parser.h"
@@ -88,6 +90,36 @@ optional<std::string> query_key_value(const std::string &query_url, const std::s
return {val.get()};
}
// Helper function for case-insensitive string region comparison
bool str_ncmp_ci(const char *s1, const char *s2, size_t n) {
for (size_t i = 0; i < n; i++) {
if (!char_equals_ci(s1[i], s2[i])) {
return false;
}
}
return true;
}
// Case-insensitive string search (like strstr but case-insensitive)
const char *stristr(const char *haystack, const char *needle) {
if (!haystack) {
return nullptr;
}
size_t needle_len = strlen(needle);
if (needle_len == 0) {
return haystack;
}
for (const char *p = haystack; *p; p++) {
if (str_ncmp_ci(p, needle, needle_len)) {
return p;
}
}
return nullptr;
}
} // namespace web_server_idf
} // namespace esphome
#endif // USE_ESP_IDF