update: 真正调通air780epvh的agps, 实现开机后8秒定位成功
[LuatOS.git] / demo / air780epvh_gnsstest / testGnss.lua
blob0d05730c3be00bf3b6157aa82015c71000c12b88
2 -- libgnss库初始化
3 libgnss.clear() -- 清空数据,兼初始化
5 -- LED和ADC初始化
6 LED_GNSS = 24
7 gpio.setup(LED_GNSS, 0) -- GNSS定位成功灯
9 local hdgnss = require("hdgnss")
11 sys.taskInit(function()
12 log.debug("提醒", "室内无GNSS信号,定位不会成功, 要到空旷的室外,起码要看得到天空")
13 hdgnss.setup({
14 uart_id=2,
15 debug=true
17 hdgnss.start()
18 end)
20 sys.taskInit(function()
21 while 1 do
22 sys.wait(5000)
23 -- log.info("RMC", json.encode(libgnss.getRmc(2) or {}, "7f"))
24 -- log.info("INT", libgnss.getIntLocation())
25 -- log.info("GGA", libgnss.getGga(3))
26 -- log.info("GLL", json.encode(libgnss.getGll(2) or {}, "7f"))
27 -- log.info("GSA", json.encode(libgnss.getGsa(1) or {}, "7f"))
28 -- log.info("GSV", json.encode(libgnss.getGsv(2) or {}, "7f"))
29 -- log.info("VTG", json.encode(libgnss.getVtg(2) or {}, "7f"))
30 -- log.info("ZDA", json.encode(libgnss.getZda(2) or {}, "7f"))
31 -- log.info("date", os.date())
32 -- log.info("sys", rtos.meminfo("sys"))
33 -- log.info("lua", rtos.meminfo("lua"))
34 end
35 end)
37 -- 订阅GNSS状态编码
38 sys.subscribe("GNSS_STATE", function(event, ticks)
39 -- event取值有
40 -- FIXED 定位成功
41 -- LOSE 定位丢失
42 -- ticks是事件发生的时间,一般可以忽略
43 local onoff = libgnss.isFix() and 1 or 0
44 log.info("GNSS", "LED", onoff)
45 gpio.set(LED_GNSS, onoff)
46 end)