Quellcode durchsuchen

add: 添加wlanraw适配

Wendal Chen vor 1 Jahr
Ursprung
Commit
5e2077dc0a

+ 6 - 23
app/network/luat_wlan_air101.c

@@ -24,6 +24,7 @@
 #include "lwip/tcp.h"
 
 void net_lwip2_set_link_state(uint8_t adapter_index, uint8_t updown);
+int luat_wlan_raw_in(const u8 *bssid, u8 *buf, u32 buf_len);
 
 #define SCAN_DONE       (0x73)
 #define ONESHOT_RESULT  (0x74)
@@ -135,9 +136,11 @@ static void netif_event_cb(u8 status) {
         #endif
         break;
     case NETIF_IP_NET_UP :
+        #ifdef LUAT_USE_NETWORK
         LLOGI("IP READY");
         msg.arg1 = status;
         luat_msgbus_put(&msg, 0);
+        #endif
         break;
 #if TLS_CONFIG_AP
     case NETIF_WIFI_SOFTAP_SUCCESS :
@@ -225,6 +228,9 @@ int luat_wlan_init(luat_wlan_config_t *conf) {
         tls_netif_add_status_event(netif_event_cb);
         #else
         tls_wifi_status_change_cb_register(netif_event_cb);
+        #ifdef LUAT_USE_WLAN_RAW
+        tls_ethernet_data_rx_callback(luat_wlan_raw_in);
+        #endif
         #endif
         tls_wifi_scan_result_cb_register(NULL);
         #endif
@@ -586,26 +592,3 @@ int luat_wlan_set_station_ip(luat_wlan_station_info_t *info) {
     #endif
     return 0;
 }
-
-extern u8* tls_wifi_buffer_acquire(int total_len);
-extern void tls_wifi_buffer_release(bool is_apsta, u8* buffer);
-int luat_wlan_macpkg_write(int is_apsta, uint8_t* buff, size_t len) {
-    u8* tmp = tls_wifi_buffer_acquire(len);
-    if (tmp == NULL) {
-        return -1;
-    }
-    memcpy(tmp, buff, len);
-    tls_wifi_buffer_release(is_apsta, tmp);
-    return 0;
-}
-
-static int macpkg_in(const u8 *bssid, u8 *buf, u32 buf_len) {
-    return luat_wlan_macpkg_input(bssid, buf, buf_len);
-}
-
-int luat_wlan_macpkg_rawmode(int enable) {
-    if (enable) {
-        tls_ethernet_data_rx_callback(macpkg_in);
-    }
-    return 0;
-}

+ 3 - 0
app/port/luat_base_air101.c

@@ -243,6 +243,9 @@ static const luaL_Reg loadedlibs[] = {
 #endif
 #ifdef LUAT_USE_WLAN
   {"wlan", luaopen_wlan},
+#ifdef LUAT_USE_WLAN_RAW
+  {"wlanraw", luaopen_wlan_raw},
+#endif
 #endif
 #ifdef LUAT_USE_PROFILER
   {"profiler", luaopen_profiler},

+ 1 - 0
app/port/luat_conf_bsp.h

@@ -43,6 +43,7 @@
 #define LUAT_USE_OTP 1
 // #define LUAT_USE_TOUCHKEY 1
 // #define LUAT_USE_SPI_SLAVE 1
+// #define LUAT_USE_WLAN_RAW 1
 
 // #define LUAT_USE_ICONV 1
 

+ 45 - 0
app/port/luat_wlan_raw_air101.c

@@ -0,0 +1,45 @@
+#include "luat_base.h"
+#include "luat_malloc.h"
+#include "luat_msgbus.h"
+#include "luat_wlan_raw.h"
+
+
+#include <string.h>
+#include "wm_irq.h"
+#include "tls_sys.h"
+#include "wm_ram_config.h"
+#include "wm_efuse.h"
+#include "wm_regs.h"
+#include "wm_wifi.h"
+#include "wm_netif.h"
+#include "wm_debug.h"
+
+#define LUAT_LOG_TAG "wlanraw"
+#include "luat_log.h"
+
+extern u8* tls_wifi_buffer_acquire(int total_len);
+extern void tls_wifi_buffer_release(bool is_apsta, u8* buffer);
+int luat_wlan_raw_write(int is_apsta, uint8_t* buff, size_t len) {
+    u8* tmp = tls_wifi_buffer_acquire(len);
+    if (tmp == NULL) {
+        return -1;
+    }
+    memcpy(tmp, buff, len);
+    tls_wifi_buffer_release(is_apsta, tmp);
+    return 0;
+}
+
+int luat_wlan_raw_in(const u8 *bssid, u8 *buf, u32 buf_len) {
+    printf("pkgin %02X%02X%02X%02X%02X%02X %p %d\n", 
+        bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], 
+        buf, buf_len);
+    l_wlan_raw_event(0, buf, buf_len); // TODO 支持AP
+    return 0;
+}
+
+int luat_wlan_raw_setup(luat_wlan_raw_conf_t *conf) {
+    // if (1) {
+    //     tls_ethernet_data_rx_callback(luat_wlan_raw_in);
+    // }
+    return 0;
+}

+ 4 - 0
xmake.lua

@@ -411,6 +411,10 @@ target("network")
     add_includedirs(luatos.."components/device/spi_slave/include",{public = true})
     add_files(luatos.."components/device/spi_slave/**.c")
 
+    -- spi slave
+    add_includedirs(luatos.."components/device/wlanraw/include",{public = true})
+    add_files(luatos.."components/device/wlanraw/**.c")
+
 target_end()
 
 target("nes")