This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Download lat&long from LM
#1
Hello,

is it possible to download the latitude and longitude from LM in lua to use it in apps?
Reply
#2
These variables can be nil if no latitude/longitude is set:
Code:
<?
require('apps')
config = getconfig()
write(config.latitude, ', ', config.longitude)
Reply
#3
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)
Reply
#4
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)
Reply
#5
For sure this is much more easier solution, and last solution was little complicated. Is this also for deamon scripts?
Reply
#6
This will work anywhere, in apps as well.
Reply


Forum Jump: