Răsfoiți Sursa

Merge branch 'master' of https://gitee.com/openLuat/LuatOS

13917187172 4 luni în urmă
părinte
comite
fca02ff714
40 a modificat fișierele cu 1215 adăugiri și 1453 ștergeri
  1. 3 0
      components/airlink/src/task/luat_airlink_spi_master_task.c
  2. 1 1
      components/camera/luat_lib_camera.c
  3. 4 2
      components/crypto/luat_crc.c
  4. 2 0
      components/lcd/luat_lcd_sh8601z.c
  5. 87 0
      components/lcd/luat_lib_lcd.c
  6. 0 1
      components/lfs/lfs_sfd.c
  7. 119 87
      components/mreport/src/luat_mreport.c
  8. 6 5
      components/network/netdrv/binding/luat_lib_netdrv.c
  9. 1 0
      components/network/netdrv/src/ch390h_api.c
  10. 0 327
      components/network/posix/luat_network_posix.c
  11. 0 20
      components/network/posix/luat_network_posix.h
  12. 622 636
      components/tp/cst92xx_fw.h
  13. 1 1
      components/tp/luat_lib_tp.c
  14. 23 110
      components/tp/luat_tp_cst9220.c
  15. 1 1
      luat/include/luat_crypto.h
  16. 1 0
      luat/include/luat_libs.h
  17. 4 0
      luat/include/luat_sfd.h
  18. 49 11
      luat/modules/luat_lib_crypto.c
  19. 1 1
      luat/modules/luat_lib_mcu.c
  20. 0 2
      module/Air8000/demo/accessory_board/AirETH_1000/http/readme.md
  21. 1 3
      module/Air8000/demo/accessory_board/AirETH_1000/network_routing/4g_out_ethernet_in_wifi_in/readme.md
  22. 1 1
      module/Air8000/demo/accessory_board/AirETH_1000/readme.md
  23. 26 0
      module/Air8000/demo/http/baidu_parent_ca.crt
  24. 29 63
      module/Air8000/demo/http/http_app.lua
  25. 0 69
      module/Air8000/demo/http/httpplus_app.lua
  26. 10 4
      module/Air8000/demo/http/netdrv/netdrv_4g.lua
  27. 36 54
      module/Air8000/demo/http/netdrv/netdrv_eth_spi.lua
  28. 9 0
      module/Air8000/demo/http/netdrv/netdrv_multiple.lua
  29. 46 0
      module/Air8000/demo/http/netdrv/netdrv_pc.lua
  30. 36 21
      module/Air8000/demo/http/netdrv/netdrv_wifi.lua
  31. 4 0
      module/Air8000/demo/http/netdrv_device.lua
  32. 6 5
      module/Air8000/demo/tf_card/http_download_file.lua
  33. 1 1
      module/Air8000/demo/tf_card/http_upload_file.lua
  34. 2 2
      module/Air8101/demo/accessory_board/AirPHY_1000/network_routing/wifi_out_ethernet_in_wifi_in/netif_app.lua
  35. 3 5
      module/Air8101/demo/accessory_board/AirPHY_1000/network_routing/wifi_out_ethernet_in_wifi_in/readme.md
  36. 3 1
      module/Air8101/demo/accessory_board/AirPHY_1000/readme.md
  37. 3 3
      olddemo/camera/spi_cam/main.lua
  38. 60 0
      olddemo/crypto/main.lua
  39. 2 2
      olddemo/lcd_qspi/main.lua
  40. 12 14
      olddemo/lcd_qspi/sh8601z.lua

+ 3 - 0
components/airlink/src/task/luat_airlink_spi_master_task.c

