1
0
mirror of https://gitee.com/openLuat/LuatOS synced 2025-08-17 22:18:03 +08:00

update: 优化一下lbsLoc库及其demo

This commit is contained in:
Wendal Chen 2023-02-20 21:19:56 +08:00
parent 3962f219f8
commit 28c038bd7c
2 changed files with 8 additions and 8 deletions

View File

@ -37,6 +37,8 @@ local function getLocCb(result, lat, lng, addr, time, locType)
log.info("服务器返回的时间", time:toHex())
log.info("定位类型,基站定位成功返回0", locType)
end
-- 广播给其他需要定位数据的task
-- sys.publish("lbsloc_result", result, lat, lng)
end
sys.taskInit(function()
@ -47,7 +49,7 @@ sys.taskInit(function()
end
end)
-- -- 以下为wifi定位
-- -- 以下为基站+wifi混合定位
-- sys.subscribe("WLAN_SCAN_DONE", function ()
-- local results = wlan.scanResult()
-- log.info("scan", "results", #results)
@ -60,6 +62,8 @@ end)
-- reqWifi[bssid]=v["rssi"]
-- end
-- lbsLoc.request(getLocCb,nil,nil,nil,nil,nil,nil,reqWifi)
-- else
-- lbsLoc.request(getLocCb) -- 没有wifi数据,进行普通定位
-- end
-- end)
@ -68,7 +72,7 @@ end)
-- wlan.init()
-- while 1 do
-- wlan.scan()
-- sys.wait(15000)
-- sys.wait(60000)
-- end
-- end)

View File

@ -48,18 +48,14 @@ local d1Name = "lbsLoc"
-- @usage
local function numToBcdNum(inStr,destLen)
local l,t,num = string.len(inStr or ""),{}
destLen = destLen or (inStr:len()+1)/2
for i=1,l,2 do
num = tonumber(inStr:sub(i,i+1),16)
if i==l then
num = 0xf0+num
else
num = (num%0x10)*0x10 + (num-(num%0x10))/0x10
end
table.insert(t,num)
end
@ -184,9 +180,9 @@ local function taskClient(cbFnc, reqAddr, timeout, productKey, host, port,reqTim
if result then
while true do
log.info(" lbsloc socket_service connect true")
result, _ = libnet.tx(d1Name, 0, netc, reqStr) ---发送数据
result = libnet.tx(d1Name, 0, netc, reqStr) ---发送数据
if result then
result, param = libnet.wait(d1Name, 10000, netc)
result, param = libnet.wait(d1Name, 15000 + retryCnt * 5, netc)
if not result then
socket.close(netc)
socket.release(netc)