| 3040 | } |
| 3041 | |
| 3042 | void 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 |
| 3062 | void prepareNFCReq(const uint8_t *dst, const char *url) { |
no test coverage detected