Logic Machine Forum
Download lat&long from LM - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Download lat&long from LM (/showthread.php?tid=997)



Download lat&long from LM - buuuudzik - 18.09.2017

Hello,

is it possible to download the latitude and longitude from LM in lua to use it in apps?


RE: Download lat&long from LM - admin - 18.09.2017

These variables can be nil if no latitude/longitude is set:
Code:
<?
require('apps')
config = getconfig()
write(config.latitude, ', ', config.longitude)



RE: Download lat&long from LM - buuuudzik - 18.09.2017

I've tried to use it in Resident script (of course without <?) but it returns below error:

Resident script:2: attempt to call global 'getconfig' (a nil value)
stack traceback:


I've used your solution and now I send get request to .lp file but interesting thing is that I must fill also login and password when I try to connect localhost(this is from demo machine):
Code:
http = require "socket.http"
result = http.request("http://admin:admin@127.0.0.1/user/long&lat.lp")

longitude, latitude = result:match('(%d*.%d*),(%d*.%d*)')
longitude, latitude = tonumber(longitude), tonumber(latitude)
log(longitude, latitude)



RE: Download lat&long from LM - admin - 20.09.2017

From scripts you can use:
Code:
require('uci')
lat = uci.get('genohm-scada.core.latitude')
lat = tonumber(lat)

lng = uci.get('genohm-scada.core.longitude')
lng = tonumber(lng)



RE: Download lat&long from LM - buuuudzik - 20.09.2017

For sure this is much more easier solution, and last solution was little complicated. Is this also for deamon scripts?


RE: Download lat&long from LM - admin - 20.09.2017

This will work anywhere, in apps as well.