8 Star 26 Fork 14

wibim / luat-jt808

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gpsmng.lua 2.83 KB
一键复制 编辑 原始数据 按行查看 历史
wibim 提交于 2020-02-15 14:44 . 第一次上代码
--[[
模块名称:gpsmng
模块功能:GPS打开关闭控制
模块最后修改时间:2017.08.25
]]
require"pincfg"
require"gps"
module(...,package.seeall)
--[[
函数名:print
功能 :打印接口,此文件中的所有打印都会加上gpsmng前缀
参数 :无
返回值:无
]]
local function print(...)
_G.print("--zbb--gpsmng",...)
end
--[[
函数名:gpsopen
功能 :打开GPS,val秒到关闭GPS
参数 :无
返回值:true
]]
local function gpsopen()
gps.open(gps.TIMER,{tag="GPSMOD",val=_G.GPSMOD_CLOSE_GPS_INVALIDSHK_FREQ+5})
return true
end
--[[
函数名:gpsclose
功能 :关闭GPS
参数 :无
返回值:无
]]
local function gpsclose()
gps.closegps(gps.TIMER,{tag="GPSMOD"})
end
--[[
函数名:shkind
功能 :震动中断消息处理
参数 :无
返回值:true
]]
local function shkind()
print("shkind",gps.isActive(gps.TIMER,{tag="GPSMOD"}))
if gps.isActive(gps.TIMER,{tag="GPSMOD"}) then
gpsopen()
end
return true
end
--[[
函数名:Extlonggps
功能 :退出LONGPS模式
参数 :无
返回值:无
]]
local function Extlonggps()
print("Extlonggps")
if nvm.get("workmod")=="LONGPS" then
nvm.set("workmod","GPS","EXTLGPS")
end
end
--[[
函数名:opnlongps
功能 :GPS一直打开
参数 :无
返回值:无
]]
local function opnlongps()
print("opnlongps")
sys.timerStart(Extlonggps,7200000) --2 hour
gps.open(gps.DEFAULT,{tag="LONGPSMOD"})
end
--[[
函数名:clslongps
功能 :GPS一直打开
参数 :无
返回值:无
]]
local function clslongps()
print("clslongps")
gps.close(gps.DEFAULT,{tag="LONGPSMOD"})
end
--[[
函数名:workmodind
功能 :工作模式切换处理
参数 :工作模式
返回值:无
]]
local function workmodind(s)
if nvm.get("workmod") ~= "GPS" then
gpsclose()
if nvm.get("workmod") == "LONGPS" then
opnlongps()
else
clslongps()
end
else --"GPS"
if s then gpsopen() end
clslongps()
end
end
local function test1Cb(tag)
print("gpsmng.test1Cb",tag)
--printGps()
end
--[[
函数名:accind
功能 :acc状态处理
参数 :acc状态
返回值:无
]]
local function accind(on)
print("accind on",on)
if on then
gps.open(gps.DEFAULT,{tag="ACC",cb=test1Cb})
else
gps.close(gps.DEFAULT,{tag="ACC"})
end
return true
end
local function parachangeind(k,v,r)
if k == "workmod" then
workmodind(true)
end
return true
end
--注册消息的处理函数
sys.subscribe("DEV_ACC_IND",accind)
sys.subscribe("GPSMOD_OPN_GPS_VALIDSHK_IND",gpsopen)
sys.subscribe("PARA_CHANGED_IND",parachangeind)
sys.subscribe("SHKCNT_VALIDSHK_IND",shkind)
if rtos.poweron_reason() == rtos.POWERON_KEY then
gpsopen()
end
-- local function nmeaCb(nmeaItem)
-- log.info("--zbb--gpsmng.nmeaCb",nmeaItem)
-- end
-- gps.setNmeaMode(2,nmeaCb)
gps.setAerialMode(1,1,0,0)
gps.setParseItem(true,true,true)
accind(acc.getflag())
Lua
1
https://gitee.com/wibim/luat-jt808.git
git@gitee.com:wibim/luat-jt808.git
wibim
luat-jt808
luat-jt808
master

搜索帮助