add set_args function

This commit is contained in:
Evgeny
2021-08-03 11:40:33 +03:00
parent e42c1950ae
commit c254466953
3 changed files with 39 additions and 0 deletions

25
ip-location-widget.lua Normal file
View File

@@ -0,0 +1,25 @@
function on_alarm()
request_ip()
end
function on_network_result(result, code, id)
if id == "ip" then
local location = {
ajson:get_value(result, "object string:latitude"),
ajson:get_value(result, "object string:longitude")
}
request_addr(location)
elseif id == "adr" then
local adr = ajson:get_value(result, "object string:display_name")
ui:show_text(adr)
end
end
function request_ip()
http:get("https://freegeoip.app/json/", "ip")
end
function request_addr(location)
http:get("https://nominatim.openstreetmap.org/reverse?format=json&lat="..location[1].."&lon=".. location[2].."&addressdetails=1", "adr")
end