diff --git a/components/mobile/luat_lib_mobile.c b/components/mobile/luat_lib_mobile.c index 6eaef55b..486cceb9 100644 --- a/components/mobile/luat_lib_mobile.c +++ b/components/mobile/luat_lib_mobile.c @@ -1055,6 +1055,8 @@ static const rotable_Reg_t reg_mobile[] = { {"CONF_FAKE_CELL_BARTIME", ROREG_INT(MOBILE_CONF_FAKE_CELL_BARTIME)}, //@const CONF_RESET_TO_FACTORY number 删除已保存的协议栈参数,重启后会使用默认配置 {"CONF_RESET_TO_FACTORY", ROREG_INT(MOBILE_CONF_RESET_TO_FACTORY)}, + //@const CONF_USB_ETHERNET number 蜂窝网络模块的usb以太网卡控制,bit0开关1,开0关,bit1模式1NAT,0独立IP,bit2协议1ECM,0RNDIS,飞行模式里设置 + {"CONF_USB_ETHERNET", ROREG_INT(MOBILE_CONF_USB_ETHERNET)}, //@const PIN_VERIFY number 验证PIN码操作 {"PIN_VERIFY", ROREG_INT(LUAT_SIM_PIN_VERIFY)}, //@const PIN_CHANGE number 更换PIN码操作 diff --git a/components/mobile/luat_mobile.h b/components/mobile/luat_mobile.h index b8ade489..f54383ce 100644 --- a/components/mobile/luat_mobile.h +++ b/components/mobile/luat_mobile.h @@ -838,6 +838,7 @@ enum MOBILE_CONF_SIM_WC_MODE, MOBILE_CONF_FAKE_CELL_BARTIME, MOBILE_CONF_RESET_TO_FACTORY, + MOBILE_CONF_USB_ETHERNET, }; uint32_t luat_mobile_sim_write_counter(void); diff --git a/demo/mobile/main.lua b/demo/mobile/main.lua index cee24a67..8eaaf9ac 100644 --- a/demo/mobile/main.lua +++ b/demo/mobile/main.lua @@ -55,7 +55,7 @@ sys.taskInit(function() end -- mobile.vsimInit() -- mobile.flymode(nil,true) - - -mobile.vsimOnOff(true) + -- mobile.vsimOnOff(true) -- mobile.flymode(nil,false) -- mobile.apn(0,2,"") -- 使用默认APN激活CID2 -- mobile.rtime(3) -- 在无数据交互时,RRC 3秒后自动释放 diff --git a/demo/vsim/main.lua b/demo/vsim/main.lua new file mode 100644 index 00000000..b495a9dc --- /dev/null +++ b/demo/vsim/main.lua @@ -0,0 +1,91 @@ + +-- LuaTools需要PROJECT和VERSION这两个信息 +PROJECT = "vsimdemo" +VERSION = "1.0.0" + +log.info("main", PROJECT, VERSION) + +-- sys库是标配 +_G.sys = require("sys") +mobile.config(mobile.USB_ETHERNET, 3) +mobile.vsimInit() +mobile.flymode(nil,true) +mobile.vsimOnOff(true) +mobile.flymode(nil,false) + +sys.taskInit(function() + + if rtos.bsp() == "UIS8850BM" then + sys.wait(2000) + end + + log.info("status", mobile.status()) + local band = zbuff.create(40) + local band1 = zbuff.create(40) + mobile.getBand(band) + log.info("当前使用的band:") + for i=0,band:used()-1 do + log.info("band", band[i]) + end + + log.info("status", mobile.status()) + sys.wait(2000) + while 1 do + log.info("imei", mobile.imei()) + log.info("imsi", mobile.imsi()) + local sn = mobile.sn() + if sn then + log.info("sn", sn:toHex()) + end + log.info("status", mobile.status()) + log.info("iccid", mobile.iccid()) + log.info("csq", mobile.csq()) -- 4G模块的CSQ并不能完全代表强度 + log.info("rssi", mobile.rssi()) -- 需要综合rssi/rsrq/rsrp/snr一起判断 + log.info("rsrq", mobile.rsrq()) + log.info("rsrp", mobile.rsrp()) + log.info("snr", mobile.snr()) + log.info("simid", mobile.simid()) -- 这里是获取当前SIM卡槽 + log.info("apn", mobile.apn(0,1)) + log.info("ip", socket.localIP()) + log.info("lua", rtos.meminfo()) + -- sys内存 + log.info("sys", rtos.meminfo("sys")) + sys.wait(15000) + end +end) + +-- 基站数据的查询 + +-- 订阅式, 模块本身会周期性查询基站信息,但通常不包含临近小区 +sys.subscribe("CELL_INFO_UPDATE", function() + log.info("cell", json.encode(mobile.getCellInfo())) +end) + +-- 轮询式, 包含临近小区信息,这是手动搜索,和上面的自动搜索冲突,开启一个就行 +sys.taskInit(function() + sys.wait(15000) + mobile.config(mobile.CONF_SIM_WC_MODE, 2) + while 1 do + mobile.reqCellInfo(10) + sys.wait(11000) + log.info("cell", json.encode(mobile.getCellInfo())) + mobile.config(mobile.CONF_SIM_WC_MODE, 2) + end +end) + +-- 获取sim卡的状态 + +sys.subscribe("SIM_IND", function(status, value) + log.info("sim status", status) + if status == 'GET_NUMBER' then + log.info("number", mobile.number(0)) + end + if status == "SIM_WC" then + log.info("sim", "write counter", value) + end +end) + +-- 用户代码已结束--------------------------------------------- +-- 结尾总是这一句 +sys.run() +-- sys.run()之后后面不要加任何语句!!!!!