@@ -221,8 +221,11 @@ __USER_FUNC_IN_RAM__ void airlink_transfer_and_exec(uint8_t *txbuff, uint8_t *rx
     g_airlink_statistic.tx_pkg.total++;
     // 拉低片选, 准备发送数据
     luat_gpio_set(AIRLINK_SPI_CS_PIN, 0);
+    
+    luat_spi_lock(MASTER_SPI_ID);
     // 发送数据
     luat_spi_transfer(MASTER_SPI_ID, (const char *)txbuff, TEST_BUFF_SIZE, (char *)rxbuff, TEST_BUFF_SIZE);
+    luat_spi_unlock(MASTER_SPI_ID);
     // 拉高片选之前,先检查一下是否有RDY事件未处理,如果有,则全部清除
     size_t qlen = 0;
     luat_rtos_queue_get_cnt(rdy_evt_queue, &qlen);

+ 1 - 1
components/camera/luat_lib_camera.c

@@ -580,7 +580,7 @@ static int l_camera_config(lua_State *L) {
 
 /*
 对于无法用GPIO控制camera pwdn脚的平台,手动控制camera pwdn脚拉高或者拉低,2025/9/6启用
-@api camera.pwdn_pin(level)
+@api camera.pwdn_pin(id, level)
 @int camera id,例如0
 @int pwdn脚电平,1高电平,0低电平
 @usage

+ 4 - 2
components/crypto/luat_crc.c

@@ -62,10 +62,12 @@ uint8_t luat_crc8(const void *data, uint32_t len, uint8_t start, uint8_t poly, u
 /************************************************************************/
 /*  CRC16                                                                */
 /************************************************************************/
-uint16_t luat_crc16(const void *data, uint32_t len, uint16_t start, uint16_t poly, uint8_t is_reverse)
+
+uint16_t luat_crc16(const void *data, uint32_t len, uint16_t start,uint16_t final, uint16_t poly, uint8_t is_reverse)
 {
 	uint32_t i;
 	uint16_t CRC16 = start;
+	uint16_t CRC16_out = final;
 	uint16_t wTemp = poly;
 	uint8_t *Src = (uint8_t *)data;
 	if (is_reverse)
@@ -123,7 +125,7 @@ uint16_t luat_crc16(const void *data, uint32_t len, uint16_t start, uint16_t pol
 		}
 	}
 
-	return CRC16;
+	return (uint16_t)(CRC16^CRC16_out);
 }
 
 

+ 2 - 0
components/lcd/luat_lcd_sh8601z.c

@@ -29,6 +29,8 @@ static int sh8601z_inited_init(luat_lcd_conf_t* conf)
     lcd_write_cmd_data(conf,0x53, &temp, 1);
     temp = 0xff;
     lcd_write_cmd_data(conf,0x51, &temp, 1);
+//    temp = 0x00;
+//    lcd_write_cmd_data(conf,0x36, &temp, 1);
 //    luat_lcd_clear(conf,LCD_BLACK);
     luat_lcd_display_on(conf);
     return 0;

+ 87 - 0
components/lcd/luat_lib_lcd.c

@@ -1531,6 +1531,89 @@ static int l_lcd_draw_gtfont_utf8_gray(lua_State* L) {
 
 #endif // LUAT_USE_GTFONT
 
+/* HzFont 接口(受 LUAT_USE_HZFONT 控制) */
+#ifdef LUAT_USE_HZFONT
+#include "luat_hzfont.h"
+/**
+使用HzFont绘制UTF-8字符串
+@api lcd.drawHzfontUtf8(x, y, str, fontSize, [color], [antialias])
+@int x 横坐标
+@int y 纵坐标(左下角为基准)
+@string str UTF-8字符串
+@int fontSize 字体大小(像素)
+@int color 颜色值(RGB565,缺省为黑色0x000000)
+@int antialias 抗锯齿级别(整数,可选):
+-- -1:自动(≤12号字 无抗锯齿,>12号字 2x2超采样)
+-- 1:无抗锯齿
+-- 2:2x2 超采样
+-- 4:4x4 超采样
+@return nil 无返回值
+@usage
+-- 默认黑色,自动抗锯齿
+lcd.drawHzfontUtf8(10, 50, "Hello世界", 24)
+-- 指定红色与2x2抗锯齿
+lcd.drawHzfontUtf8(10, 80, "Red文本", 24, 0xF800, 2)
+-- 仅指定抗锯齿(颜色位用nil占位)
+lcd.drawHzfontUtf8(10, 110, "锐利输出", 14, nil, 1)
+*/
+static int l_lcd_draw_hzfont_utf8(lua_State *L) {
+    int x = luaL_checkinteger(L, 1);
+    int y = luaL_checkinteger(L, 2);
+    size_t len = 0;
+    const char* str = luaL_checklstring(L, 3, &len);
+    int fontSize = luaL_checkinteger(L, 4);
+    uint32_t color = 0x000000; /* 默认黑色 */
+    if (!lua_isnoneornil(L, 5)) {
+        color = (uint32_t)luaL_checkinteger(L, 5);
+    }
+    int antialias = -1; /* -1 表示自动 */
+    if (!lua_isnoneornil(L, 6)) {
+        if (lua_isinteger(L, 6) || lua_isnumber(L, 6)) {
+            int v = (int)luaL_checkinteger(L, 6);
+            if (v == -1) antialias = -1;
+            else if (v <= 1) antialias = 1;
+            else if (v <= 2) antialias = 2;
+            else antialias = 4;
+        } else {
+            antialias = -1;
+        }
+    }
+    if (fontSize <= 0 || fontSize > 255) {
+        LLOGE("Invalid font size: %d", fontSize);
+        return 0;
+    }
+    if (lcd_dft_conf == NULL) {
+        LLOGE("lcd not init");
+        return 0;
+    }
+    (void)luat_hzfont_draw_utf8(x, y, str, (unsigned char)fontSize, color, antialias);
+    lcd_auto_flush(lcd_dft_conf);
+    return 0;
+}
+
+/**
+获取HzFont渲染下的UTF-8字符串宽度
+@api lcd.getHzFontStrWidth(str, fontSize)
+@string str UTF-8字符串
+@int fontSize 字体大小(像素)
+@return int 宽度(像素)
+@usage
+local w = lcd.getHzFontStrWidth("Hello世界", 24)
+*/
+static int l_lcd_get_hzfont_str_width(lua_State *L) {
+    size_t len = 0;
+    const char* str = luaL_checklstring(L, 1, &len);
+    int fontSize = luaL_checkinteger(L, 2);
+    if (fontSize <= 0 || fontSize > 255) {
+        lua_pushinteger(L, 0);
+        return 1;
+    }
+    unsigned int width = luat_hzfont_get_str_width(str, (unsigned char)fontSize);
+    lua_pushinteger(L, width);
+    return 1;
+}
+#endif /* LUAT_USE_HZFONT */
+
 static int l_lcd_set_default(lua_State *L) {
     if (lua_gettop(L) == 1) {
         lcd_dft_conf = lua_touserdata(L, 1);
@@ -2123,6 +2206,10 @@ static const rotable_Reg_t reg_lcd[] =
     { "drawGtfontUtf8Gray", ROREG_FUNC(l_lcd_draw_gtfont_utf8_gray)},
 #endif // LUAT_USE_GTFONT_UTF8
 #endif // LUAT_USE_GTFONT
+#ifdef LUAT_USE_HZFONT
+    { "drawHzfontUtf8", ROREG_FUNC(l_lcd_draw_hzfont_utf8)},
+    { "getHzFontStrWidth", ROREG_FUNC(l_lcd_get_hzfont_str_width)},
+#endif // LUAT_USE_HZFONT
     // 默认只带英文12号字体
     //@const font_opposansm12 font 12号字体
     { "font_opposansm12", ROREG_PTR((void*)u8g2_font_opposansm12)},

+ 0 - 1
components/lfs/lfs_sfd.c

@@ -1,5 +1,4 @@
 
-#
 #include "luat_base.h"
 #include "luat_sfd.h"
 #include "luat_mem.h"

+ 119 - 87
components/mreport/src/luat_mreport.c

@@ -19,13 +19,53 @@
 
 #define MREPORT_DOMAIN "47.94.236.172"
 #define MREPORT_PORT (12388)
-// #define MREPORT_DOMAIN "112.125.89.8"
-// #define MREPORT_PORT (42919)
 
-static struct udp_pcb* mreport_pcb;
-static luat_rtos_timer_t mreport_timer;
-const char *project_name = "unkonw";             // luatos项目名称
-const char *project_version = "";                   // luatos项目版本号
+typedef struct mreport_ctx {
+    struct udp_pcb* mreport_pcb;
+    luat_rtos_timer_t mreport_timer;
+    char project_name[64];             // luatos项目名称
+    char project_version[32];          // luatos项目版本号
+    int s_adapter_index;                  // 网络适配器索引
+} mreport_ctx_t;
+
+static mreport_ctx_t* s_mreport_ctx;
+
+static void luat_mreport_init(lua_State *L) {
+    if (s_mreport_ctx == NULL) {
+        s_mreport_ctx = (mreport_ctx_t*)luat_heap_malloc(sizeof(mreport_ctx_t));
+        if (s_mreport_ctx == NULL) {
+            LLOGE("mreport malloc ctx failed");
+            return;
+        }
+        memset(s_mreport_ctx, 0, sizeof(mreport_ctx_t));
+        memcpy(s_mreport_ctx->project_name, "unkonw", 6);
+        memcpy(s_mreport_ctx->project_version, "0.0.0", 6);
+        s_mreport_ctx->s_adapter_index = 0;
+    }
+    if (strcmp(s_mreport_ctx->project_name, "unkonw") == 0) {
+        lua_getglobal(L, "PROJECT");
+        if (LUA_TSTRING == lua_type(L, -1))
+        {
+            size_t project_len;
+            const char *project_name = luaL_tolstring(L, -1, &project_len);
+            size_t copy_len = project_len < sizeof(s_mreport_ctx->project_version) - 1  ? project_len : sizeof(s_mreport_ctx->project_version) - 1;
+            memcpy(s_mreport_ctx->project_name, project_name, copy_len);
+            s_mreport_ctx->project_name[copy_len] = '\0';
+        }
+    }
+
+    if (strcmp(s_mreport_ctx->project_version, "0.0.0") == 0) {
+        lua_getglobal(L, "VERSION");
+        if (LUA_TSTRING == lua_type(L, -1))
+        {
+            size_t version_len;
+            const char *project_version = luaL_tolstring(L, -1, &version_len);
+            size_t copy_len = version_len < sizeof(s_mreport_ctx->project_version) - 1  ? version_len : sizeof(s_mreport_ctx->project_version) - 1;
+            memcpy(s_mreport_ctx->project_version, project_version, version_len);
+            s_mreport_ctx->project_version[copy_len] = '\0';
+        }
+    }
+}
 
 static inline uint16_t u162bcd(uint16_t src) {
     uint8_t high = (src >> 8) & 0xFF;
@@ -45,8 +85,8 @@ static void luat_mreport_sys_basic(cJSON* mreport_data) {
     cJSON_AddNumberToObject(mreport_data, "localtime", t);
 
     // luatos项目信息
-    cJSON_AddStringToObject(mreport_data, "proj", project_name);
-    cJSON_AddStringToObject(mreport_data, "pver", project_version);
+    cJSON_AddStringToObject(mreport_data, "proj", s_mreport_ctx->project_name);
+    cJSON_AddStringToObject(mreport_data, "pver", s_mreport_ctx->project_version);
     
     // rndis
     cJSON_AddNumberToObject(mreport_data, "rndis", 0);
@@ -78,7 +118,7 @@ static void luat_mreport_mobile(cJSON* mreport_data) {
 
     // MUID
     char muid[33] = {0};
-    luat_mobile_get_muid(muid, 32);
+    luat_mobile_get_muid(muid, 32); // TODO 如果不是cat1,要从mcu库取.
     muid[32] = '\0';
     cJSON_AddStringToObject(mreport_data, "muid", muid);
 
@@ -134,47 +174,21 @@ static void luat_mreport_sim_network(cJSON* mreport_data, struct netif* netif) {
     }
 
     // 基站/小区
-    luat_mobile_get_cell_info_async(5);
-    luat_mobile_cell_info_t* cell_info = luat_heap_malloc(sizeof(luat_mobile_cell_info_t));
-    if (cell_info == NULL) {
-        LLOGE("out of memory when malloc cell_info");
-    }
-    else {
-        int ret = luat_mobile_get_last_notify_cell_info(cell_info);
-        if (ret != 0) {
-            LLOGI("none cell info found %d", ret);
-        }
-        else {
-            cJSON_AddNumberToObject(mreport_data, "cid", cell_info->lte_service_info.cid);
-            cJSON_AddNumberToObject(mreport_data, "pci", cell_info->lte_service_info.pci);
-            cJSON_AddNumberToObject(mreport_data, "tac", cell_info->lte_service_info.tac);
-            cJSON_AddNumberToObject(mreport_data, "band", cell_info->lte_service_info.band);
-            cJSON_AddNumberToObject(mreport_data, "earfcn", cell_info->lte_service_info.earfcn);
-            cJSON_AddNumberToObject(mreport_data, "mcc", u162bcd(cell_info->lte_service_info.mcc));
-            cJSON_AddNumberToObject(mreport_data, "mnc", u162bcd(cell_info->lte_service_info.mnc));
-            uint32_t eci;
-            if (luat_mobile_get_service_cell_identifier(&eci) == 0) {
-                cJSON_AddNumberToObject(mreport_data, "eci", eci);
-            }
-            
-            if (cell_info->lte_neighbor_info_num > 0) {
-                for (size_t i = 0; i < cell_info->lte_neighbor_info_num; i++) {
-                    cJSON * cell = cJSON_CreateObject();
-                    // 邻近小区的信息
-	                cJSON_AddNumberToObject(cell, "cid", cell_info->lte_info[i].cid);
-                    cJSON_AddNumberToObject(cell, "pci", cell_info->lte_info[i].pci);
-                    cJSON_AddNumberToObject(cell, "rsrp", cell_info->lte_info[i].rsrp);
-                    cJSON_AddNumberToObject(cell, "rsrq", cell_info->lte_info[i].rsrq);
-                    cJSON_AddNumberToObject(cell, "snr", cell_info->lte_info[i].snr);
-                    cJSON_AddNumberToObject(cell, "tac", cell_info->lte_info[i].tac);
-                    cJSON_AddItemToArray(cells, cell);
-                }
-                cJSON_AddItemToObject(mreport_data, "cells", cells);
-            }
-        }
-    }
-    if (cell_info != NULL) {
-        luat_heap_free(cell_info);
+    luat_mobile_scell_extern_info_t scell_info = {0};
+    if (luat_mobile_get_extern_service_cell_info(&scell_info) == 0) {
+        int band = 0;
+        uint32_t eci = 0;
+        uint16_t tac = 0;
+        band = luat_mobile_get_band_from_earfcn(scell_info.earfcn);
+        luat_mobile_get_service_cell_identifier(&eci);
+        luat_mobile_get_service_tac_or_lac(&tac);
+        cJSON_AddNumberToObject(mreport_data, "cid", eci);
+        cJSON_AddNumberToObject(mreport_data, "pci", scell_info.pci);
+        cJSON_AddNumberToObject(mreport_data, "tac", tac);
+        cJSON_AddNumberToObject(mreport_data, "band", band);
+        cJSON_AddNumberToObject(mreport_data, "earfcn", scell_info.earfcn);
+        cJSON_AddNumberToObject(mreport_data, "mcc", u162bcd(scell_info.mcc));
+        cJSON_AddNumberToObject(mreport_data, "mnc", u162bcd(scell_info.mnc));
     }
 
     // ip地址
@@ -281,29 +295,35 @@ void luat_mreport_send(void) {
     int ret = 0;
     size_t olen = 0;
     cJSON* mreport_data = cJSON_CreateObject();
+    int adapter_id = 0;
 
-    int adapter_index = network_register_get_default();
-	if (adapter_index < 0 || adapter_index >= NW_ADAPTER_QTY){
+    if (s_mreport_ctx->s_adapter_index == 0) 
+        adapter_id = network_register_get_default();
+    else
+        adapter_id = s_mreport_ctx->s_adapter_index;
+
+	if (adapter_id < 0 || adapter_id >= NW_ADAPTER_QTY){
 		LLOGE("尚无已注册的网络适配器");
         cJSON_Delete(mreport_data);
 		return;
 	}
-    luat_netdrv_t* netdrv = luat_netdrv_get(adapter_index);
+    luat_netdrv_t* netdrv = luat_netdrv_get(adapter_id);
     if (netdrv == NULL || netdrv->netif == NULL) {
+        LLOGE("当前使用的网络适配器id:%d, 还没初始化", adapter_id);
         cJSON_Delete(mreport_data);
         return;
     }
 
     struct netif *netif = netdrv->netif;
     if (ip_addr_isany(&netif->ip_addr)) {
-        LLOGD("还没联网");
+        LLOGE("当前使用的网络适配器id:%d, 还没分配到ip地址", adapter_id);
         cJSON_Delete(mreport_data);
         return;
     }
 
-    if (mreport_pcb == NULL) {
-        mreport_pcb = udp_new();
-        if (mreport_pcb == NULL) {
+    if (s_mreport_ctx->mreport_pcb == NULL) {
+        s_mreport_ctx->mreport_pcb = udp_new();
+        if (s_mreport_ctx->mreport_pcb == NULL) {
             LLOGE("创建,mreport udp pcb 失败, 内存不足?");
             cJSON_Delete(mreport_data);
             return;
@@ -311,7 +331,7 @@ void luat_mreport_send(void) {
     }
     // ipaddr_aton("47.94.236.172", &host);
     ipaddr_aton(MREPORT_DOMAIN, &host);
-    ret = udp_connect(mreport_pcb, &host, MREPORT_PORT);
+    ret = udp_connect(s_mreport_ctx->mreport_pcb, &host, MREPORT_PORT);
     if (ret) {
         LLOGD("udp_connect %d", ret);
         cJSON_Delete(mreport_data);
@@ -320,9 +340,9 @@ void luat_mreport_send(void) {
 
     // 基础信息
     luat_mreport_sys_basic(mreport_data);
-    // 模组信息
+    // 模组信息, TODO 有mobile库的才添加
     luat_mreport_mobile(mreport_data);
-    // sim卡和网络相关
+    // sim卡和网络相关, TODO 有mobile库的才添加
     luat_mreport_sim_network(mreport_data, netif);
     // adc信息
     luat_mreport_adc(mreport_data);
@@ -340,24 +360,24 @@ void luat_mreport_send(void) {
         cJSON_Delete(mreport_data);
         return;
     }
-    LLOGE("mreport json --- len: %d\r\n%s", strlen(json), json);
+    // LLOGE("mreport json --- len: %d\r\n%s", strlen(json), json);
 
     struct pbuf* p = pbuf_alloc(PBUF_TRANSPORT, strlen(json), PBUF_RAM);
     if (p == NULL) {
         LLOGE("获取pbuf失败 %d", strlen(json));
-        free(json);
+        luat_heap_free(json);
         cJSON_Delete(mreport_data);
         return;
     }
 
     pbuf_take(p, json, strlen(json));
-    memcpy(&mreport_pcb->local_ip, &netif->ip_addr, sizeof(ip_addr_t));
-    ret = udp_sendto_if(mreport_pcb, p, &host, MREPORT_PORT, netif);
+    memcpy(&s_mreport_ctx->mreport_pcb->local_ip, &netif->ip_addr, sizeof(ip_addr_t));
+    ret = udp_sendto_if(s_mreport_ctx->mreport_pcb, p, &host, MREPORT_PORT, netif);
     pbuf_free(p);
-    free(json);
+    luat_heap_free(json);
     cJSON_Delete(mreport_data);
     if (ret) {
-        LLOGD("ret %d", ret);
+        LLOGE("send fail ret %d", ret);
     }
 }
 
@@ -367,12 +387,12 @@ static void mreport_timer_cb(void* params) {
 }
 
 void luat_mreport_start(void) {
-    int ret = luat_rtos_timer_create(&mreport_timer);
+    int ret = luat_rtos_timer_create(&s_mreport_ctx->mreport_timer);
     if (ret) {
         LLOGE("luat_rtos_timer_create %d", ret);
         return;
     }
-    ret = luat_rtos_timer_start(mreport_timer, 1*60*1000, 1, mreport_timer_cb, NULL);
+    ret = luat_rtos_timer_start(s_mreport_ctx->mreport_timer, 1*60*1000, 1, mreport_timer_cb, NULL);
     if (ret) {
         LLOGE("luat_rtos_timer_start %d", ret);
     }
@@ -380,15 +400,15 @@ void luat_mreport_start(void) {
 }
 
 void luat_mreport_stop(void) {
-    if (mreport_timer) {
-        luat_stop_rtos_timer(mreport_timer);
-        luat_rtos_timer_delete(mreport_timer);
-        mreport_timer = NULL;
+    if (s_mreport_ctx->mreport_timer) {
+        luat_stop_rtos_timer(s_mreport_ctx->mreport_timer);
+        luat_rtos_timer_delete(s_mreport_ctx->mreport_timer);
+        s_mreport_ctx->mreport_timer = NULL;
     }
 }
 
 void luat_mreport_config(const char* config, int val) {
-    LLOGD("luat_mreport_config %s %d", config, val);
+    // LLOGD("luat_mreport_config %s %d", config, val);
     if (strcmp(config, "enable") == 0) {
         if (val == 0) {
             luat_mreport_stop();
@@ -400,23 +420,35 @@ void luat_mreport_config(const char* config, int val) {
             LLOGE("luat_mreport enable %d error", val);
         }
     }
+    else if (strcmp(config, "adapter_id") == 0) {
+        if (val >= 0 && val < NW_ADAPTER_QTY) {
+			s_mreport_ctx->s_adapter_index = val;
+		}
+        else {
+            LLOGE("luat_mreport adapter_id %d error", val);
+            s_mreport_ctx->s_adapter_index = network_register_get_default(); // 默认使用默认网络适配器
+        }
+    }
 }
 
 int l_mreport_config(lua_State *L) {
-    char* config = luaL_checkstring(L, 1);
-    int value = lua_toboolean(L, 2);
-    lua_getglobal(L, "PROJECT");
-    size_t version_len, project_len;
-    if (LUA_TSTRING == lua_type(L, -1))
-    {
-    	project_name = luaL_tolstring(L, -1, &project_len);
+    int num_args = lua_gettop(L);
+    if (num_args == 0) {
+        luat_mreport_send();
     }
-    lua_getglobal(L, "VERSION");
-    if (LUA_TSTRING == lua_type(L, -1))
-    {
-    	project_version = luaL_tolstring(L, -1, &version_len);
+    else if (num_args == 2) {
+        char* config = luaL_checkstring(L, 1);
+        int value = -1;
+        if (lua_isboolean(L, 2))
+        {
+            value = lua_toboolean(L, 2);
+        }
+        else if (lua_isnumber(L, 2))
+        {
+            value = lua_tonumber(L, 2);
+        }
+        luat_mreport_init(L);
+        luat_mreport_config(config, value);
     }
-
-    luat_mreport_config(config, value);
     return 0;
-}
+}

+ 6 - 5
components/network/netdrv/binding/luat_lib_netdrv.c

@@ -380,7 +380,7 @@ static int l_netdrv_debug(lua_State *L) {
 }
 
 /*
-设置遥测功能(还未实现全部功能)
+设置遥测功能,开启后,会自动上报设备信息,2025/9/25启用
 @api netdrv.mreport(config, value)
 @string 配置项
 @boolean 设置功能开关
@@ -390,13 +390,14 @@ static int l_netdrv_debug(lua_State *L) {
 netdrv.mreport("enable", true)
 netdrv.mreport("enable", false)
 
+-- 设置使用的网络适配器,2025/10/30启用
+netdrv.mreport("adapter_id", socket.LWIP_GP)
+netdrv.mreport("adapter_id", socket.LWIP_STA)
+netdrv.mreport("adapter_id", socket.LWIP_ETH)
+
 -- 立即上报一次, 无参数的方式调用
 netdrv.mreport()
 
--- 设置自定义数据
-netdrv.mreport("custom", {abc=1234})
--- 清除自定义数据
-netdrv.mreport("custom")
 */
 extern int l_mreport_config(lua_State* L);
 

+ 1 - 0
components/network/netdrv/src/ch390h_api.c

@@ -227,6 +227,7 @@ int luat_ch390h_write_pkg(ch390h_t* ch, uint8_t *buff, uint16_t len) {
         }
         // return 1;
     }
+    luat_ch390h_write_reg(ch, 0x55, 2);     // 发数据之前重置一下tx的内存指针
     // 写入下一个数据
     luat_ch390h_write(ch, 0x78, len, buff);
     // TCR == 0之后, 才能写入长度

+ 0 - 327
components/network/posix/luat_network_posix.c

@@ -1,327 +0,0 @@
-#include "luat_base.h"
-#include "luat_network_adapter.h"
-#include "luat_mem.h"
-#include "luat_msgbus.h"
-#include "luat_crypto.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <netdb.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/select.h>
-
-#define LUAT_LOG_TAG "network"
-#include "luat_log.h"
-
-#include "luat_network_posix.h"
-
-CBFuncEx_t posix_network_cb;
-void * posix_network_param;
-uint8_t posix_network_ready;
-
-static luat_rtos_mutex_t* master_lock;
-
-static void posix_send_event(int id, int p1, int p2, int p3) {
-    luat_network_cb_param_t params = {0};
-    params.tag = 0;
-    params.param = posix_network_param;
-    // 触发一下回调
-    // if (ready) {
-    OS_EVENT event = {
-        .ID = id,
-        .Param1 = p1,
-        .Param2 = p2,
-        .Param3 = p3
-    };
-    LLOGD("posix event %d %d %d %d", id, p1, p2, p3);
-    posix_network_cb(&event, &params);
-}
-
-void posix_network_client_thread_entry(posix_socket_t *ps) {
-
-    luat_network_cb_param_t params = {0};
-    params.tag = 0;
-    params.param = posix_network_param;
-    // 触发一下回调
-    // if (ready) {
-    OS_EVENT event = {0};
-
-    struct sockaddr_in sockaddr = {0};
-    sockaddr.sin_family = AF_INET;
-    sockaddr.sin_port = htons(ps->remote_port);
-    sockaddr.sin_addr.s_addr = ps->remote_ip.ipv4;
-    luat_rtos_task_sleep(50);
-
-    LLOGD("ready to connect %d", ps->socket_id);
-    int ret = connect(ps->socket_id, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
-
-    LLOGD("connect ret %d", ret);
-    if (ret) {
-        // 失败了
-        LLOGD("connect FAIL ret %d", ret);
-        posix_send_event(EV_NW_SOCKET_ERROR, ps->socket_id, 0, 0);
-        luat_heap_free(ps);
-        return;
-    }
-    // 发送系统消息, 通知连接成功
-    posix_send_event(EV_NW_SOCKET_CONNECT_OK, ps->socket_id, 0, 0);
-    LLOGD("wait data now");
-
-    fd_set readfds;
-    fd_set writefds;
-    fd_set errorfds;
-    int maxsock;
-    struct timeval tv;
-    maxsock = ps->socket_id;
-    // timeout setting
-    tv.tv_sec = 0;
-    tv.tv_usec = 3000; //暂时3ms吧
-    while (1) {
-        // initialize file descriptor set
-        FD_ZERO(&readfds);
-        // FD_ZERO(&writefds);
-        FD_ZERO(&errorfds);
-        FD_SET(ps->socket_id, &readfds);
-        // FD_SET(ps->socket_id, &writefds);
-        FD_SET(ps->socket_id, &errorfds);
-
-        if (master_lock)
-            if (luat_rtos_mutex_lock(master_lock, 100))
-                continue;
-        ret = select(maxsock + 1, &readfds, NULL, &errorfds, &tv);
-        if (master_lock)
-            luat_rtos_mutex_unlock(master_lock);
-
-        if (ret < 0) {
-            LLOGE("select ret %d", ret);
-            break;
-        } else if (ret == 0) {
-            //printf("select timeout\n");
-            continue;
-        }
-
-        if (FD_ISSET(maxsock, &readfds)) {
-            // 发消息,可读了
-        }
-        // if (FD_ISSET(maxsock, &writefds)) {
-        //     // 发消息,发送完成了??
-        // }
-        if (FD_ISSET(maxsock, &errorfds)) {
-            // 发消息,出错了
-            break;
-        }
-    }
-
-    luat_heap_free(ps);
-    LLOGI("socket thread exit");
-}
-
-void posix_network_set_ready(uint8_t ready) {
-    LLOGD("CALL posix_network_set_ready");
-    posix_network_ready = ready;
-    luat_network_cb_param_t params = {0};
-    params.tag = 0;
-    params.param = posix_network_param;
-    // 触发一下回调
-    // if (ready) {
-        OS_EVENT event = {
-            .ID = EV_NW_STATE,
-            .Param1 = 0,
-            .Param2 = ready,
-            .Param3 = 0
-        };
-        posix_network_cb(&event, &params);
-    // }
-}
-
-//检查网络是否准备好,返回非0准备好,user_data是注册时的user_data,传入给底层api
-uint8_t (posix_check_ready)(void *user_data) {
-    LLOGD("CALL posix_check_ready %d", posix_network_ready);
-    return posix_network_ready;
-};
-
-//创建一个socket,并设置成非阻塞模式,user_data传入对应适配器, tag作为socket的合法依据,给check_socket_vaild比对用
-//成功返回socketid,失败 < 0
-int (posix_create_socket)(uint8_t is_tcp, uint64_t *tag, void *param, uint8_t is_ipv6, void *user_data) {
-    // TODO 支持IPV6
-    int s = socket(AF_INET, is_tcp ? SOCK_STREAM : SOCK_DGRAM, is_tcp ? IPPROTO_TCP : IPPROTO_UDP);
-    LLOGD("CALL posix_create_socket %d %d", s, is_tcp);
-    return s;
-}
-
-//作为client绑定一个port,并连接remote_ip和remote_port对应的server
-//成功返回0,失败 < 0
-int (posix_socket_connect)(int socket_id, uint64_t tag, uint16_t local_port, luat_ip_addr_t *remote_ip, uint16_t remote_port, void *user_data) {
-    LLOGD("CALL posix_socket_connect %d", socket_id);
-    posix_socket_t *ps = luat_heap_malloc(sizeof(posix_socket_t));
-    if (ps == NULL) {
-        LLOGE("out of memory when malloc posix_socket_t");
-        return -1;
-    }
-    ps->socket_id = socket_id;
-    ps->tag = tag;
-    ps->local_port = local_port;
-    memcpy(&ps->remote_ip, remote_ip, sizeof(luat_ip_addr_t));
-    ps->remote_port = remote_port;
-    ps->user_data = user_data;
-
-    int ret = network_posix_client_thread_start(ps);
-    LLOGD("socket thread start %d", ret);
-
-    if (ret) {
-        luat_heap_free(ps);
-    }
-    return ret;
-}
-//作为server绑定一个port,开始监听
-//成功返回0,失败 < 0
-int (posix_socket_listen)(int socket_id, uint64_t tag, uint16_t local_port, void *user_data) {
-    // 尚未支持
-    return -1;
-}
-//作为server接受一个client
-//成功返回0,失败 < 0
-int (posix_socket_accept)(int socket_id, uint64_t tag, luat_ip_addr_t *remote_ip, uint16_t *remote_port, void *user_data) {
-    // 尚未支持
-    return -1;
-}
-
-//主动断开一个tcp连接,需要走完整个tcp流程,用户需要接收到close ok回调才能确认彻底断开
-//成功返回0,失败 < 0
-int (posix_socket_disconnect)(int socket_id, uint64_t tag, void *user_data) {
-    return close(socket_id);
-}
-
-//释放掉socket的控制权,除了tag异常外,必须立刻生效
-//成功返回0,失败 < 0
-int (posix_socket_close)(int socket_id, uint64_t tag, void *user_data) {
-    return close(socket_id);
-}
-
-//强行释放掉socket的控制权,必须立刻生效
-//成功返回0,失败 < 0
-int (posix_socket_force_close)(int socket_id, void *user_data) {
-    return close(socket_id);
-}
-
-//tcp时,不需要remote_ip和remote_port,如果buf为NULL,则返回当前缓存区的数据量,当返回值小于len时说明已经读完了
-//udp时,只返回1个block数据,需要多次读直到没有数据为止
-//成功返回实际读取的值,失败 < 0
-int (posix_socket_receive)(int socket_id, uint64_t tag, uint8_t *buf, uint32_t len, int flags, luat_ip_addr_t *remote_ip, uint16_t *remote_port, void *user_data) {
-    
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 1000; //暂时1ms吧
-    setsockopt(socket_id, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
-
-    if (master_lock)
-        if (luat_rtos_mutex_lock(master_lock, 100))
-            return -1;
-    int ret = recv(socket_id, buf, len, flags);
-    if (master_lock)
-        luat_rtos_mutex_unlock(master_lock);
-    return ret;
-}
-
-//tcp时,不需要remote_ip和remote_port
-//成功返回>0的len,缓冲区满了=0,失败 < 0,如果发送了len=0的空包,也是返回0,注意判断
-int (posix_socket_send)(int socket_id, uint64_t tag, const uint8_t *buf, uint32_t len, int flags, luat_ip_addr_t *remote_ip, uint16_t remote_port, void *user_data) {
-    
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 1000; //暂时1ms吧
-    setsockopt(socket_id, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
-
-    if (master_lock)
-        if (luat_rtos_mutex_lock(master_lock, 100))
-            return -1;
-    int ret = send(socket_id, buf, len, flags);
-    if (master_lock)
-        luat_rtos_mutex_unlock(master_lock);
-    return ret;
-}
-
-//检查socket合法性,成功返回0,失败 < 0
-int (posix_socket_check)(int socket_id, uint64_t tag, void *user_data) {
-    // TODO 通过select errorfds?
-    LLOGD("CALL posix_socket_check %d %lld", socket_id, tag);
-    return 0;
-}
-
-//保留有效的socket,将无效的socket关闭
-void (posix_socket_clean)(int *vaild_socket_list, uint32_t num, void *user_data) {
-    
-}
-
-int (posix_getsockopt)(int socket_id, uint64_t tag, int level, int optname, void *optval, uint32_t *optlen, void *user_data) {
-    return getsockopt(socket_id, level, optname, optval, optlen);
-}
-
-int (posix_setsockopt)(int socket_id, uint64_t tag, int level, int optname, const void *optval, uint32_t optlen, void *user_data) {
-    return setsockopt(socket_id, level, optname, optval, optlen);
-}
-
-//非posix的socket,用这个根据实际硬件设置参数
-int (posix_user_cmd)(int socket_id, uint64_t tag, uint32_t cmd, uint32_t value, void *user_data) {
-    return 0; // 没有这些东西
-}
-
-
-int (posix_dns)(const char *domain_name, uint32_t len, void *param,  void *user_data) {
-    LLOGD("CALL posix_dns %.*s", len, domain_name);
-    return -1; // 暂不支持DNS
-}
-
-int (posix_set_dns_server)(uint8_t server_index, luat_ip_addr_t *ip, void *user_data) {
-    return 0; // 暂不支持设置DNS
-}
-
-#ifdef LUAT_USE_LWIP
-int (posix_set_mac)(uint8_t *mac, void *user_data);
-int (posix_set_static_ip)(luat_ip_addr_t *ip, luat_ip_addr_t *submask, luat_ip_addr_t *gateway, luat_ip_addr_t *ipv6, void *user_data);
-#endif
-int (posix_get_local_ip_info)(luat_ip_addr_t *ip, luat_ip_addr_t *submask, luat_ip_addr_t *gateway, void *user_data) {
-    ip->ipv4 = 0;
-    submask->ipv4 = 0;
-    gateway->ipv4 = 0;
-    return 0;
-}
-
-//所有网络消息都是通过cb_fun回调
-//cb_fun回调时第一个参数为OS_EVENT,包含了socket的必要信息,第二个是luat_network_cb_param_t,其中的param是这里传入的param(就是适配器序号)
-//OS_EVENT ID为EV_NW_XXX,param1是socket id param2是各自参数 param3是create_soceket传入的socket_param(就是network_ctrl *)
-//dns结果是特别的,ID为EV_NW_SOCKET_DNS_RESULT,param1是获取到的IP数据量,0就是失败了,param2是ip组,动态分配的, param3是dns传入的param(就是network_ctrl *)
-void (posix_socket_set_callback)(CBFuncEx_t cb_fun, void *param, void *user_data) {
-    LLOGD("call posix_socket_set_callback %p %p", cb_fun, param);
-    if (master_lock == NULL)
-        luat_rtos_mutex_create(master_lock);
-    posix_network_cb = cb_fun;
-    posix_network_param = param;
-}
-
-
-network_adapter_info network_posix = {
-    .check_ready = posix_check_ready,
-    .create_soceket = posix_create_socket,
-    .socket_connect  = posix_socket_connect,
-    .socket_accept = posix_socket_accept,
-    .socket_disconnect  = posix_socket_disconnect,
-    .socket_close = posix_socket_close,
-    .socket_force_close = posix_socket_force_close,
-    .socket_receive = posix_socket_receive,
-    .socket_send = posix_socket_send,
-    .socket_clean = posix_socket_clean,
-    .getsockopt = posix_getsockopt,
-    .setsockopt = posix_setsockopt,
-    .user_cmd  = posix_user_cmd,
-    .dns = posix_dns,
-    .set_dns_server = posix_set_dns_server,
-    .get_local_ip_info = posix_get_local_ip_info,
-    .socket_set_callback = posix_socket_set_callback,
-    .name = "posix",
-    .max_socket_num = 4,
-    .no_accept = 1, // 暂时不支持接收
-    .is_posix = 1,
-};

+ 0 - 20
components/network/posix/luat_network_posix.h

@@ -1,20 +0,0 @@
-#ifndef LUAT_NETWORK_POSIX_H
-#define LUAT_NETWORK_POSIX_H
-
-#include "luat_base.h"
-#include "luat_network_adapter.h"
-
-typedef struct posix_socket
-{
-    int socket_id;
-    uint64_t tag;
-    uint16_t local_port;
-    luat_ip_addr_t remote_ip;
-    uint16_t remote_port;
-    void *user_data;
-}posix_socket_t;
-
-int network_posix_client_thread_start(posix_socket_t* ps);
-void posix_network_client_thread_entry(posix_socket_t* args);
-
-#endif

Fișier diff suprimat deoarece este prea mare
+ 622 - 636
components/tp/cst92xx_fw.h


+ 1 - 1
components/tp/luat_lib_tp.c

@@ -36,7 +36,7 @@ static const tp_reg_t tp_regs[] = {
 	{"jd9261t_inited",  &tp_config_jd9261t_inited},
 	{"ft3x68", &tp_config_ft3x68},
     {"cst820", &tp_config_cst820},
-    // {"cst9220", &tp_config_cst92xx},
+    {"cst9220", &tp_config_cst92xx},
     #endif
 #endif
 #ifdef LUAT_USE_TP_PC

+ 23 - 110
components/tp/luat_tp_cst9220.c

@@ -11,8 +11,6 @@
 #define LUAT_LOG_TAG "cst92xx"
 #include "luat_log.h"
 
-#define HYN_POWER_ON_UPDATA           (0) //touch fw updata
-
 #define CST92XX_ADDRESS               (0x5A)
 
 #define CST9217_CHIP_ID_CODE          (0x9217)
@@ -107,19 +105,20 @@ static int hyn_wr_reg(luat_tp_config_t* luat_tp_config, uint32_t reg_addr, uint8
         reg_addr >>= 8;
     }
 
-    if (luat_tp_config->soft_i2c != NULL){
-        ret = i2c_soft_send(luat_tp_config->soft_i2c, luat_tp_config->address, (char *)wbuf, reg_len, 1);
-    }else{
-        ret = luat_i2c_send(luat_tp_config->i2c_id, luat_tp_config->address, wbuf, reg_len, 1);
-    }
-    if(rlen){
+    if (rlen){
         if (luat_tp_config->soft_i2c != NULL){
+            ret = i2c_soft_send(luat_tp_config->soft_i2c, luat_tp_config->address, (char *)wbuf, reg_len, 1);
             ret |= i2c_soft_recv(luat_tp_config->soft_i2c, luat_tp_config->address, (char *)rbuf, rlen);
         }else{
-            ret |= luat_i2c_recv(luat_tp_config->i2c_id, luat_tp_config->address, rbuf, rlen);
+            ret = luat_i2c_transfer(luat_tp_config->i2c_id, luat_tp_config->address, wbuf, reg_len, rbuf, rlen);
+        }
+    }else{
+        if (luat_tp_config->soft_i2c != NULL){
+            ret = i2c_soft_send(luat_tp_config->soft_i2c, luat_tp_config->address, (char *)wbuf, reg_len, 1);
+        }else{
+            ret = luat_i2c_send(luat_tp_config->i2c_id, luat_tp_config->address, wbuf, reg_len, 1);
         }
     }
-
     return ret;
 }
 
@@ -251,7 +250,7 @@ static int tp_cst92xx_updata_tpinfo(luat_tp_config_t* luat_tp_config){
 static int tp_cst92xx_hw_reset(luat_tp_config_t* luat_tp_config){
     if (luat_tp_config->pin_rst != LUAT_GPIO_NONE){
         luat_gpio_set(luat_tp_config->pin_rst, Luat_GPIO_LOW);
-        luat_rtos_task_sleep(8);
+        luat_rtos_task_sleep(1);
         luat_gpio_set(luat_tp_config->pin_rst, Luat_GPIO_HIGH);
     }
     return 0;
@@ -368,85 +367,6 @@ static int tp_cst92xx_read_chip_id(luat_tp_config_t* luat_tp_config){
     return 0;
 }
 
-static uint32_t cst92xx_read_checksum(luat_tp_config_t* luat_tp_config){
-    uint8_t i2c_buf[4] = {0};
-    uint32_t chip_checksum = 0;
-    uint8_t retry = 5;
-    
-    hyn_92xxdata.boot_is_pass = 0;
-
-    if (hyn_wr_reg(luat_tp_config,0xA00300,3,i2c_buf,0)) {
-        return -1;
-    }      
-    luat_rtos_task_sleep(2);    
-    while(retry--){
-        luat_rtos_task_sleep(5);
-        if (hyn_wr_reg(luat_tp_config,0xA000,2,i2c_buf,1)) {
-            continue;
-        }
-        if(i2c_buf[0]!=0) break;
-    }
-
-    luat_rtos_task_sleep(1);
-    if(i2c_buf[0] == 0x01){
-        hyn_92xxdata.boot_is_pass = 1;
-        memset(i2c_buf,0,sizeof(i2c_buf));
-
-        if (hyn_wr_reg(luat_tp_config,0xA008,2,i2c_buf,4)) {
-            return -1;
-        }      
-
-        chip_checksum = ((uint32_t)(i2c_buf[0])) |
-            (((uint32_t)(i2c_buf[1])) << 8) |
-            (((uint32_t)(i2c_buf[2])) << 16) |
-            (((uint32_t)(i2c_buf[3])) << 24);
-    }
-    else{
-        hyn_92xxdata.need_updata_fw = 1;
-    }
-
-    return chip_checksum;
-}
-
-static int cst92xx_updata_judge(luat_tp_config_t* luat_tp_config, uint8_t *p_fw, uint16_t len){
-    uint32_t f_checksum,f_fw_ver,f_ictype,f_fw_project_id;
-    uint8_t *p_data = p_fw + len - 28;   //7F64
-    struct tp_info *ic = &hyn_92xxdata.hw_info;
-
-    if (tp_cst92xx_enter_boot(luat_tp_config)){
-        LLOGI("cst92xx_enter_boot fail,need update");
-        return -1; 
-    }
-    hyn_92xxdata.hw_info.ic_fw_checksum = cst92xx_read_checksum(luat_tp_config);
-    if(hyn_92xxdata.boot_is_pass == 0){
-        LLOGI("boot_is_pass %d,need force update",hyn_92xxdata.boot_is_pass);
-        return -1; //need updata
-    }
-    
-    f_fw_project_id = U8TO16(p_data[1],p_data[0]);
-    f_ictype = U8TO16(p_data[3],p_data[2]);
-
-    f_fw_ver = U8TO16(p_data[7],p_data[6]);
-    f_fw_ver = (f_fw_ver<<16)|U8TO16(p_data[5],p_data[4]);
-
-    f_checksum = U8TO16(p_data[11],p_data[10]);
-    f_checksum = (f_checksum << 16)|U8TO16(p_data[9],p_data[8]);
-
-
-    LLOGI("Bin_info project_id:0x%04x ictype:0x%04x fw_ver:0x%x checksum:0x%x",f_fw_project_id,f_ictype,f_fw_ver,f_checksum);
-    if(f_ictype != ic->fw_chip_type || f_fw_project_id != ic->fw_project_id){
-        LLOGE("not update,please confirm: ic_type 0x%04x,ic_project_id 0x%04x",ic->fw_chip_type,ic->fw_project_id);
-        return 0; //not updata
-    }
-    if(f_checksum != ic->ic_fw_checksum && f_fw_ver > ic->fw_ver){
-        LLOGI("need update!");
-        return -1; //need updata
-    }
-    LLOGI("cst92xx_updata_judge done, no need update");
-    return 0;
-}
-
-
 static int tp_cst92xx_gpio_init(luat_tp_config_t* luat_tp_config){
     luat_gpio_mode(luat_tp_config->pin_rst, Luat_GPIO_OUTPUT, Luat_GPIO_DEFAULT, Luat_GPIO_HIGH);
     luat_gpio_mode(luat_tp_config->pin_int, Luat_GPIO_OUTPUT, Luat_GPIO_DEFAULT, Luat_GPIO_HIGH);
@@ -475,22 +395,6 @@ static int tp_cst92xx_init(luat_tp_config_t* luat_tp_config){
     tp_cst92xx_hw_reset(luat_tp_config);
     luat_rtos_task_sleep(40);
 
-#if HYN_POWER_ON_UPDATA
-    if(tp_cst92xx_read_chip_id(luat_tp_config)){
-        LLOGE("cst92xx_read_chip_id failed");
-        return ret;
-    }
-
-    ret = tp_cst92xx_updata_tpinfo(luat_tp_config);
-    if(ret){
-        LLOGE("cst92xx_updata_tpinfo failed");
-        return ret;
-    }
-    cst92xx_updata_judge(luat_tp_config,(uint8_t*)fw_bin,CST92XX_BIN_SIZE);
-    tp_cst92xx_hw_reset(luat_tp_config);
-    luat_rtos_task_sleep(40);
-#endif
-
     ret = tp_cst92xx_updata_tpinfo(luat_tp_config);
     if(ret){
         LLOGE("cst92xx_updata_tpinfo failed");
@@ -659,10 +563,19 @@ static int tp_cst92xx_read(luat_tp_config_t* luat_tp_config, luat_tp_data_t *lua
     if (hyn_wr_reg(luat_tp_config, 0xD000,2,read_buff,sizeof(read_buff))){
         goto exit_;
     }   
-        
-    if (hyn_wr_reg(luat_tp_config, 0xD000AB,3,read_buff,0)){
-        goto exit_;
-    }   
+    
+    if (read_buff[0] & 0x0F)
+    {
+        if (hyn_wr_reg(luat_tp_config, 0xD000AB,3,read_buff,0)){
+            goto exit_;
+        }
+    }
+    else
+    {
+        if (hyn_wr_reg(luat_tp_config, 0xD000CC,3,read_buff,0)){
+            goto exit_;
+        }
+    }
 
     // luat_rtos_task_sleep(8);
     // for (size_t i = 0; i < sizeof(read_buff); i++){

+ 1 - 1
luat/include/luat_crypto.h

@@ -161,7 +161,7 @@ uint8_t luat_crc8(const void *data, uint32_t len, uint8_t start, uint8_t poly, u
  * @param is_reverse 是否逆序计算,顺序从MSB算到LSB,逆序从LSB算到MSB,不清楚的2个都试试
  * @return 输出值
  */
-uint16_t luat_crc16(const void *data, uint32_t len, uint16_t start, uint16_t poly, uint8_t is_reverse);
+uint16_t luat_crc16(const void *data, uint32_t len, uint16_t start, uint16_t final, uint16_t poly, uint8_t is_reverse);
 
 /**
  * @brief crc32常用算法

+ 1 - 0
luat/include/luat_libs.h

@@ -103,6 +103,7 @@ LUAMOD_API int luaopen_coremark( lua_State *L );
 
 LUAMOD_API int luaopen_fonts( lua_State *L );
 LUAMOD_API int luaopen_gtfont( lua_State *L );
+LUAMOD_API int luaopen_hzfont( lua_State *L );
 
 LUAMOD_API int luaopen_pin( lua_State *L );
 LUAMOD_API int luaopen_pins( lua_State *L );

+ 4 - 0
luat/include/luat_sfd.h

@@ -5,7 +5,9 @@
 #include "luat_base.h"
 
 #include "luat_spi.h"
+#ifdef __LUATOS__
 #include "luat_zbuff.h"
+#endif
 
 typedef struct sdf_opts {
     int (*initialize) (void* userdata);
@@ -25,7 +27,9 @@ typedef struct sfd_drv {
             int id;
             int cs;
         } spi;
+#ifdef __LUATOS__
         luat_zbuff_t* zbuff;
+#endif
     } cfg;
     size_t sector_size;
     size_t sector_count;

+ 49 - 11
luat/modules/luat_lib_crypto.c

@@ -283,7 +283,28 @@ int l_crypto_cipher_decrypt(lua_State *L) {
 }
 
 #include "crc.h"
-
+typedef struct{
+const char *name;   //参数模型
+uint16_t crc16_polynomial;   //多项式
+uint16_t initial_value;  //初始值
+uint16_t finally_data;  //结果异或值
+uint8_t input_reverse; //输入数据反转
+uint8_t output_reverse; //输出数据反转
+} crc16method;
+
+static const crc16method crc16method_table[] = 
+{
+    {(const char*)"IBM", 0x8005, 0x0000, 0x0000, 1, 1},
+    {(const char*)"MAXIM", 0x8005, 0x0000, 0xffff, 1, 1}, 
+    {(const char*)"USB", 0x8005, 0xffff, 0xffff, 1, 1}, 
+    {(const char*)"MODBUS", 0x8005, 0xffff, 0x0000, 1, 1}, 
+    {(const char*)"CCITT", 0x1021, 0x0000, 0x0000, 1, 1}, 
+    {(const char*)"CCITT-FALSE", 0x1021, 0xffff, 0x0000, 0, 0}, 
+    {(const char*)"X25", 0x1021, 0xffff, 0xffff, 1, 1}, 
+    {(const char*)"XMODEM", 0x1021, 0x0000,0x0000, 0, 0}, 
+    {(const char*)"DNP", 0x3D65, 0x0000, 0xffff, 1, 1},
+    {(const char*)"USER-DEFINED", 0x0000, 0x0000,0x0000, 0, 0},
+};
 /**
 计算CRC16
 @api crypto.crc16(method, data, poly, initial, finally, inReversem outReverse)
@@ -308,6 +329,11 @@ static int l_crypto_crc16(lua_State *L)
     size_t inputlen = 0;
     const unsigned char *inputData = NULL;
     const char  *inputmethod = (const char*)luaL_checkstring(L, 1);
+    uint16_t poly_default = 0x0000;
+    uint16_t initial_default = 0x0000;
+    uint16_t finally_default = 0x0000;
+    uint16_t in_reverse = 0;
+    uint16_t out_reverse = 0;
     if(lua_isuserdata(L, 2))
     {
         luat_zbuff_t *buff = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
@@ -315,13 +341,25 @@ static int l_crypto_crc16(lua_State *L)
         inputData = (const unsigned char *)(buff->addr + buff->cursor);
     }else{
         inputData = (const unsigned char*)lua_tolstring(L,2,&inputlen);
+    }    
+    for (int i = 0; i < sizeof(crc16method_table)/sizeof(crc16method_table[0]); i++)
+    {
+        if (strcmp(crc16method_table[i].name, inputmethod) == 0)
+        {
+            poly_default = crc16method_table[i].crc16_polynomial;
+            initial_default = crc16method_table[i].initial_value;
+            finally_default = crc16method_table[i].finally_data;
+            in_reverse = crc16method_table[i].input_reverse;
+            out_reverse = crc16method_table[i].output_reverse;
+        }
     }
-    uint16_t poly = (uint16_t)luaL_optnumber(L,3,0x0000);
-    uint16_t initial = (uint16_t)luaL_optnumber(L,4,0x0000);
-    uint16_t finally = (uint16_t)luaL_optnumber(L,5,0x0000);
-    uint8_t inReverse = (uint8_t)luaL_optnumber(L,6,0);
-    uint8_t outReverse = (uint8_t)luaL_optnumber(L,7,0);
-    lua_pushinteger(L, calcCRC16(inputData, inputmethod,inputlen,poly,initial,finally,inReverse,outReverse));
+    uint16_t poly = (uint16_t)luaL_optnumber(L,3,poly_default);
+    uint16_t initial = (uint16_t)luaL_optnumber(L,4,initial_default);
+    uint16_t finally = (uint16_t)luaL_optnumber(L,5,finally_default);
+    uint8_t inReverse = (uint8_t)luaL_optnumber(L,6,in_reverse);
+    uint8_t outReverse = (uint8_t)luaL_optnumber(L,7,out_reverse);
+    
+    lua_pushinteger(L, luat_crc16(inputData, inputlen, initial, finally, poly, inReverse));
     return 1;
 }
 
@@ -343,7 +381,7 @@ static int l_crypto_crc16_modbus(lua_State *L)
     const unsigned char *inputData = (const unsigned char*)luaL_checklstring(L, 1, &len);
     uint16_t crc_init = (uint16_t)luaL_optinteger(L, 2, 0xFFFF);
 
-    lua_pushinteger(L, calcCRC16_modbus(inputData, len, crc_init));
+    lua_pushinteger(L, luat_crc16_modbus(inputData, len));
     return 1;
 }
 
@@ -387,10 +425,10 @@ local crc = crypto.crc8(data, 0x31, 0xff, false)
  */
 static int l_crypto_crc8(lua_State *L)
 {
-    size_t len = 0;
+    size_t len = 0; 
     const unsigned char *inputData = (const unsigned char*)luaL_checklstring(L, 1, &len);
     if (!lua_isinteger(L, 2)) {
-        lua_pushinteger(L, calcCRC8(inputData, len));
+        lua_pushinteger(L, luat_crc8(inputData, len, 0x00, 0x07, 0));//poly默认值0x0000
     } else {
     	uint8_t poly = (uint8_t)lua_tointeger(L, 2);
     	uint8_t start = (uint8_t)luaL_optinteger(L, 3, 0);
@@ -400,7 +438,7 @@ static int l_crypto_crc8(lua_State *L)
     	}
 		lua_pushinteger(L, luat_crc8(inputData, len, start, poly, is_rev));
     }
-    return 1;
+    return 1; 
 }
 
 

+ 1 - 1
luat/modules/luat_lib_mcu.c

@@ -402,7 +402,7 @@ static int l_mcu_xtal_ref_output(lua_State* L) {
 
 LUAT_WEAK int luat_mcu_muid(char* buf) {return -1;}
 static int l_mcu_muid(lua_State* L) {
-	char muid[20];
+	char muid[33] = {0};
 	luat_mcu_muid(muid);
 	// LLOGD("mcu muid %s", muid);
 	lua_pushstring(L, muid);

+ 0 - 2
module/Air8000/demo/accessory_board/AirETH_1000/http/readme.md

@@ -14,8 +14,6 @@
 
 1、Air8000核心板一块+可上网的sim卡一张+网线一根+AirETH_1000板子一个;
 
-[](https://docs.openLuat.com/cdn/image/AirETH_1000.jpg)
-
 ![](https://docs.openLuat.com/cdn/image/AirETH_1000.jpg)
 
 2、TYPE-C USB数据线一根 + 杜邦线若干;

+ 1 - 3
module/Air8000/demo/accessory_board/AirETH_1000/network_routing/4g_out_ethernet_in_wifi_in/readme.md

@@ -14,9 +14,7 @@
 
 1、Air8000核心板一块+可上网的sim卡一张+网线一根+AirETH_1000板子一个;
 
-[](https://docs.openLuat.com/cdn/image/AirETH_1000.jpg)
-
-![](https://docs.openLuat.com/cdn/image/AirETH_1000.jpg)
+![](https://docs.openLuat.com/cdn/image/AirETH_1000.jpg)
 
 2、TYPE-C USB数据线一根 + 杜邦线若干;
 

+ 1 - 1
module/Air8000/demo/accessory_board/AirETH_1000/readme.md

@@ -12,4 +12,4 @@
 
 (2)wifi_out_ethernet_in_wifi_in
 
-使用网络路由功能,以太网提供网络供以太网和wifi设备上网
+使用网络路由功能,模组连接外部wifi提供网络供以太网和wifi设备上网

+ 26 - 0
module/Air8000/demo/http/baidu_parent_ca.crt

@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIETjCCAzagAwIBAgINAe5fIh38YjvUMzqFVzANBgkqhkiG9w0BAQsFADBMMSAw
+HgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFs
+U2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0xODExMjEwMDAwMDBaFw0yODEx
+MjEwMDAwMDBaMFAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52
+LXNhMSYwJAYDVQQDEx1HbG9iYWxTaWduIFJTQSBPViBTU0wgQ0EgMjAxODCCASIw
+DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKdaydUMGCEAI9WXD+uu3Vxoa2uP
+UGATeoHLl+6OimGUSyZ59gSnKvuk2la77qCk8HuKf1UfR5NhDW5xUTolJAgvjOH3
+idaSz6+zpz8w7bXfIa7+9UQX/dhj2S/TgVprX9NHsKzyqzskeU8fxy7quRU6fBhM
+abO1IFkJXinDY+YuRluqlJBJDrnw9UqhCS98NE3QvADFBlV5Bs6i0BDxSEPouVq1
+lVW9MdIbPYa+oewNEtssmSStR8JvA+Z6cLVwzM0nLKWMjsIYPJLJLnNvBhBWk0Cq
+o8VS++XFBdZpaFwGue5RieGKDkFNm5KQConpFmvv73W+eka440eKHRwup08CAwEA
+AaOCASkwggElMA4GA1UdDwEB/wQEAwIBhjASBgNVHRMBAf8ECDAGAQH/AgEAMB0G
+A1UdDgQWBBT473/yzXhnqN5vjySNiPGHAwKz6zAfBgNVHSMEGDAWgBSP8Et/qC5F
+JK5NUPpjmove4t0bvDA+BggrBgEFBQcBAQQyMDAwLgYIKwYBBQUHMAGGImh0dHA6
+Ly9vY3NwMi5nbG9iYWxzaWduLmNvbS9yb290cjMwNgYDVR0fBC8wLTAroCmgJ4Yl
+aHR0cDovL2NybC5nbG9iYWxzaWduLmNvbS9yb290LXIzLmNybDBHBgNVHSAEQDA+
+MDwGBFUdIAAwNDAyBggrBgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5j
+b20vcmVwb3NpdG9yeS8wDQYJKoZIhvcNAQELBQADggEBAJmQyC1fQorUC2bbmANz
+EdSIhlIoU4r7rd/9c446ZwTbw1MUcBQJfMPg+NccmBqixD7b6QDjynCy8SIwIVbb
+0615XoFYC20UgDX1b10d65pHBf9ZjQCxQNqQmJYaumxtf4z1s4DfjGRzNpZ5eWl0
+6r/4ngGPoJVpjemEuunl1Ig423g7mNA2eymw0lIYkN5SQwCuaifIFJ6GlazhgDEw
+fpolu4usBCOmmQDo8dIm7A9+O4orkjgTHY+GzYZSR+Y0fFukAj6KYXwidlNalFMz
+hriSqHKvoflShx8xpfywgVcvzfTO3PYkz6fiNJBonf6q8amaEsybwMbDqKWwIX7e
+SPY=
+-----END CERTIFICATE-----

+ 29 - 63
module/Air8000/demo/http/http_app.lua

@@ -22,68 +22,6 @@ http核心库和httpplus扩展库的区别如下:
 ]]
 
 
---[[
-此处先详细解释下http.request接口的使用方法
-
-接口定义:
-    http.request(method, url, headers, body, opts, server_ca_cert, client_cert, client_key, client_password)
-
-使用方法:
-    local code, headers, body = http.request(method, url, headers, body, opts, server_ca_cert, client_cert, client_key, client_password).wait()
-    只能在task中使用
-    发送http请求到服务器,等待服务器的http应答,此处会阻塞当前task,等待整个过程成功结束或者出现错误异常结束或者超时结束
-
-参数定义:
-    method,stirng类型,必须包含此参数,表示HTTP请求方法,支持"GET"、"POST"、"HEAD"等所有HTTP请求方法
-    url,string类型,必须包含此参数,表示HTTP请求URL地址,支持HTTP、HTTPS,支持域名、IP地址,支持自定义端口,标准的HTTP URL格式都支持
-    headers,table或者nil类型,可选包含此参数,表示HTTP请求头,例如 {["Content-Type"] = "application/x-www-form-urlencoded", ["self_defined_key"] = "self_defined_value"} 
-    body,string或者zbuff或者nil类型,可选包含此参数,表示HTTP请求体,如果请求体是一个文件中的内容,要把文件内容读出来,赋值给body使用
-    opts,table或者nil类型,可选包含此参数,表示HTTP请求的一些额外配置,包含以下内容
-    {
-        timeout    -- -- number或者nil类型,单位毫秒,可选包含此参数,表示从发送请求到读取到服务器响应整个过程的超时时间,如果传入0,表示永久等待;如果没有传入此参数或者传入nil,则使用默认值10分钟
-        dst        -- 下载路径,string类型,当HTTP请求的数据需要保存到文件中时,此处填写完整的文件路径
-        adapter    -- 使用的网卡ID,number类型,例如4G网卡,SPI外挂以太网卡,WIFI网卡等;如果没有传入此参数,内核固件会自动选择当前时间点其他功能模块设置的默认网卡
-                    -- 除非你HTTP请求时,一定要使用某一种网卡,才设置此参数;如果没什么特别要求,不要使用此参数,使用系统中设置的默认网卡即可
-                    -- 这个参数和本demo中的netdrv_device.lua关系比较大,netdrv_device会设置默认网卡,此处http不要设置adapter参数,直接使用netdrv_device设置的默认网卡就行
-        debug      -- 调试开关,bool类型,true表示打开debug调试信息日志,false表示关闭debug调试信息日志,默认为关闭状态
-        ipv6       -- 是否为ipv6,bool类型,true表示使用ipv6,false表示不使用ipv6,默认为false
-        userdata   -- 下载回调函数使用的用户自定义回调参数,做为callback回调函数的第三个参数使用
-        callback   -- 下载回调函数,function类型,当下载数据时,无论是保存到内存中,还是保存到文件系统中,如果设置了callback,内核固件中每收到一包body数据,都会自动执行一次callback回调函数
-                    -- 回调函数的调用形式为callback(content_len, body_len, userdata)
-                    --     content_len:number类型,数据总长度
-                    --     body_len:number类型,已经下载的数据长度
-                    --     userdata:下载回调函数使用的用户自定义回调参数
-    }
-    server_ca_cert,string类型,服务器ca证书数据,可选包含此参数,当客户端需要验证服务器证书时,需要此参数,如果证书数据在一个文件中,要把文件内容读出来,赋值给server_ca_cert
-    client_cert,string类型,客户端证书数据,可选包含此参数,当服务器需要验证客户端证书时,需要此参数,如果证书数据在一个文件中,要把文件内容读出来,赋值给client_cert
-    client_key, string类型,客户端加密后的私钥数据,可选包含此参数,当服务器需要验证客户端证书时,需要此参数,如果加密后的私钥数据在一个文件中,要把文件内容读出来,赋值给client_key
-    client_password,string类型,客户端私钥口令数据,可选包含此参数,当服务器需要验证客户端证书时,需要此参数,如果私钥口令数据在一个文件中,要把文件内容读出来,赋值给client_password
-
-返回值定义:
-
-    http.request().wait()有三个返回值code,headers,body
-    code表示执行结果,number类型,有以下两种含义:
-        1、code大于等于100时,表示服务器返回的HTTP状态码,例如200表示成功,详细说明可以通过搜索引擎搜索“HTTP状态码”自行了解
-        2、code小于0时,表示内核固件中检测到通信异常,有如下几种:
-            -1 HTTP_ERROR_STATE 错误的状态, 一般是底层异常,请报issue
-            -2 HTTP_ERROR_HEADER 错误的响应头部, 通常是服务器问题
-            -3 HTTP_ERROR_BODY 错误的响应体,通常是服务器问题
-            -4 HTTP_ERROR_CONNECT 连接服务器失败, 未联网,地址错误,域名错误
-            -5 HTTP_ERROR_CLOSE 提前断开了连接, 网络或服务器问题
-            -6 HTTP_ERROR_RX 接收数据报错, 网络问题
-            -7 HTTP_ERROR_DOWNLOAD 下载文件过程报错, 网络问题或下载路径问题
-            -8 HTTP_ERROR_TIMEOUT 超时, 包括连接超时,读取数据超时
-            -9 HTTP_ERROR_FOTA fota功能报错,通常是更新包不合法  
-    headers有以下两种含义:
-        1、当code的返回值大于等于100时,headers表示服务器返回的应答头,table类型
-        2、当code的返回值小于0时,headers为nil        
-    body有以下三种含义
-        1、当code的返回值大于等于100时,如果请求的body数据不需要保存到文件中,而是直接保存到内存中,则body表示请求到的数据内容,string类型
-        2、当code的返回值大于等于100时,如果请求的body数据需要保存到文件中,则body表示保存请求数据后的文件的大小,number类型
-        3、当code的返回值小于0时,body为nil
-]]
-
-
 -- http下载数据回调函数
 -- content_len:number类型,数据总长度
 -- body_len:number类型,已经下载的数据长度
@@ -100,8 +38,9 @@ end
 -- callback可以设置回调函数,可用于实时检测body数据的下载进度
 local function http_app_get()
     -- https get请求https://www.air32.cn/网页内容
+    -- 应答体为chunk编码
     -- 如果请求成功,请求的数据保存到body中
-    local code, headers, body = http.request("GET", "https://www.air32.cn/").wait()
+    local code, headers, body = http.request("GET", "http://www.air32.cn/").wait()
     log.info("http_app_get1", 
         code==200 and "success" or "error", 
         code, 
@@ -463,6 +402,31 @@ local function http_app_post_file()
 end
 
 
+-- https+证书校验 get请求功能演示
+-- 请求的body数据保存到内存变量中,在内存够用的情况下,最大支持32KB的数据存储到内存中
+local function http_app_ca_get()
+
+    -- 用来验证server证书是否合法的ca证书文件为baidu_parent_ca.crt
+    -- 此ca证书的有效期截止到2028年11月21日
+    -- 将这个ca证书文件的内容读取出来,赋值给server_ca_cert
+    -- 注意:此处的ca证书文件仅用来验证baidu网站的server证书
+    -- baidu网站的server证书有效期截止到2026年8月10日
+    -- 在有效期之前,baidu会更换server证书,如果server证书更换后,此处验证使用的baidu_parent_ca.crt也可能需要更换
+    -- 使用电脑上的网页浏览器访问https://www.baidu.com,可以实时看到baidu的server证书以及baidu_parent_ca.crt
+    -- 如果你使用的是自己的server,要替换为自己server证书对应的ca证书文件
+    local server_ca_cert = io.readFile("/luadb/baidu_parent_ca.crt")
+
+    -- https get请求https://www.bidu.cn/网页内容
+    -- 如果请求成功,请求的数据保存到body中
+    local code, headers, body = http.request("GET", "https://www.baidu.com/", nil, nil, nil, server_ca_cert).wait()
+    log.info("http_app_ca_get", 
+        code==200 and "success" or "error", 
+        code, 
+        json.encode(headers or {}), 
+        body and (body:len()>512 and body:len() or body) or "nil")
+end
+
+
 
 -- http app task 的任务处理函数
 local function http_app_task_func()
@@ -500,6 +464,8 @@ local function http_app_task_func()
         http_app_post_binary()
         -- http post文件上传功能演示
         http_app_post_file()
+        -- https+证书校验 get请求功能演示
+        http_app_ca_get()
 
         -- 60秒之后,循环测试
         sys.wait(60000)

+ 0 - 69
module/Air8000/demo/http/httpplus_app.lua

@@ -22,74 +22,6 @@ http核心库和httpplus扩展库的区别如下:
 ]]
 
 
---[[
-此处先详细解释下httpplus.request接口的使用方法
-
-接口定义:
-    httpplus.request(opts)
-
-使用方法:
-    local code, response = httpplus.request(opts)
-    只能在task中使用
-    发送http请求到服务器,等待服务器的http应答,此处会阻塞当前task,等待整个过程成功结束或者出现错误异常结束或者超时结束
-
-参数定义:
-    opts,table类型,表示HTTP请求参数,包含以下内容
-    {
-        url        -- string类型,必须包含此参数,表示HTTP请求URL地址,支持HTTP、HTTPS,支持域名、IP地址,支持自定义端口,标准的HTTP URL格式都支持
-        method     -- stirng或者nil类型,可选包含此参数,表示HTTP请求方法,支持"GET"、"POST"、"HEAD"等所有HTTP请求方法,如果没有传入此参数或者传入了nil类型,则使用默认值,默认值分为以下两种情况:
-                   -- 如果没有设置files,forms,body,bodyfile参数,则默认为"GET"
-                   -- 如果至少设置了files,forms,body,bodyfile中的一种参数,则默认为"POST"
-        headers    -- table或者nil类型,可选包含此参数,表示自定义的一个或者多个HTTP请求头,例如 {["self_defined_key1"] = "self_defined_value1", ["self_defined_key2"] = "self_defined_value2"}
-        timeout    -- number或者nil类型,单位秒,可选包含此参数,表示从发送请求到读取到服务器响应整个过程的超时时间,如果传入0,表示永久等待;如果没有传入此参数或者传入nil,则使用默认值30秒
-        files      -- table或者nil类型,可选包含此参数,表示POST上传的一个或者多个文件列表,键值对的形式,若存在本参数,会自动强制以multipart/form-data形式上传;例如
-                   -- {
-                   --     ["uploadFile"] = "/luadb/logo.jpg",
-                   --     ["logo1.jpg"] = "/luadb/logo.jpg",
-                   -- }
-
-        forms      -- table或者nil类型,可选包含此参数,表示POST上传的一个或者多个表单参数列表,键值对的形式
-                   -- 若存在本参数并且不存在files参数,会自动强制以application/x-www-form-urlencoded形式上传
-                   -- 若存在本参数并且存在files参数,会自动强制以multipart/form-data形式上传,也就是说支持同时上传文件和表单参数
-                   -- 例如:
-                   -- {
-                   --     ["username"] = "LuatOS",
-                   --     ["password"] = "123456",
-                   -- } 
-        body       -- string,zbuff,table或者nil类型,可选包含此参数,表示自定义的body内容, 不能与files或者forms同时存在
-        bodyfile   -- string或者nil类型,可选包含此参数,表示要上传的一个文件的路径,会自动读取文件中的内容进行上传
-                   -- 不能与files或者forms同时存在
-                   -- 可以与body同时存在,与body同时存在时, 优先级高于body参数,也就是说,bodyfile对应的文件路径中的内容在body参数对应的内容之前
-        debug      -- bool或者nil类型,可选包含此参数,表示调试开关,true表示打开debug调试信息日志,false表示关闭debug调试信息日志,如果没有传入此参数或者传入了nil类型,则使用默认值false
-        try_ipv6   -- bool或者nil类型,可选包含此参数,表示是否优先尝试ipv6地址,true表示优先尝试使用ipv6,false表示不尝试使用ipv6,如果没有传入此参数或者传入了nil类型,则使用默认值false
-        adapter    -- number或者nil类型,可选包含此参数,表示使用的网卡ID,例如4G网卡,SPI外挂以太网卡,WIFI网卡等;如果没有传入此参数,内核固件会自动选择当前时间点其他功能模块设置的默认网卡
-                   -- 除非你HTTP请求时,一定要使用某一种网卡,才设置此参数;如果没什么特别要求,不要使用此参数,使用系统中设置的默认网卡即可
-                   -- 这个参数和本demo中的netdrv_device.lua关系比较大,netdrv_device会设置默认网卡,此处http不要设置adapter参数,直接使用netdrv_device设置的默认网卡就行
-    }
-
-返回值定义:
-    httpplus.request(opts)有两个返回值code,response
-    code表示执行结果,number类型,有以下两种含义:
-        1、code大于等于100时,表示服务器返回的HTTP状态码,例如200表示成功,详细说明可以通过搜索引擎搜索“HTTP状态码”自行了解
-        2、code小于0时,表示内核固件中检测到通信异常,有如下几种:
-            -1 HTTP_ERROR_STATE 错误的状态, 一般是底层异常,请报issue
-            -2 HTTP_ERROR_HEADER 错误的响应头部, 通常是服务器问题
-            -3 HTTP_ERROR_BODY 错误的响应体,通常是服务器问题
-            -4 HTTP_ERROR_CONNECT 连接服务器失败, 未联网,地址错误,域名错误
-            -5 HTTP_ERROR_CLOSE 提前断开了连接, 网络或服务器问题
-            -6 HTTP_ERROR_RX 接收数据报错, 网络问题
-            -7 HTTP_ERROR_DOWNLOAD 下载文件过程报错, 网络问题或下载路径问题
-            -8 HTTP_ERROR_TIMEOUT 超时, 包括连接超时,读取数据超时
-            -9 HTTP_ERROR_FOTA fota功能报错,通常是更新包不合法     
-    response有以下两种含义
-        1、当code的返回值大于等于100时,response为table类型,包含以下两项内容
-           {
-               headers = {},    -- table类型,一个或者多个应答头,键值对的形式,可以使用json.encode(response.headers)在日志中打印
-               body = ,         -- zbuff类型,应答体数据;通过zbuff的query函数,可以转化为string类型:response.body:query();也可以通过uart.tx等支持zbuff的函数直接使用,例如uart.tx(1, response.body)
-           }
-        2、当code的返回值小于0时,response为nil
-]]
-
 local httpplus = require "httpplus"
 
 
@@ -314,7 +246,6 @@ local function httpplus_app_post_file()
 end
 
 
-
 -- http app task 的任务处理函数
 local function httpplus_app_task_func() 
     while true do

+ 10 - 4
module/Air8000/demo/http/netdrv/netdrv_4g.lua

@@ -13,6 +13,15 @@
 
 local function ip_ready_func(ip, adapter)
     if adapter == socket.LWIP_GP then
+        -- 在位置1和2设置自定义的DNS服务器ip地址:
+        -- "223.5.5.5",这个DNS服务器IP地址是阿里云提供的DNS服务器IP地址;
+        -- "114.114.114.114",这个DNS服务器IP地址是国内通用的DNS服务器IP地址;
+        -- 可以加上以下两行代码,在自动获取的DNS服务器工作不稳定的情况下,这两个新增的DNS服务器会使DNS服务更加稳定可靠;
+        -- 如果使用专网卡,不要使用这两行代码;
+        -- 如果使用国外的网络,不要使用这两行代码;
+        socket.setDNS(adapter, 1, "223.5.5.5")
+        socket.setDNS(adapter, 2, "114.114.114.114")
+        
         log.info("netdrv_4g.ip_ready_func", "IP_READY", socket.localIP(socket.LWIP_GP))
     end
 end
@@ -30,8 +39,5 @@ end
 sys.subscribe("IP_READY", ip_ready_func)
 sys.subscribe("IP_LOSE", ip_lose_func)
 
-
--- 设置默认网卡为socket.LWIP_GP
 -- 在Air8000上,内核固件运行起来之后,默认网卡就是socket.LWIP_GP
--- 在单4G网卡使用场景下,下面这一行代码加不加都没有影响,为了和其他网卡驱动模块的代码风格保持一致,所以加上了
-socket.dft(socket.LWIP_GP)
+

+ 36 - 54
module/Air8000/demo/http/netdrv/netdrv_eth_spi.lua

@@ -15,8 +15,19 @@
 本文件没有对外接口,直接在其他功能模块中require "netdrv_eth_spi"就可以加载运行;
 ]]
 
-local function ip_ready_func(ip, adapter)
+local exnetif = require "exnetif"
+
+local function ip_ready_func(ip, adapter)    
     if adapter == socket.LWIP_ETH then
+        -- 在位置1和2设置自定义的DNS服务器ip地址:
+        -- "223.5.5.5",这个DNS服务器IP地址是阿里云提供的DNS服务器IP地址;
+        -- "114.114.114.114",这个DNS服务器IP地址是国内通用的DNS服务器IP地址;
+        -- 可以加上以下两行代码,在自动获取的DNS服务器工作不稳定的情况下,这两个新增的DNS服务器会使DNS服务更加稳定可靠;
+        -- 如果使用专网卡,不要使用这两行代码;
+        -- 如果使用国外的网络,不要使用这两行代码;
+        socket.setDNS(adapter, 1, "223.5.5.5")
+        socket.setDNS(adapter, 2, "114.114.114.114")
+
         log.info("netdrv_eth_spi.ip_ready_func", "IP_READY", socket.localIP(socket.LWIP_ETH))
     end
 end
@@ -28,61 +39,32 @@ local function ip_lose_func(adapter)
 end
 
 
--- 此处订阅"IP_READY"和"IP_LOSE"两种消息
--- 在消息的处理函数中,仅仅打印了一些信息,便于实时观察“通过SPI外挂CH390H芯片的以太网卡”的连接状态
--- 也可以根据自己的项目需求,在消息处理函数中增加自己的业务逻辑控制,例如可以在连网状态发生改变时更新网络图标
-sys.subscribe("IP_READY", ip_ready_func)
-sys.subscribe("IP_LOSE", ip_lose_func)
+-- 以太网联网成功(成功连接路由器,并且获取到了IP地址)后,内核固件会产生一个"IP_READY"消息
+-- 各个功能模块可以订阅"IP_READY"消息实时处理以太网联网成功的事件
+-- 也可以在任何时刻调用socket.adapter(socket.LWIP_ETH)来获取以太网是否连接成功
 
+-- 以太网断网后,内核固件会产生一个"IP_LOSE"消息
+-- 各个功能模块可以订阅"IP_LOSE"消息实时处理以太网断网的事件
+-- 也可以在任何时刻调用socket.adapter(socket.LWIP_ETH)来获取以太网是否连接成功
 
--- 设置默认网卡为socket.LWIP_ETH
-socket.dft(socket.LWIP_ETH)
+--此处订阅"IP_READY"和"IP_LOSE"两种消息
+--在消息的处理函数中,仅仅打印了一些信息,便于实时观察“通过SPI外挂CH390H芯片的以太网卡”的连接状态
+--也可以根据自己的项目需求,在消息处理函数中增加自己的业务逻辑控制,例如可以在连网状态发生改变时更新网络图标
+sys.subscribe("IP_READY", ip_ready_func)
+sys.subscribe("IP_LOSE", ip_lose_func)
 
 
--- 本demo测试使用的是Air8000开发板
+-- 配置SPI外接以太网芯片CH390H的单网卡,exnetif.set_priority_order使用的网卡编号为socket.LWIP_ETH
+-- 本demo使用Air8000开发板测试,开发板上的硬件配置为:
 -- GPIO140为CH390H以太网芯片的供电使能控制引脚
-gpio.setup(140, 1, gpio.PULLUP)
-
--- 这个task的核心业务逻辑是:初始化SPI,初始化以太网卡,并在以太网卡上开启动态主机配置协议
-local function netdrv_eth_spi_task_func()
-    -- 初始化SPI1
-    local result = spi.setup(
-        1,--spi_id
-        nil,
-        0,--CPHA
-        0,--CPOL
-        8,--数据宽度
-        25600000--,--频率
-        -- spi.MSB,--高低位顺序    可选,默认高位在前
-        -- spi.master,--主模式     可选,默认主
-        -- spi.full--全双工       可选,默认全双工
-    )
-    log.info("netdrv_eth_spi", "spi open result", result)
-    --返回值为0,表示打开成功
-    if result ~= 0 then
-        log.error("netdrv_eth_spi", "spi open error",result)
-        return
-    end
-
-    -- 初始化以太网卡
-
-    -- 以太网联网成功(成功连接路由器,并且获取到了IP地址)后,内核固件会产生一个"IP_READY"消息
-    -- 各个功能模块可以订阅"IP_READY"消息实时处理以太网联网成功的事件
-    -- 也可以在任何时刻调用socket.adapter(socket.LWIP_ETH)来获取以太网是否连接成功
-
-    -- 以太网断网后,内核固件会产生一个"IP_LOSE"消息
-    -- 各个功能模块可以订阅"IP_LOSE"消息实时处理以太网断网的事件
-    -- 也可以在任何时刻调用socket.adapter(socket.LWIP_ETH)来获取以太网是否连接成功
-
-    -- socket.LWIP_ETH 指定网络适配器编号
-    -- netdrv.CH390外挂CH390
-    -- SPI ID 1, 片选 GPIO12
-    netdrv.setup(socket.LWIP_ETH, netdrv.CH390, {spi=1, cs=12})
-
-    -- 在以太网上开启动态主机配置协议
-    netdrv.dhcp(socket.LWIP_ETH, true)
-end
-
--- 创建并且启动一个task
--- task的处理函数为netdrv_eth_spi_task_func
-sys.taskInit(netdrv_eth_spi_task_func)
+-- 使用spi1,片选引脚使用GPIO12
+-- 如果使用的硬件不是Air8000开发板,根据自己的硬件配置修改以下参数
+exnetif.set_priority_order({
+    {
+        ETHERNET = {
+            pwrpin = 140, 
+            tp = netdrv.CH390,
+            opts = {spi = 1, cs = 12}
+        }
+    }
+})

+ 9 - 0
module/Air8000/demo/http/netdrv/netdrv_multiple.lua

@@ -24,6 +24,15 @@ local exnetif = require "exnetif"
 --     net_type:为nil
 --     adapter:number类型,为-1
 local function netdrv_multiple_notify_cbfunc(net_type,adapter)
+    -- 在位置1和2设置自定义的DNS服务器ip地址:
+    -- "223.5.5.5",这个DNS服务器IP地址是阿里云提供的DNS服务器IP地址;
+    -- "114.114.114.114",这个DNS服务器IP地址是国内通用的DNS服务器IP地址;
+    -- 可以加上以下两行代码,在自动获取的DNS服务器工作不稳定的情况下,这两个新增的DNS服务器会使DNS服务更加稳定可靠;
+    -- 如果使用专网卡,不要使用这两行代码;
+    -- 如果使用国外的网络,不要使用这两行代码;
+    socket.setDNS(adapter, 1, "223.5.5.5")
+    socket.setDNS(adapter, 2, "114.114.114.114")
+    
     if type(net_type)=="string" then
         log.info("netdrv_multiple_notify_cbfunc", "use new adapter", net_type, adapter)
     elseif type(net_type)=="nil" then

+ 46 - 0
module/Air8000/demo/http/netdrv/netdrv_pc.lua

@@ -0,0 +1,46 @@
+--[[
+@module  netdrv_pc
+@summary “pc模拟器网卡”驱动模块 
+@version 1.0
+@date    2025.07.01
+@author  朱天华
+@usage
+本文件为pc模拟器网卡驱动模块,核心业务逻辑为:
+1、监听"IP_READY"和"IP_LOSE",在日志中进行打印;
+
+本文件没有对外接口,直接在其他功能模块中require "netdrv_pc"就可以加载运行;
+]]
+
+local function ip_ready_func(ip, adapter)    
+    if adapter == socket.ETH0 then
+        -- 在位置1和2设置自定义的DNS服务器ip地址:
+        -- "223.5.5.5",这个DNS服务器IP地址是阿里云提供的DNS服务器IP地址;
+        -- "114.114.114.114",这个DNS服务器IP地址是国内通用的DNS服务器IP地址;
+        -- 可以加上以下两行代码,在自动获取的DNS服务器工作不稳定的情况下,这两个新增的DNS服务器会使DNS服务更加稳定可靠;
+        -- 如果使用专网卡,不要使用这两行代码;
+        -- 如果使用国外的网络,不要使用这两行代码;
+        socket.setDNS(adapter, 1, "223.5.5.5")
+        socket.setDNS(adapter, 2, "114.114.114.114")
+
+        log.info("netdrv_pc.ip_ready_func", "IP_READY", socket.localIP(socket.ETH0))
+    end
+end
+
+local function ip_lose_func(adapter)    
+    if adapter == socket.ETH0 then
+        log.warn("netdrv_pc.ip_lose_func", "IP_LOSE")
+    end
+end
+
+
+
+--此处订阅"IP_READY"和"IP_LOSE"两种消息
+--在消息的处理函数中,仅仅打印了一些信息,便于实时观察pc模拟器网络的连接状态
+--也可以根据自己的项目需求,在消息处理函数中增加自己的业务逻辑控制,例如可以在连网状态发生改变时更新网络图标
+sys.subscribe("IP_READY", ip_ready_func)
+sys.subscribe("IP_LOSE", ip_lose_func)
+
+-- 设置默认网卡为socket.ETH0
+-- pc模拟器上的默认网卡仍然需要使用接口(socket.ETH0)来设置,因为exnetif扩展库当前还不支持模拟器
+socket.dft(socket.ETH0)
+

+ 36 - 21
module/Air8000/demo/http/netdrv/netdrv_wifi.lua

@@ -13,9 +13,20 @@
 本文件没有对外接口,直接在其他功能模块中require "netdrv_wifi"就可以加载运行;
 ]]
 
+local exnetif = require "exnetif"
+
 local function ip_ready_func(ip, adapter)
     if adapter == socket.LWIP_STA then
-        log.info("netdrv_wifi.ip_ready_func", "IP_READY", json.encode(wlan.getInfo()))
+        -- 在位置1和2设置自定义的DNS服务器ip地址:
+        -- "223.5.5.5",这个DNS服务器IP地址是阿里云提供的DNS服务器IP地址;
+        -- "114.114.114.114",这个DNS服务器IP地址是国内通用的DNS服务器IP地址;
+        -- 可以加上以下两行代码,在自动获取的DNS服务器工作不稳定的情况下,这两个新增的DNS服务器会使DNS服务更加稳定可靠;
+        -- 如果使用专网卡,不要使用这两行代码;
+        -- 如果使用国外的网络,不要使用这两行代码;
+        socket.setDNS(adapter, 1, "223.5.5.5")
+        socket.setDNS(adapter, 2, "114.114.114.114")
+
+        log.info("netdrv_wifi.ip_ready_func", "IP_READY", socket.localIP(socket.LWIP_STA))
     end
 end
 
@@ -26,28 +37,32 @@ local function ip_lose_func(adapter)
 end
 
 
--- 此处订阅"IP_READY"和"IP_LOSE"两种消息
--- 在消息的处理函数中,仅仅打印了一些信息,便于实时观察WIFI的连接状态
--- 也可以根据自己的项目需求,在消息处理函数中增加自己的业务逻辑控制,例如可以在连网状态发生改变时更新网络图标
-sys.subscribe("IP_READY", ip_ready_func)
-sys.subscribe("IP_LOSE", ip_lose_func)
+--WIFI联网成功(做为STATION成功连接AP,并且获取到了IP地址)后,内核固件会产生一个"IP_READY"消息
+--各个功能模块可以订阅"IP_READY"消息实时处理WIFI联网成功的事件
+--也可以在任何时刻调用socket.adapter(socket.LWIP_STA)来获取WIFI网络是否连接成功
 
+--WIFI断网后,内核固件会产生一个"IP_LOSE"消息
+--各个功能模块可以订阅"IP_LOSE"消息实时处理WIFI断网的事件
+--也可以在任何时刻调用socket.adapter(socket.LWIP_STA)来获取WIFI网络是否连接成功
 
--- 设置默认网卡为socket.LWIP_STA
-socket.dft(socket.LWIP_STA)
-
+--此处订阅"IP_READY"和"IP_LOSE"两种消息
+--在消息的处理函数中,仅仅打印了一些信息,便于实时观察WIFI的连接状态
+--也可以根据自己的项目需求,在消息处理函数中增加自己的业务逻辑控制,例如可以在连网状态发生改变时更新网络图标
+sys.subscribe("IP_READY", ip_ready_func)
+sys.subscribe("IP_LOSE", ip_lose_func)
 
-wlan.init()
--- 连接WIFI热点,连接结果会通过"IP_READY"或者"IP_LOSE"消息通知
--- Air8000仅支持2.4G的WIFI,不支持5G的WIFI
--- 此处前两个参数表示WIFI热点名称以及密码,更换为自己测试时的真实参数即可
--- 第三个参数1表示WIFI连接异常时,内核固件会自动重连
-wlan.connect("茶室-降功耗,找合宙!", "Air123456", 1)
 
--- WIFI联网成功(做为STATION成功连接AP,并且获取到了IP地址)后,内核固件会产生一个"IP_READY"消息
--- 各个功能模块可以订阅"IP_READY"消息实时处理WIFI联网成功的事件
--- 也可以在任何时刻调用socket.adapter(socket.LWIP_STA)来获取WIFI网络是否连接成功
+-- 配置WiFi设备模式的单网卡,exnetif.set_priority_order使用的网卡编号为socket.LWIP_STA
+-- ssid为要连接的WiFi路由器名称;
+-- password为要连接的WiFi路由器密码;
+-- 注意:仅支持2.4G的WiFi,不支持5G的WiFi;
+-- 实际测试时,根据自己要连接的WiFi热点信息修改以下参数
+exnetif.set_priority_order({
+    {
+        WIFI = {
+            ssid = "茶室-降功耗,找合宙!", 
+            password = "Air123456"
+        }
+    }
+})
 
--- WIFI断网后,内核固件会产生一个"IP_LOSE"消息
--- 各个功能模块可以订阅"IP_LOSE"消息实时处理WIFI断网的事件
--- 也可以在任何时刻调用socket.adapter(socket.LWIP_STA)来获取WIFI网络是否连接成功

+ 4 - 0
module/Air8000/demo/http/netdrv_device.lua

@@ -10,6 +10,7 @@
 2、netdrv_wifi:socket.LWIP_STA,WIFI STA网卡;
 3、netdrv_ethernet_spi:socket.LWIP_ETH,通过SPI外挂CH390H芯片的以太网卡;
 4、netdrv_multiple:可以配置多种网卡的优先级,按照优先级配置,使用其中一种网卡连接外网;
+5、netdrv_pc:pc模拟器上的网卡
 
 根据自己的项目需求,只需要require以上四种中的一种即可;
 
@@ -31,3 +32,6 @@ require "netdrv_4g"
 
 -- 加载“可以配置优先级的多种网卡”驱动模块
 -- require "netdrv_multiple"
+
+-- 加载“pc模拟器网卡”驱动模块
+-- require "netdrv_pc"

+ 6 - 5
module/Air8000/demo/tf_card/http_download_file.lua

@@ -42,15 +42,16 @@ local function http_download_file_task()
         return
     end
 
+
     -- 阶段2: 执行下载任务
     log.info("HTTP下载", "开始下载任务")
 
     -- 核心下载操作开始 (支持http和https)
-    --local code, headers, body = http.request("GET", "...", nil, nil, {dst = "/sd/1.mp3"}).wait()
-    -- 其中 "..."为url地址, 支持 http和https, 支持域名, 支持自定义端口。
+    local code, headers, body = http.request("GET", "...", nil, nil, {dst = "/sd/1.mp3"}).wait()
+    其中 "..."为url地址, 支持 http和https, 支持域名, 支持自定义端口。
     local code, headers, body_size = http.request("GET",
-                                    "https://gitee.com/openLuat/LuatOS/raw/master/module/Air780EHM_Air780EHV_Air780EGH/demo/audio/1.mp3",
-                                    nil, nil, {dst = "/sd/1.mp3"}).wait()
+                                    "https://cdn.openluat-erp.openluat.com/erp_site_file/product_file/AirM2M_780EHT_V2017_LTE_AT.dfota.bin",
+                                    nil, nil, {dst = "/sd/3_23MB.bin"}).wait()
     -- 阶段3: 记录下载结果
     log.info("HTTP下载", "下载完成", 
         code==200 and "success" or "error", 
@@ -62,7 +63,7 @@ local function http_download_file_task()
         
     if code == 200 then
         -- 获取实际文件大小
-        local actual_size = io.fileSize("/sd/1.mp3")
+        local actual_size = io.fileSize("/sd/3_23MB.bin")
         log.info("HTTP下载", "文件大小验证", "预期:", body_size, "实际:", actual_size)
         
         if actual_size~= body_size then

+ 1 - 1
module/Air8000/demo/tf_card/http_upload_file.lua

@@ -43,7 +43,7 @@ local function http_upload_task()
 
     -- 阶段3: 检查要上传的文件是否存在
     -- 替换为实际的文件路径
-    local upload_file_path = "/sd/30M_test.txt" 
+    local upload_file_path = "/sd/3_23MB.bin" 
     if not io.exists(upload_file_path) then
         log.error("HTTP上传", "要上传的文件不存在", upload_file_path)
         fatfs.unmount("/sd")

+ 2 - 2
module/Air8101/demo/accessory_board/AirPHY_1000/network_routing/wifi_out_ethernet_in_wifi_in/netif_app.lua

@@ -24,7 +24,7 @@ function netif_app_task_func()
         },                              -- 最大客户端数量, 默认4
         channel = 6,                    -- AP建立的通道, 默认6
         main_adapter = {                -- 提供网络的网卡开启参数
-            ssid = "iPhone", 
+            ssid = "iPhone",            -- WIFI的名称和密码根据实际修改
             password = "xiaoshuai"
         }
     })
@@ -32,7 +32,7 @@ function netif_app_task_func()
     res = exnetif.setproxy(socket.LWIP_ETH, socket.LWIP_STA, {
         ethpower_en = 13,               -- 以太网模块的pwrpin引脚(gpio编号)
         main_adapter = {                -- 提供网络的网卡开启参数
-            ssid = "iPhone", 
+            ssid = "iPhone",            -- WIFI的名称和密码根据实际修改
             password = "xiaoshuai"
         }
     })

+ 3 - 5
module/Air8101/demo/accessory_board/AirPHY_1000/network_routing/wifi_out_ethernet_in_wifi_in/readme.md

@@ -59,15 +59,13 @@ Air8101核心板和AirPHY_1000配件板的硬件接线方式为:
 ssid = "WIFI名称"
 password = "WiFi密码"
 
-3、如果使用spi方式外挂网卡,打开SPI方式外挂网卡的代码,注释掉RMII方式外挂网卡的代码
+3、内核固件和本项目的Lua脚本:main.lua:主程序入口,netif_app.lua:网络管理模块
 
-4、内核固件和本项目的Lua脚本:main.lua:主程序入口,netif_app.lua:网络管理模块
-
-5、启动设备,观察日志输出:
+4、启动设备,观察日志输出:
 
 ```lua
 [INFO] exnetif setproxy success
 [INFO] http执行结果 200 ... 
 ```
 
-6、其他设备通过wifi或以太网接入Air8101,其他设备都能正常上网,则表示验证成功。
+5、其他设备通过wifi或以太网接入Air8101,其他设备都能正常上网,则表示验证成功。

+ 3 - 1
module/Air8101/demo/accessory_board/AirPHY_1000/readme.md

@@ -6,4 +6,6 @@
 
 2、network_routing:
 
-(1)使用网络路由功能,以太网提供网络供以太网和wifi设备上网
+(1)使用网络路由功能,8101连接外部WIFI提供网络供以太网和wifi设备上网
+
+

+ 3 - 3
olddemo/camera/spi_cam/main.lua

@@ -152,9 +152,9 @@ local function device_init()
 
 end
 
-local function pdwn(level)
+local function pdwn(id, level)
     if hmeta.chip() == "UIS8910" then
-        camera.pwdn_pin(level)
+        camera.pwdn_pin(id, level)
     else
         gpio.setup(5, level) -- PD拉低
     end
@@ -185,7 +185,7 @@ sys.taskInit(function()
 
     local camera_id = device_init()
 	camera.on(camera_id, "scanned", cb)
-    pdwn(0)
+    pdwn(camera_id, 0)
     if DONE_WITH_CLOSE then
         camera.close(camera_id)
     else

+ 60 - 0
olddemo/crypto/main.lua

@@ -232,6 +232,66 @@ sys.taskInit(function()
         log.info("crypto", "当前固件不支持crypto.crc7")
     end
 
+    local originStr = "123456sdfdsfdsfdsffdsfdsfsdfs1234"
+    local crc16 = crypto.crc16("IBM",originStr)
+    log.info("crc16_IBM", crc16)
+    -- 计算CRC16_MAXIM
+    
+    crc16 = crypto.crc16("MAXIM",originStr)
+    log.info("crc16_MAXIM", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("USB",originStr)
+    log.info("crc16_USB", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("MODBUS",originStr)
+    log.info("crc16_MODBUS", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("CCITT",originStr)
+    log.info("crc16_CCITT", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("CCITT-FALSE",originStr)
+    log.info("crc16_CCITT-FALSE", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("X25",originStr)
+    log.info("crc16_X25", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("XMODEM",originStr)
+    log.info("crc16_XMODEM", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("DNP",originStr)
+    log.info("crc16_DNP", crc16)
+    -- 计算CRC16_modbus
+    
+    crc16 = crypto.crc16("USER-DEFINE",originStr)
+    log.info("crc16_USER-DEFINE", crc16)
+    
+    -- 计算CRC16 modbus
+    crc16 = crypto.crc16_modbus("123456sdfdsfdsfdsffdsfdsfsdfs1234")
+    log.info("crc16", crc16)
+    crc16 = crypto.crc16_modbus("123456sdfdsfdsfdsffdsfdsfsdfs1234", 0xFFFF)
+    log.info("crc16", crc16)
+    
+    -- 计算CRC32
+    local data = "123456sdfdsfdsfdsffdsfdsfsdfs1234" 
+    local crc32 = crypto.crc32(data)
+    log.info("crc32", crc32) --21438764
+    -- start和poly可选, 是 2025.4.14 新增的参数
+    local crc32 = crypto.crc32(data, 0xFFFFFFFF, 0x04C11DB7, 0xFFFFFFFF) --等同于crypto.crc32(data)
+    log.info("crc32", crc32)
+
+    -- 计算CRC8
+    local data= "sdfdsfdsfdsffdsfdsfsdfs1234"
+    local crc8 = crypto.crc8(data)
+    log.info("crc8", crc8)
+    local crc8 = crypto.crc8(data, 0x31, 0xff, false)
+    log.info("crc8", crc8)  
     
     -- crypto.md测试, 要测试输出长度
     log.info("crypto.md测试")

+ 2 - 2
olddemo/lcd_qspi/main.lua

@@ -15,11 +15,11 @@ sys.taskInit(function()
     gpio.setup(16,1)    --打开jd9261t LCD电源,根据板子实际情况修改
     gpio.setup(17,1)    --打开co5300 LCD电源,根据板子实际情况修改
 
-    co5300_init({port = lcd.HWID_0, pin_dc = -1, pin_pwr = -1, pin_rst = 36, w = 480, h = 466, interface_mode=lcd.QSPI_MODE,bus_speed=50000000, rb_swap = true})
+    -- co5300_init({port = lcd.HWID_0, pin_dc = -1, pin_pwr = -1, pin_rst = 36, w = 480, h = 466, interface_mode=lcd.QSPI_MODE,bus_speed=50000000, rb_swap = true})
     -- jd9261t_init({port = lcd.HWID_0,pin_dc = -1, pin_pwr = 27, pin_rst = 36, w = 480,h = 480, interface_mode=lcd.QSPI_MODE, bus_speed=60000000,flush_rate=659,vbp=19,vfp=108,vs=2,rb_swap=true})
     -- jd9261t_init({port = lcd.HWID_0,pin_dc = -1, pin_pwr = 27, pin_rst = 36, w = 540,h = 540, interface_mode=lcd.QSPI_MODE, bus_speed=80000000,flush_rate=600,vbp=10,vfp=108,vs=2,rb_swap=true})
     -- jd9261t_init({port = lcd.HWID_0,pin_dc = -1, pin_pwr = 27, pin_rst = 36, w = 720,h = 720, interface_mode=lcd.QSPI_MODE, bus_speed=60000000,flush_rate=300,vbp=10,vfp=160,vs=2,rb_swap=true})
-    -- sh8601z_init({port = lcd.HWID_0, pin_dc = -1, pin_pwr = -1, pin_rst = 36, w = 368, h = 448, interface_mode=lcd.QSPI_MODE,bus_speed=80000000, rb_swap = true})
+    sh8601z_init({port = lcd.HWID_0, pin_dc = -1, pin_pwr = -1, pin_rst = 36, w = 368, h = 448, interface_mode=lcd.QSPI_MODE,bus_speed=80000000, rb_swap = false})
     lcd.setupBuff(nil, false)
     lcd.autoFlush(false)
     lcd.user_done() --必须在初始化完成后,在正式显示之前

+ 12 - 14
olddemo/lcd_qspi/sh8601z.lua

@@ -8,20 +8,18 @@ function sh8601z_init(lcd_cfg)
     sys.wait(50)
     lcd.wakeup()
     sys.wait(100)
-    -- 演示一下用zbuff传参数,和下面的直接传参数是等效的
-    local param = zbuff.create(1)
-    param[0] = 0x00
-    lcd.cmd(0x36, param, 1) --方向
-    param[0] = 0x55
-    lcd.cmd(0x3a, param, 1)
-    param[0] = 0x20
-    lcd.cmd(0x53, param, 1)
-    param[0] = 0xff
-    lcd.cmd(0x51, param, 1)
 
-    -- lcd.cmd(0x36, 0x00) --方向
-    -- lcd.cmd(0x3a, 0x55)
-    -- lcd.cmd(0x53, 0x20)
-    -- lcd.cmd(0x51, 0xff)
+    local param = zbuff.create(2)
+
+    lcd.cmd(0x36, 0x00) --方向
+    lcd.cmd(0x3a, 0x55)
+    lcd.cmd(0x53, 0x20)
+    lcd.cmd(0x51, 0xff)
+	param[0] = 0x5a
+	param[1] = 0x5a
+	lcd.cmd(0xc0, param, 2) --2个字节以上的参数必须用zbuff
+	lcd.cmd(0xc1, param, 2)
+	lcd.cmd(0xb0, 0x33)
+	lcd.cmd(0xb1, 0x02)
     lcd.cmd(0x29)
 end

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff