Răsfoiți Sursa

change: airlink,air8000的airlink已经自动启动,不需要手工启动和注册netdrv了

Wendal Chen 9 luni în urmă
părinte
comite
c22f975c5b

+ 5 - 0
components/airlink/src/task/luat_airlink_task.c

@@ -53,6 +53,11 @@ __USER_FUNC_IN_RAM__ static int luat_airlink_task(void *param) {
             // if (ptr->cmd != 0x10) {
             //     LLOGD("收到指令/回复 cmd %d len %d", ptr->cmd, ptr->len);
             // }
+            if (g_airlink_last_cmd_timestamp == 0) {
+                uint64_t tmp = luat_mcu_tick64_ms();
+                LLOGI("AIRLINK_READY %ld", (uint32_t)tmp);
+                // TODO 发个系统消息
+            }
             g_airlink_last_cmd_timestamp = luat_mcu_tick64_ms();
             cmd_reg = airlink_cmds;
             while (1) {

+ 1 - 1
components/network/netdrv/src/luat_netdrv.c

@@ -45,8 +45,8 @@ luat_netdrv_t* luat_netdrv_setup(luat_netdrv_conf_t *conf) {
         if (drvs[conf->id]->boot) {
             //LLOGD("启动网络设备 %p", drvs[conf->id]);
             drvs[conf->id]->boot(drvs[conf->id], NULL);
-            return drvs[conf->id];
         }
+        return drvs[conf->id];
     }
     LLOGW("无效的注册id或类型 id=%d, impl=%d", conf->id, conf->impl);
     return NULL;

+ 16 - 26
demo/airlink/air8000_wifi/main.lua

@@ -10,7 +10,10 @@ dnsproxy = require("dnsproxy")
 dhcpsrv = require("dhcpsrv")
 httpplus = require("httpplus")
 
-PWR8000S = gpio.setup(23, 0, gpio.PULLUP) -- 关闭Air8000S的LDO供电
+-- 通过boot按键方便刷Air8000S
+function PWR8000S(val)
+    gpio.set(23, val)
+end
 
 gpio.debounce(0, 1000)
 gpio.setup(0, function()
@@ -42,22 +45,20 @@ function test_sta()
     log.info("执行STA连接操作")
     wlan.connect("luatos1234", "12341234")
     netdrv.dhcp(socket.LWIP_STA, true)
-    -- netdrv.napt(socket.LWIP_STA)
     sys.wait(8000)
     iperf.server(socket.LWIP_STA)
 
     sys.wait(5000)
-    -- airlink.slave_reboot()
-    -- while 1 do
-    --     -- log.info("MAC地址", netdrv.mac(socket.LWIP_STA))
-    --     -- log.info("IP地址", netdrv.ipv4(socket.LWIP_STA))
-    --     -- log.info("ready?", netdrv.ready(socket.LWIP_STA))
-    --     sys.wait(1000)
-    --     log.info("执行http请求")
-    --     -- local code = http.request("GET", "http://192.168.1.15:8000/README.md", nil, nil, {adapter=socket.LWIP_STA,timeout=3000}).wait()
-    --     local code, headers, body = http.request("GET", "https://httpbin.air32.cn/bytes/2048", nil, nil, {adapter=socket.LWIP_STA,timeout=3000}).wait()
-    --     log.info("http执行结果", code, headers, body and #body)
-    -- end
+    while 1 do
+        -- log.info("MAC地址", netdrv.mac(socket.LWIP_STA))
+        -- log.info("IP地址", netdrv.ipv4(socket.LWIP_STA))
+        -- log.info("ready?", netdrv.ready(socket.LWIP_STA))
+        sys.wait(1000)
+        log.info("执行http请求")
+        -- local code = http.request("GET", "http://192.168.1.15:8000/README.md", nil, nil, {adapter=socket.LWIP_STA,timeout=3000}).wait()
+        local code, headers, body = http.request("GET", "https://httpbin.air32.cn/bytes/2048", nil, nil, {adapter=socket.LWIP_STA,timeout=3000}).wait()
+        log.info("http执行结果", code, headers, body and #body)
+    end
 end
 
 function test_scan()
@@ -84,20 +85,9 @@ sys.taskInit(function()
 end)
 
 sys.taskInit(function()
-    -- 稍微缓一下
-    sys.wait(10)
-    -- 初始化airlink
-    airlink.init()
-    -- 启动底层线程, 从机模式
-    PWR8000S(1)
-    sys.wait(200)
-    airlink.start(1)
-    sys.wait(500) -- 稍微缓一下
-    airlink.test(10)
-    netdrv.setup(socket.LWIP_STA, netdrv.WHALE)
-    netdrv.setup(socket.LWIP_AP, netdrv.WHALE)
+    log.info("新的Air8000脚本...")
 
-    sys.wait(100)
+    sys.wait(300) -- 稍微缓一下, Air8000S的启动大概需要300ms
     wlan.init()
     sys.wait(100)