MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / getLocation

Function getLocation

ESP32_AP-Flasher/src/contentmanager.cpp:3042–3059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3040}
3041
3042void getLocation(JsonObject &cfgobj) {
3043 const String lat = cfgobj["#lat"];
3044 const String lon = cfgobj["#lon"];
3045
3046 if (util::isEmptyOrNull(lat) || util::isEmptyOrNull(lon)) {
3047 wsLog("get location");
3048 JsonDocument filter;
3049 filter["results"][0]["latitude"] = true;
3050 filter["results"][0]["longitude"] = true;
3051 filter["results"][0]["timezone"] = true;
3052 JsonDocument doc;
3053 if (util::httpGetJson("https://geocoding-api.open-meteo.com/v1/search?name=" + urlEncode(cfgobj["location"]) + "&count=1", doc, 5000, &filter)) {
3054 cfgobj["#lat"] = doc["results"][0]["latitude"].as<String>();
3055 cfgobj["#lon"] = doc["results"][0]["longitude"].as<String>();
3056 cfgobj["#tz"] = doc["results"][0]["timezone"].as<String>();
3057 }
3058 }
3059}
3060
3061#ifdef CONTENT_NFCLUT
3062void prepareNFCReq(const uint8_t *dst, const char *url) {

Callers 3

drawWeatherFunction · 0.85
drawForecastFunction · 0.85
drawBuienradarFunction · 0.85

Calls 4

isEmptyOrNullFunction · 0.85
wsLogFunction · 0.85
httpGetJsonFunction · 0.85
urlEncodeFunction · 0.85

Tested by

no test coverage detected