Air202 - 如何阅读ATS7的答案?

欢迎您! 我来自波兰。 我在AliExpress买了Air202。
我有这样的剧本。


Hello! I'm from Poland. I bought Air202 on AliExpress.
I have a script like that.


require"ril"

module(...,package.seeall)
local function print(...)
    _G.print("test",...)
end

-----------------------------------------------------------------------------------------

local function ats()
  ril.request("ATS7?")
end
sys.timer_start(ats,20000)

-----------------------------------------------------------------------------------------

ril.regrsp("ATS7?",fnc,2)

-----------------------------------------------------------------------------------------

local function fnc(data,prefix)
  if data == "ATS7?" then
    print(data)
  end
end
ril.regurc("ATS7?",fnc)

-----------------------------------------------------------------------------------------


attachments-2019-01-jQ3iOtaw5c2dfb3c139c3.PNG
如何阅读ATS7的答案? 并打印21?
谢谢你的帮助。


How to read the answer from ATS7? and print 21?
Thank you for your help.

attachments-2019-01-J2v6VCRI5c2dfba744fd0.PNG




第1版:
Edition 1:



李炜镪

谢谢你的回答,但它不起作用。
这是我的第二个脚本:

Thank you for your answer, but it does not work.
This is my second script:


require"ril"

module(...,package.seeall)
local function print(...)
_G.print("test",...)
end

-----------------------------------------------------------------------------------------

local function ats()
ril.request("ATS7?")
end
sys.timer_start(ats,20000)

-----------------------------------------------------------------------------------------

ril.regrsp('S', nil, 1) -- set ATS response format numberic
ril.request("ATS7?", nil, function(cmd, success, response, intermediate) -- response callback
log.info('req ATS7', success, response, intermediate)
end)


attachments-2019-01-4SGZG6Up5c2e64475625e.PNG
在这里你可以看到错误:


Here you can see the error:

attachments-2019-01-oFx6Ylna5c2e5f583c3ff.PNG



请先 登录 后评论

最佳答案 2019-01-04 20:34

try like this.

ril.regRsp('S', nil, 1) -- set ATS response format numberic
ril.request("ATS7?", nil, function(cmd, success, response, intermediate) -- response callback
    log.info('req ATS7', success, response, intermediate)
end)
请先 登录 后评论

其它 0 个回答