Răsfoiți Sursa

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

Wendal Chen 3 ani în urmă
părinte
comite
9f60e21a84
73 a modificat fișierele cu 157 adăugiri și 87 ștergeri
  1. 1 0
      components/camera/luat_lib_camera.c
  2. 1 0
      components/coremark/luat_lib_coremark.c
  3. 4 3
      components/eink/luat_lib_eink.c
  4. 1 0
      components/ethernet/w5500/luat_lib_w5500.c
  5. 2 1
      components/flashdb/src/luat_lib_fdb.c
  6. 2 1
      components/gtfont/luat_lib_gtfont.c
  7. 1 0
      components/io_queue/luat_lib_io_queue.c
  8. 16 15
      components/iotauth/luat_lib_iotauth.c
  9. 3 2
      components/lcd/luat_lib_lcd.c
  10. 1 0
      components/lora/luat_lib_lora.c
  11. 2 1
      components/lua-cjson/lua_cjson.c
  12. 1 0
      components/luatfonts/luat_lib_fonts.c
  13. 2 0
      components/lvgl/binding/luat_lib_lvgl_anim.c
  14. 1 0
      components/miniz/luat_lib_miniz.c
  15. 8 7
      components/minmea/luat_lib_libgnss.c
  16. 1 0
      components/mlx90640-library/luat_lib_mlx90640.c
  17. 1 0
      components/mobile/luat_lib_mobile.c
  18. 1 0
      components/multimedia/luat_lib_multimedia.c
  19. 1 0
      components/network/adapter/luat_lib_socket.c
  20. 1 0
      components/network/httpsrv/src/luat_lib_httpsrv.c
  21. 1 0
      components/network/libemqtt/luat_lib_mqtt.c
  22. 20 12
      components/network/libhttp/luat_lib_http.c
  23. 1 0
      components/nimble/src/luat_lib_nimble.c
  24. 1 0
      components/rsa/binding/luat_lib_rsa.c
  25. 1 0
      components/serialization/protobuf/luat_lib_protobuf.c
  26. 1 0
      components/sfd/luat_lib_sfd.c
  27. 1 0
      components/sfud/luat_lib_sfud.c
  28. 1 0
      components/statem/luat_lib_statem.c
  29. 1 0
      components/u8g2/luat_lib_disp.c
  30. 1 0
      components/u8g2/luat_lib_u8g2.c
  31. 1 0
      components/usbapp/luat_lib_usbapp.c
  32. 1 0
      components/wlan/luat_lib_wlan.c
  33. 1 0
      components/zlib/luat_lib_zlib.c
  34. 7 11
      demo/socket/Air105/http_demo.lua
  35. 14 14
      demo/socket/EC618/http_demo.lua
  36. 1 1
      demo/wlan/esp32c3/hello_world/main.lua
  37. 4 3
      lua/src/liolib.c
  38. 1 0
      lua/src/lstrlib_exts.c
  39. 1 0
      luat/include/luat_libs.h
  40. 1 0
      luat/modules/luat_lib_adc.c
  41. 2 1
      luat/modules/luat_lib_crypto.c
  42. 1 0
      luat/modules/luat_lib_dac.c
  43. 1 0
      luat/modules/luat_lib_fota.c
  44. 1 0
      luat/modules/luat_lib_fs.c
  45. 1 0
      luat/modules/luat_lib_gpio.c
  46. 1 0
      luat/modules/luat_lib_i2c.c
  47. 1 0
      luat/modules/luat_lib_i2s.c
  48. 1 0
      luat/modules/luat_lib_ir.c
  49. 4 3
      luat/modules/luat_lib_keyboard.c
  50. 1 0
      luat/modules/luat_lib_lcdseg.c
  51. 3 2
      luat/modules/luat_lib_libcoap.c
  52. 1 0
      luat/modules/luat_lib_log.c
  53. 4 3
      luat/modules/luat_lib_lpmem.c
  54. 1 0
      luat/modules/luat_lib_mcu.c
  55. 1 0
      luat/modules/luat_lib_otp.c
  56. 1 0
      luat/modules/luat_lib_pack.c
  57. 1 0
      luat/modules/luat_lib_pm.c
  58. 1 0
      luat/modules/luat_lib_pwm.c
  59. 1 0
      luat/modules/luat_lib_rtc.c
  60. 1 0
      luat/modules/luat_lib_rtos.c
  61. 1 0
      luat/modules/luat_lib_sdio.c
  62. 1 0
      luat/modules/luat_lib_sensor.c
  63. 1 0
      luat/modules/luat_lib_spi.c
  64. 1 0
      luat/modules/luat_lib_sys_doc.c
  65. 1 0
      luat/modules/luat_lib_timer.c
  66. 1 0
      luat/modules/luat_lib_touchkey.c
  67. 1 0
      luat/modules/luat_lib_uart.c
  68. 1 0
      luat/modules/luat_lib_wdt.c
  69. 1 0
      luat/modules/luat_lib_zbuff.c
  70. 2 2
      script/turnkey/EinkBook/Scripts/main.lua
  71. 3 3
      script/turnkey/eink-calendar/main.lua
  72. 1 1
      tools/api_get.py
  73. 1 1
      tools/make_doc_file.py

+ 1 - 0
components/camera/luat_lib_camera.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2022.01.11
 @demo camera
+@tag LUAT_USE_CAMERA
 */
 #include "luat_base.h"
 #include "luat_camera.h"

+ 1 - 0
components/coremark/luat_lib_coremark.c

@@ -3,6 +3,7 @@
 @summary 跑分
 @version 1.0
 @date    2022.01.11
+@tag LUAT_USE_COREMARK
 */
 #include "luat_base.h"
 

+ 4 - 3
components/eink/luat_lib_eink.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2020.11.14
 @demo eink
+@tag LUAT_USE_EINK
 */
 #include "luat_base.h"
 #include "luat_log.h"
@@ -500,7 +501,7 @@ static int l_eink_print(lua_State *L)
     int y           = luaL_checkinteger(L, 2);
     const char *str = luaL_checklstring(L, 3, &len);
 
-    
+
     if (check_init() == 0) {
       return 0;
     }
@@ -553,7 +554,7 @@ static int l_eink_show(lua_State *L)
     /* Display the frame_buffer */
     //EPD_SetFrameMemory(&epd, frame_buffer, x, y, Paint_GetWidth(&ctxs[ctx_index]->paint), Paint_GetHeight(&ctxs[ctx_index]->paint));
     //EPD_DisplayFrame(&epd);
-    
+
     if (check_init() == 0) {
       return 0;
     }
@@ -641,7 +642,7 @@ static int l_eink_rect(lua_State *L)
     int y2      = luaL_checkinteger(L, 4);
     int colored = luaL_optinteger(L, 5, 0);
     int fill    = luaL_optinteger(L, 6, 0);
-  
+
     if (check_init() == 0) {
       return 0;
     }

+ 1 - 0
components/ethernet/w5500/luat_lib_w5500.c

@@ -3,6 +3,7 @@
 @summary w5500以太网驱动
 @version 1.0
 @date    2022.04.11
+@tag LUAT_USE_W5500
 */
 
 #include "luat_base.h"

+ 2 - 1
components/flashdb/src/luat_lib_fdb.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.11.03
 @demo fdb
+@tag LUAT_USE_FDB
 */
 
 #include "luat_base.h"
@@ -212,7 +213,7 @@ static int l_fdb_kv_get(lua_State *L) {
     blob.buf = buff.b;
     blob.size = buff.size;
     size_t read_len = fdb_kv_get_blob(kvdb, key, &blob);
-    
+
     lua_Integer *intVal;
     // lua_Number *numVal;
 

+ 2 - 1
components/gtfont/luat_lib_gtfont.c

@@ -3,6 +3,7 @@
 @summary gtfont高通字库模块
 @version 1.0
 @date    2021.11.11
+@tag LUAT_USE_GTFONT
 */
 
 #include "luat_base.h"
@@ -23,7 +24,7 @@ void gtfont_draw_w(unsigned char *pBits,unsigned int x,unsigned int y,unsigned i
 	unsigned int i,j,k,n;
 	unsigned char temp;
 	n = 0;
-	
+
 	for( i = 0;i < high; i++){
 		for( j = 0;j < ((widt+7)>> 3);j++){
 			temp = pBits[n++];

+ 1 - 0
components/io_queue/luat_lib_io_queue.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2022.03.13
 @demo io_queue
+@tag LUAT_USE_IO_QUEUE
 */
 #include "luat_base.h"
 #include "luat_multimedia.h"

+ 16 - 15
components/iotauth/luat_lib_iotauth.c

@@ -5,6 +5,7 @@
 @version core V0007
 @date    2022.08.06
 @demo iotauth
+@tag LUAT_USE_IOTAUTH
 */
 #include "luat_base.h"
 #include "luat_crypto.h"
@@ -87,9 +88,9 @@ static void aliyun_token(const char* product_key,const char* device_name,const c
 /*
 阿里云物联网平台三元组生成
 @api iotauth.aliyun(product_key, device_name,device_secret,method,cur_timestamp)
-@string product_key 
-@string device_name 
-@string device_secret 
+@string product_key
+@string device_name
+@string device_secret
 @string method 加密方式,"hmacmd5" "hmacsha1" "hmacsha256" 可选,默认"hmacsha256"
 @number cur_timestamp 可选
 @return string mqtt三元组 client_id
@@ -209,9 +210,9 @@ static void onenet_token(const char* product_id,const char* device_name,const ch
 /*
 中国移动物联网平台三元组生成
 @api iotauth.onenet(produt_id, device_name,key,method,cur_timestamp,version)
-@string produt_id 
-@string device_name 
-@string key 
+@string produt_id
+@string device_name
+@string key
 @string method 加密方式,"md5" "sha1" "sha256" 可选,默认"md5"
 @number cur_timestamp 可选
 @string version 可选 默认"2018-10-31"
@@ -253,8 +254,8 @@ static void iotda_token(const char* device_id,const char* device_secret,long lon
 /*
 华为物联网平台三元组生成
 @api iotauth.iotda(device_id,device_secret,ins_timestamp,cur_timestamp)
-@string device_id 
-@string device_secret 
+@string device_id
+@string device_secret
 @number ins_timestamp 是否校验时间戳 1:校验 0:不校验
 @number cur_timestamp 可选
 @return string mqtt三元组 client_id
@@ -335,9 +336,9 @@ static void qcloud_token(const char* product_id,const char* device_name,const ch
 /*
 腾讯联网平台三元组生成
 @api iotauth.qcloud(product_id, device_name,device_secret,method,cur_timestamp,sdk_appid)
-@string product_id 
-@string device_name 
-@string device_secret 
+@string product_id
+@string device_name
+@string device_secret
 @string method 加密方式,"sha1" "sha256" 可选,默认"sha256"
 @number cur_timestamp 可选
 @string sdk_appid 可选 默认为"12010126"
@@ -383,7 +384,7 @@ static void tuya_token(const char* device_id,const char* device_secret,long long
 涂鸦联网平台三元组生成
 @api iotauth.tuya(device_id,device_secret,cur_timestamp)
 @string device_id
-@string device_secret 
+@string device_secret
 @number cur_timestamp 可选
 @return string mqtt三元组 client_id
 @return string mqtt三元组 user_name
@@ -432,9 +433,9 @@ static void baidu_token(const char* iot_core_id,const char* device_key,const cha
 /*
 百度物联网平台三元组生成
 @api iotauth.baidu(iot_core_id, device_key,device_secret,method,cur_timestamp)
-@string iot_core_id 
-@string device_key 
-@string device_secret 
+@string iot_core_id
+@string device_key
+@string device_secret
 @string method 加密方式,"MD5" "SHA256" 可选,默认"MD5"
 @number cur_timestamp 可选
 @return string mqtt三元组 client_id

+ 3 - 2
components/lcd/luat_lib_lcd.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.06.16
 @demo lcd
+@tag LUAT_USE_LCD
 */
 #include "luat_base.h"
 #include "luat_lcd.h"
@@ -1590,7 +1591,7 @@ static const int l_lcd_draw_utf8(lua_State *L) {
             luat_lcd_draw(default_conf, draw_x, y, draw_x + desc.char_w - 1, y + font->line_height - 1, buff);
           //}
           //else {
-          // 
+          //
           //}
         }
     }
@@ -1598,7 +1599,7 @@ static const int l_lcd_draw_utf8(lua_State *L) {
       luat_heap_free(buff);
 
     lcd_auto_flush(default_conf);
-    lua_pushinteger(L, draw_x + desc.char_w);  
+    lua_pushinteger(L, draw_x + desc.char_w);
     return 1;
 }
 #endif

+ 1 - 0
components/lora/luat_lib_lora.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.06.24
 @demo lora
+@tag LUAT_USE_LORA
 */
 
 #include "luat_base.h"

+ 2 - 1
components/lua-cjson/lua_cjson.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2020.02.18
 @demo json
+@tag LUAT_USE_CJSON
 */
 /* Lua CJSON - JSON support for Lua
  *
@@ -709,7 +710,7 @@ static int json_encode(lua_State *l)
 
     luaL_argcheck(l, lua_gettop(l) == 1, 1, "expected 1 argument");
 
-    
+
     encode_buf = &local_encode_buf;
     ret = strbuf_init(encode_buf, 0);
     if (ret) {

+ 1 - 0
components/luatfonts/luat_lib_fonts.c

@@ -3,6 +3,7 @@
 @summary 字体库
 @version 1.0
 @date    2022.07.11
+@tag LUAT_USE_FONTS
 */
 
 #include "luat_base.h"

+ 2 - 0
components/lvgl/binding/luat_lib_lvgl_anim.c

@@ -3,6 +3,8 @@
 @summary LVGL图像库
 @version 1.0
 @date    2021.06.01
+@demo lvgl
+@tag LUAT_USE_LVGL
 */
 
 #include "luat_base.h"

+ 1 - 0
components/miniz/luat_lib_miniz.c

@@ -3,6 +3,7 @@
 @summary 简易zlib压缩
 @version 1.0
 @date    2022.8.11
+@tag LUAT_USE_MINIZ
 @usage
 -- 准备好数据
 local bigdata = "123jfoiq4hlkfjbnasdilfhuqwo;hfashfp9qw38hrfaios;hfiuoaghfluaeisw"

+ 8 - 7
components/minmea/luat_lib_libgnss.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2020.07.03
 @demo libgnss
+@tag LUAT_USE_LIBGNSS
 */
 #include "luat_base.h"
 #include "luat_msgbus.h"
@@ -41,7 +42,7 @@ static int luat_libgnss_init(lua_State *L) {
             LLOGW("out of memory for libgnss data parse");
             return 0;
         }
-        gnsstmp = luat_heap_malloc(sizeof(luat_libgnss_t)); 
+        gnsstmp = luat_heap_malloc(sizeof(luat_libgnss_t));
         if (gnsstmp == NULL) {
             luat_heap_free(gnss);
             LLOGW("out of memory for libgnss data parse");
@@ -62,7 +63,7 @@ static int parse_nmea(const char* line, lua_State *L) {
     if (gnss == NULL && luat_libgnss_init(L)) {
         return 0;
     }
-    
+
     switch (minmea_sentence_id(line, false)) {
         case MINMEA_SENTENCE_RMC: {
             if (minmea_parse_rmc(&(gnsstmp->frame_rmc), line)) {
@@ -206,7 +207,7 @@ static int l_libgnss_parse(lua_State *L) {
             prev = i;
         }
     }
-    
+
     return 0;
 }
 
@@ -265,7 +266,7 @@ static int l_libgnss_get_rmc(lua_State *L) {
     lua_createtable(L, 0, 12);
 
     if (gnss != NULL) {
-        
+
         lua_pushliteral(L, "valid");
         lua_pushboolean(L, gnss->frame_rmc.valid);
         lua_settable(L, -3);
@@ -346,7 +347,7 @@ static int l_libgnss_get_gsv(lua_State *L) {
                 if (gnss->frame_gsv[i].sats[j].snr) {
                     lua_pushinteger(L, count++);
                     lua_createtable(L, 0, 3);
-                    
+
                     lua_pushliteral(L, "snr");
                     lua_pushinteger(L, gnss->frame_gsv[i].sats[j].snr);
                     lua_settable(L, -3);
@@ -412,7 +413,7 @@ static int l_libgnss_get_gsa(lua_State *L) {
             lua_settable(L, -3);
         }
     }
-    
+
     lua_settable(L, -3);
 
     return 1;
@@ -519,7 +520,7 @@ static int l_libgnss_debug(lua_State *L) {
     {
         gnss->debug = 0;
     }
-    
+
     return 0;
 }
 

+ 1 - 0
components/mlx90640-library/luat_lib_mlx90640.c

@@ -4,6 +4,7 @@
 @summary 红外测温(MLX90640)
 @version 1.0
 @date    2022.1.20
+@tag LUAT_USE_MLX90640
 */
 
 #include "luat_base.h"

+ 1 - 0
components/mobile/luat_lib_mobile.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2022.8.9
 @demo    mobile
+@tag LUAT_USE_MOBILE
 @usage
 -- 简单演示
 

+ 1 - 0
components/multimedia/luat_lib_multimedia.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2022.03.11
 @demo multimedia
+@tag LUAT_USE_MEDIA
 */
 #include "luat_base.h"
 #include "luat_multimedia.h"

+ 1 - 0
components/network/adapter/luat_lib_socket.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.11.13
 @demo socket
+@tag LUAT_USE_NETWORK
 */
 #include "luat_base.h"
 #include "luat_malloc.h"

+ 1 - 0
components/network/httpsrv/src/luat_lib_httpsrv.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.010.15
 @demo wlan
+@tag LUAT_USE_HTTPSRV
 */
 
 #include "luat_base.h"

+ 1 - 0
components/network/libemqtt/luat_lib_mqtt.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.08.25
 @demo socket
+@tag LUAT_USE_MQTT
 */
 
 #include "luat_base.h"

+ 20 - 12
components/network/libhttp/luat_lib_http.c

@@ -1,9 +1,10 @@
 /*
-@module  http2
-@summary http2客户端
+@module  http
+@summary http 客户端
 @version 1.0
 @date    2022.09.05
 @demo    socket
+@tag LUAT_USE_HTTP
 */
 
 #include "luat_base.h"
@@ -572,8 +573,8 @@ static int http_set_url(luat_http_ctrl_t *http_ctrl) {
 }
 
 /*
-http2客户端
-@api http2.request(method,url,headers,body,opts,ca_file)
+http客户端
+@api http.request(method,url,headers,body,opts,ca_file)
 @string 请求方法, 支持 GET/POST
 @string url地址
 @tabal  请求头 可选 例如{["Content-Type"] = "application/x-www-form-urlencoded"}
@@ -585,15 +586,15 @@ http2客户端
 @return string body
 @usage
 -- GET请求
-local code, headers, body = http2.request("GET","http://site0.cn/api/httptest/simple/time").wait()
-log.info("http2.get", code, headers, body)
+local code, headers, body = http.request("GET","http://site0.cn/api/httptest/simple/time").wait()
+log.info("http.get", code, headers, body)
 -- POST请求
-local code, headers, body = http2.request("POST","http://httpbin.com/post", {}, "abc=123").wait()
-log.info("http2.post", code, headers, body)
+local code, headers, body = http.request("POST","http://httpbin.com/post", {}, "abc=123").wait()
+log.info("http.post", code, headers, body)
 
 -- GET请求,但下载到文件
-local code, headers, body = http2.request("GET","http://httpbin.com/", {}, "", {dst="/data.bin"}).wait()
-log.info("http2.get", code, headers, body)
+local code, headers, body = http.request("GET","http://httpbin.com/", {}, "", {dst="/data.bin"}).wait()
+log.info("http.get", code, headers, body)
 */
 static int l_http_request(lua_State *L) {
 	size_t client_cert_len, client_key_len, client_password_len,len;
@@ -659,7 +660,7 @@ static int l_http_request(lua_State *L) {
 	}
 	network_init_ctrl(http_ctrl->netc, NULL, luat_lib_http_callback, http_ctrl);
 
-	
+
 	network_set_base_mode(http_ctrl->netc, 1, 10000, 0, 0, 0, 0);
 	network_set_local_port(http_ctrl->netc, 0);
 
@@ -772,8 +773,15 @@ LUAMOD_API int luaopen_http( lua_State *L ) {
     luat_newlib2(L, reg_http);
 #else
     luat_newlib2(L, reg_http_emtry);
-	LLOGE("reg_http2 require network enable!!");
+	LLOGE("reg_http require network enable!!");
 #endif
     return 1;
 }
 
+LUAMOD_API int luaopen_http2( lua_State *L ) {
+    lua_getglobal(L, "http");
+    if (lua_isuserdata(L, -1))
+        return 1;
+    luaopen_http(L);
+    return 1;
+}

+ 1 - 0
components/nimble/src/luat_lib_nimble.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.10.21
 @demo    nimble
+@tag LUAT_USE_NIMBLE
 @usage
 -- 本库当前支持Air101/Air103/ESP32/ESP32C3
 -- 理论上支持ESP32C2/ESP32S2/ESP32S3,但尚未测试

+ 1 - 0
components/rsa/binding/luat_lib_rsa.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.11.03
 @demo    rsa
+@tag LUAT_USE_RSA
 @usage
 -- 请在电脑上生成私钥和公钥, 当前最高支持4096bit, 一般来说2048bit就够用了
 -- openssl genrsa -out privkey.pem 2048

+ 1 - 0
components/serialization/protobuf/luat_lib_protobuf.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.09.08
 @demo protobuf
+@tag LUAT_USE_PROTOBUF
 @usage
 
 -- 加载 pb 文件, 这个是从pbtxt 转换得到的

+ 1 - 0
components/sfd/luat_lib_sfd.c

@@ -3,6 +3,7 @@
 @summary SPI FLASH操作库
 @version 1.0
 @date    2021.05.18
+@tag LUAT_USE_SFD
 */
 #include "luat_base.h"
 #include "luat_spi.h"

+ 1 - 0
components/sfud/luat_lib_sfud.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2021.09.23
 @demo sfud
+@tag LUAT_USE_SFUD
 */
 
 #include "luat_base.h"

+ 1 - 0
components/statem/luat_lib_statem.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.09.26
 @demo statem
+@tag LUAT_USE_STATEM
 */
 
 #include "luat_base.h"

+ 1 - 0
components/u8g2/luat_lib_disp.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2020.03.30
 @demo u8g2
+@tag LUAT_USE_DISP
 */
 #include "luat_base.h"
 #include "luat_malloc.h"

+ 1 - 0
components/u8g2/luat_lib_u8g2.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.01.25
 @demo u8g2
+@tag LUAT_USE_U8G2
 */
 #include "luat_base.h"
 #include "luat_malloc.h"

+ 1 - 0
components/usbapp/luat_lib_usbapp.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2022.01.17
 @demo usb_hid
+@tag LUAT_USE_USB
 */
 #include "luat_base.h"
 #include "luat_msgbus.h"

+ 1 - 0
components/wlan/luat_lib_wlan.c

@@ -6,6 +6,7 @@
 @version 1.0
 @date    2022.09.30
 @demo wlan
+@tag LUAT_USE_WLAN
 */
 
 #include "luat_base.h"

+ 1 - 0
components/zlib/luat_lib_zlib.c

@@ -3,6 +3,7 @@
 @summary zlib压缩/解压缩
 @version 1.0
 @date    2022.01.06
+@tag LUAT_USE_ZLIB
 */
 
 #include "luat_base.h"

+ 7 - 11
demo/socket/Air105/http_demo.lua

@@ -1,35 +1,31 @@
 
---[[
-这个demo未完成, 暂不可用
-TODO http2库完成后删除这段注释
-]]
 local function testTask()
 
     -- GET request, task内的同步操作
-    local code, headers, body = http2.request("GET","http://site0.cn/api/httptest/simple/time").wait()
-    log.info("http2.get", code, headers, body)
+    local code, headers, body = http.request("GET","http://site0.cn/api/httptest/simple/time").wait()
+    log.info("http.get", code, headers, body)
 
     -- POST request
     local req_headers = {}
     req_headers["Content-Type"] = "application/json"
     local body = json.encode({name="LuatOS"})
-    local code, headers, body = http2.request("POST","http://site0.cn/api/httptest/simple/date", 
+    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
             req_headers,
             body -- POST请求所需要的body, string, zbuff, file均可
     ).wait()
-    log.info("http2.post", code, headers, body)
+    log.info("http.post", code, headers, body)
 
     -- POST and download, task内的同步操作
     local opts = {}                 -- 额外的配置项
     opts["dst"] = "/data.bin"       -- 下载路径,可选
     opts["timeout"] = 30            -- 超时时长,单位秒,可选
     opts["adapter"] = socket.ETH0  -- 使用哪个网卡,可选
-    local code, headers, body = http2.request("POST","http://site0.cn/api/httptest/simple/date", 
+    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
             {}, -- 请求所添加的 headers, 可以是nil
             "", 
             opts
     ).wait()
-    log.info("http2.post", code, headers, body) -- 只返回code和headers
+    log.info("http.post", code, headers, body) -- 只返回code和headers
 
     local f = io.open("/data.bin", "rb")
     if f then
@@ -38,7 +34,7 @@ local function testTask()
     end
     
     -- GET request, 开个task让它自行执行去吧, 不管执行结果了
-    sys.taskInit(http2.request("GET","http://site0.cn/api/httptest/simple/time").wait)
+    sys.taskInit(http.request("GET","http://site0.cn/api/httptest/simple/time").wait)
 end
 
 function httpDemo()

+ 14 - 14
demo/socket/EC618/http_demo.lua

@@ -2,7 +2,7 @@ local libnet = require "libnet"
 
 
 -- local function downloadFile(code, headers, body)
---     log.info("http2.get", code, json.encode(headers), body)
+--     log.info("http.get", code, json.encode(headers), body)
 --     local r = io.writeFile("/data.txt", body)
 --     if r then
 --         log.info("文件写入成功")
@@ -18,12 +18,12 @@ sys.taskInit(function ()
     log.info("------下载文件------")
     local path = "/data.txt"
     -- GET请求,但下载到文件
-    http2.request(
+    http.request(
         "GET",
         "http://cdn.openluat-luatcommunity.openluat.com/attachment/20220825134126812_text.txt").cb
         (
             function (code, headers, body)
-                log.info("http2.get", code, json.encode(headers), body)
+                log.info("http.get", code, json.encode(headers), body)
                 local r = io.writeFile("/data.txt", body)
                 if r then
                     log.info("文件写入成功")
@@ -48,12 +48,12 @@ sys.taskInit(function ()
     -- opts["adapter"] = ""  -- 使用哪个网卡,可选
     -- local req_headers = {}
     -- req_headers["Content-Type"] = "application/json"
-    -- local code, headers, body = http2.request("POST","http://site0.cn/api/httptest/simple/date", 
+    -- local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
     --         json.encode(req_headers), -- 请求所添加的 headers, 可以是nil
     --         "",
     --         opts
     -- ).wait()
-    -- log.info("http2.post", code, headers, body) -- 只返回code和headers
+    -- log.info("http.post", code, headers, body) -- 只返回code和headers
 end)
 
 -- [[
@@ -66,7 +66,7 @@ sys.taskInit(
 
         -- GET请求
         log.info("------GET请求------")
-        local code, headers, body = http2.request("GET","https://www.baidu.com/").wait()
+        local code, headers, body = http.request("GET","https://www.baidu.com/").wait()
         log.info("http.get", code, json.encode(headers), body)
         sys.wait(2000)
 
@@ -75,7 +75,7 @@ sys.taskInit(
         local req_headers = {}
         req_headers["Content-Type"] = "application/json"
         local body = json.encode({name="LuatOS"})
-        http2.request("POST","http://site0.cn/api/httptest/simple/date", 
+        http.request("POST","http://site0.cn/api/httptest/simple/date", 
             req_headers,
             body -- POST请求所需要的body, string, zbuff, file均可
         ).cb(function(code, headers, body)
@@ -94,24 +94,24 @@ sys.taskInit(
 --         -- while 1 do
 --             log.info("mem.lua", rtos.meminfo())
 --             log.info("mem.sys", rtos.meminfo("sys"))
---             local code, headers, body = http2.request("GET","https://www.baidu.com/").wait()
---             log.info("http2.get", code, json.encode(headers), body)
+--             local code, headers, body = http.request("GET","https://www.baidu.com/").wait()
+--             log.info("http.get", code, json.encode(headers), body)
 
---             -- -- local code, headers, body = http2.request("GET","http://site0.cn/api/httptest/simple/time").wait()
---             -- -- log.info("http2.get", code, json.encode(headers), body)
+--             -- -- local code, headers, body = http.request("GET","http://site0.cn/api/httptest/simple/time").wait()
+--             -- -- log.info("http.get", code, json.encode(headers), body)
 --             -- sys.wait(2000)
 
 --             -- -- POST request
 --             -- local req_headers = {}
 --             -- req_headers["Content-Type"] = "application/json"
 --             -- local body = json.encode({name="LuatOS"})
---             -- local code, headers, body = http2.request("POST","http://site0.cn/api/httptest/simple/date", 
+--             -- local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
 --             --         req_headers,
 --             --         body -- POST请求所需要的body, string, zbuff, file均可
 --             -- ).cb(function (code, headers, body)
---             --     log.info("http2.post", code, headers, body)
+--             --     log.info("http.post", code, headers, body)
 --             -- end)
---             -- log.info("http2.post1", code, headers, body)
+--             -- log.info("http.post1", code, headers, body)
 --         -- end
 --     end
 -- )

+ 1 - 1
demo/wlan/esp32c3/hello_world/main.lua

@@ -30,7 +30,7 @@ sys.taskInit(function()
         sys.wait(100)
         -- local url = "http://ip.nutz.cn/json"
         local url = "http://nutzam.com/1.txt"
-        local code, headers, body = http2.request("GET", url).wait()
+        local code, headers, body = http.request("GET", url).wait()
         log.info("http", code, json.encode(headers), #body)
     else
         print("wlan NOT ready!!!!")

+ 4 - 3
lua/src/liolib.c

@@ -3,6 +3,7 @@
 @summary io操作(扩展)
 @version 1.0
 @date    2020.07.03
+@tag LUAT_CONF_BSP
 */
 
 #define liolib_c
@@ -755,7 +756,7 @@ static int f_flush (lua_State *L) {
 @string 文件路径
 @return bool 存在返回true,否则返回false
 @usage
-log.info("io", "file exists", io.exists("/boottime")) 
+log.info("io", "file exists", io.exists("/boottime"))
  */
 static int io_exists (lua_State *L) {
   const char *filename = luaL_checkstring(L, 1);
@@ -781,7 +782,7 @@ static int io_fileSize (lua_State *L) {
   const char *filename = luaL_checkstring(L, 1);
   FILE* f = fopen(filename, "rb");
   if(f == NULL) {
-    lua_pushinteger(L, 0); 
+    lua_pushinteger(L, 0);
   }
   else {
     fseek(f, 0, SEEK_END);
@@ -1115,7 +1116,7 @@ static int io_lsdir (lua_State *L) {
   else if (ret > 0) {
     lua_pushboolean(L, 1);
     lua_createtable(L, ret, 0);
-    
+
     for (size_t i = 0; i < ret; i++)
     {
       lua_createtable(L, 0, 2);

+ 1 - 0
lua/src/lstrlib_exts.c

@@ -1,6 +1,7 @@
 /*
 @module  string
 @summary 字符串操作函数
+@tag LUAT_CONF_BSP
 */
 #include "luat_base.h"
 #include "luat_malloc.h"

+ 1 - 0
luat/include/luat_libs.h

@@ -51,6 +51,7 @@ LUAMOD_API int luaopen_sfud( lua_State *L );
 LUAMOD_API int luaopen_mqtt( lua_State *L );
 /** http库*/
 LUAMOD_API int luaopen_http( lua_State *L );
+LUAMOD_API int luaopen_http2( lua_State *L );
 /** pack库*/
 LUAMOD_API int luaopen_pack( lua_State *L );
 /** mqttcore库*/

+ 1 - 0
luat/modules/luat_lib_adc.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2020.07.03
 @demo adc
+@tag LUAT_USE_ADC
 */
 #include "luat_base.h"
 #include "luat_adc.h"

+ 2 - 1
luat/modules/luat_lib_crypto.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2020.07.03
 @demo crypto
+@tag LUAT_USE_CRYPTO
 */
 #include "luat_base.h"
 #include "luat_crypto.h"
@@ -288,7 +289,7 @@ int l_crypto_cipher_decrypt(lua_State *L) {
 local crc = crypto.crc16("")
  */
 static int l_crypto_crc16(lua_State *L)
-{   
+{
     size_t inputlen;
     const unsigned char *inputData;
     const char  *inputmethod = (const char*)luaL_checkstring(L, 1);

+ 1 - 0
luat/modules/luat_lib_dac.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.12.03
 @demo multimedia
+@tag LUAT_USE_DAC
 */
 
 #include "luat_base.h"

+ 1 - 0
luat/modules/luat_lib_fota.c

@@ -5,6 +5,7 @@
 @version core V0007
 @date    2022.05.26
 @demo ota
+@tag LUAT_USE_FOTA
 */
 #include "luat_base.h"
 #include "luat_fota.h"

+ 1 - 0
luat/modules/luat_lib_fs.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.03.30
 @demo fs
+@tag LUAT_USE_FS
 */
 #include "luat_base.h"
 #include "luat_fs.h"

+ 1 - 0
luat/modules/luat_lib_gpio.c

@@ -7,6 +7,7 @@
 @date    2020.03.30
 @demo gpio
 @video https://www.bilibili.com/video/BV1hr4y1p7dt
+@tag LUAT_USE_GPIO
 */
 #include "luat_base.h"
 #include "luat_gpio.h"

+ 1 - 0
luat/modules/luat_lib_i2c.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2020.03.30
 @demo i2c
+@tag LUAT_USE_I2C
 */
 #include "luat_base.h"
 #include "luat_log.h"

+ 1 - 0
luat/modules/luat_lib_i2s.c

@@ -3,6 +3,7 @@
 @summary 数字音频
 @version core V0007
 @date    2022.05.26
+@tag LUAT_USE_I2S
 */
 #include "luat_base.h"
 #include "luat_malloc.h"

+ 1 - 0
luat/modules/luat_lib_ir.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2021.10.26
 @demo ir
+@tag LUAT_USE_IR
 */
 #include "luat_base.h"
 #include "luat_gpio.h"

+ 4 - 3
luat/modules/luat_lib_keyboard.c

@@ -1,10 +1,11 @@
 
 /*
 @module  keyboard
-@summary 键盘矩阵(当前仅air105支持)
+@summary 键盘矩阵
 @version 1.0
 @date    2021.11.24
 @demo keyboard
+@tag LUAT_USE_KEYBOARD
 */
 
 #include "luat_base.h"
@@ -84,7 +85,7 @@ static int l_keyboard_init(lua_State *L) {
     conf.debounce = luaL_optinteger(L, 4, 1);
     conf.cb = l_keyboard_irq_cb;
     int ret = luat_keyboard_init(&conf);
-    
+
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     return 1;
 }
@@ -97,7 +98,7 @@ static int l_keyboard_deinit(lua_State *L) {
     conf.debounce = luaL_optinteger(L, 4, 1);
 
     int ret = luat_keyboard_deinit(&conf);
-    
+
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     return 1;
 }

+ 1 - 0
luat/modules/luat_lib_lcdseg.c

@@ -3,6 +3,7 @@
 @summary 段式lcd
 @version 1.0
 @date    2021.10.22
+@tag LUAT_USE_LCDSEG
 */
 
 #include "luat_base.h"

+ 3 - 2
luat/modules/luat_lib_libcoap.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2020.06.30
 @demo libcoap
+@tag LUAT_USE_COAP
 */
 #include "luat_base.h"
 #include "luat_timer.h"
@@ -220,7 +221,7 @@ static int l_libcoap_parse(lua_State* L) {
             else if (opt_header->opt_len == 13) {
                 opt_header->opt_len += (unsigned int)(*(ptr+1));
             }
-            
+
             ptr += opt_header->opt_len + 1;
             idx += opt_header->opt_len + 1;
             _coap->optSize += opt_header->opt_len + 1;
@@ -228,7 +229,7 @@ static int l_libcoap_parse(lua_State* L) {
         LLOGD("opt size=%d", _coap->optSize);
         memcpy(_coap->opt, ptr - _coap->optSize, _coap->optSize);
     }
-    
+
 
     // 分析一下data
     if (idx < len) {

+ 1 - 0
luat/modules/luat_lib_log.c

@@ -4,6 +4,7 @@
 @summary 日志库
 @version 1.0
 @date    2020.03.30
+@tag LUAT_CONF_BSP
 */
 #include "luat_base.h"
 #include "luat_sys.h"

+ 4 - 3
luat/modules/luat_lib_lpmem.c

@@ -4,6 +4,7 @@
 @summary 操作低功耗不掉电内存块
 @version V0002
 @date    2020.07.10
+@tag LUAT_USE_LPMEM
 */
 
 #include "luat_base.h"
@@ -18,7 +19,7 @@
 @int 内存偏移量
 @int 读取大小,单位字节
 @return string 读取成功返回字符串,否则返回nil
-@usage  
+@usage
 -- 读取1kb的内存
 local data = lpmem.read(0, 1024)
 */
@@ -43,7 +44,7 @@ static int l_lpmem_read(lua_State *L) {
 @int 内存偏移量
 @string 待写入的数据
 @return boolean 成功返回true,否则返回false
-@usage  
+@usage
 -- 往偏移量为512字节的位置, 写入数据
 lpmem.write(512, data)
 */
@@ -66,7 +67,7 @@ static int l_lpmem_write(lua_State *L) {
 获取内存块的总大小
 @api    lpmem.size()
 @return int 内存块的大小
-@usage  
+@usage
 lpmem.size()
 */
 static int l_lpmem_size(lua_State *L) {

+ 1 - 0
luat/modules/luat_lib_mcu.c

@@ -4,6 +4,7 @@
 @summary 封装mcu一些特殊操作
 @version core V0007
 @date    2021.08.18
+@tag LUAT_USE_MCU
 */
 #include "luat_base.h"
 #include "luat_mcu.h"

+ 1 - 0
luat/modules/luat_lib_otp.c

@@ -4,6 +4,7 @@
 @summary OTP操作库
 @version 1.0
 @date    2021.12.08
+@tag LUAT_USE_OTP
 */
 #include "luat_base.h"
 #include "luat_otp.h"

+ 1 - 0
luat/modules/luat_lib_pack.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2021.12.20
 @video https://www.bilibili.com/video/BV1Sr4y1n7bP
+@tag LUAT_USE_PACK
 */
 
 #define	OP_ZSTRING	      'z'		/* zero-terminated string */

+ 1 - 0
luat/modules/luat_lib_pm.c

@@ -5,6 +5,7 @@
 @version 1.0
 @date    2020.07.02
 @demo pm
+@tag LUAT_USE_PM
 */
 #include "lua.h"
 #include "lauxlib.h"

+ 1 - 0
luat/modules/luat_lib_pwm.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2020.07.03
 @demo pwm
+@tag LUAT_USE_PWM
 */
 #include "luat_base.h"
 #include "luat_pwm.h"

+ 1 - 0
luat/modules/luat_lib_rtc.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2021.08.31
 @demo rtc
+@tag LUAT_USE_RTC
 */
 #include "luat_base.h"
 #include "luat_rtc.h"

+ 1 - 0
luat/modules/luat_lib_rtos.c

@@ -3,6 +3,7 @@
 @summary RTOS底层操作库
 @version 1.0
 @date    2020.03.30
+@tag LUAT_CONF_BSP
 */
 #include "luat_base.h"
 #include "luat_sys.h"

+ 1 - 0
luat/modules/luat_lib_sdio.c

@@ -4,6 +4,7 @@
 @summary sdio
 @version 1.0
 @date    2021.09.02
+@tag LUAT_USE_SDIO
 */
 #include "luat_base.h"
 #include "luat_sdio.h"

+ 1 - 0
luat/modules/luat_lib_sensor.c

@@ -4,6 +4,7 @@
 @summary 传感器操作库
 @version 1.0
 @date    2020.03.30
+@tag LUAT_USE_SENSOR
 */
 #include "luat_base.h"
 #include "luat_timer.h"

+ 1 - 0
luat/modules/luat_lib_spi.c

@@ -5,6 +5,7 @@
 @date    2020.04.23
 @demo spi
 @video https://www.bilibili.com/video/BV1VY411M7YH
+@tag LUAT_USE_SPI
 */
 #include "luat_base.h"
 #include "luat_log.h"

+ 1 - 0
luat/modules/luat_lib_sys_doc.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2019.11.23
 @video https://www.bilibili.com/video/BV1194y1o7q2
+@tag LUAT_CONF_BSP
 */
 
 /*

+ 1 - 0
luat/modules/luat_lib_timer.c

@@ -3,6 +3,7 @@
 @summary 操作底层定时器
 @version 1.0
 @date    2020.03.30
+@tag LUAT_USE_TIMER
 */
 #include "luat_base.h"
 #include "luat_log.h"

+ 1 - 0
luat/modules/luat_lib_touchkey.c

@@ -3,6 +3,7 @@
 @summary 触摸按键
 @version 1.0
 @date    2022.01.15
+@tag LUAT_USE_TOUCHKEY
 */
 #include "luat_base.h"
 #include "luat_touchkey.h"

+ 1 - 0
luat/modules/luat_lib_uart.c

@@ -5,6 +5,7 @@
 @date    2020.03.30
 @demo uart
 @video https://www.bilibili.com/video/BV1er4y1p75y
+@tag LUAT_USE_UART
 */
 #include "luat_base.h"
 #include "luat_uart.h"

+ 1 - 0
luat/modules/luat_lib_wdt.c

@@ -4,6 +4,7 @@
 @version 1.0
 @date    2021.08.06
 @demo wdt
+@tag LUAT_USE_WDT
 */
 #include "luat_base.h"
 #include "luat_wdt.h"

+ 1 - 0
luat/modules/luat_lib_zbuff.c

@@ -4,6 +4,7 @@
 @version 0.1
 @date    2021.03.31
 @video https://www.bilibili.com/video/BV1gr4y1V7HN
+@tag LUAT_USE_ZBUFF
 */
 #include "luat_base.h"
 #include "luat_zbuff.h"

+ 2 - 2
script/turnkey/EinkBook/Scripts/main.lua

@@ -150,7 +150,7 @@ function showBook(bookName, bookUrl, page)
     sys.taskInit(function()
         waitHttpTask = true
         for i = 1, 3 do
-            local code, headers, data = http2.request("GET",bookUrl .. "/" .. page).wait()
+            local code, headers, data = http.request("GET",bookUrl .. "/" .. page).wait()
             log.info("SHOWBOOK", code)
             if code ~= 200 then
                 log.error("SHOWBOOK", "获取图书内容失败 ", data)
@@ -317,7 +317,7 @@ sys.taskInit(function()
         end
     end
     for i = 1, 5 do
-        local code, headers, data = http2.request("GET", serverAdress .. "getBooks").wait()
+        local code, headers, data = http.request("GET", serverAdress .. "getBooks").wait()
         log.info("SHOWBOOK", code)
         if code ~= 200 then
             log.error(tag, "获取图书列表失败 ", data)

+ 3 - 3
script/turnkey/eink-calendar/main.lua

@@ -9,11 +9,11 @@ require("sysplus")
 
 --需要自行填写的东西
 --wifi信息
-local wifiName,wifiPassword = "wifi","password"
+local wifiName,wifiPassword = "Xiaomi_AX6000","Air123456"
 --地区id,请前往https://api.luatos.org/luatos-calendar/v1/check-city/ 查询自己所在位置的id
 local location = "101020100"
 --天气接口信息,需要自己申请,具体参数请参考https://api.luatos.org/ 页面上的描述
-local appid,appsecret = "appid(要改)","appsecret(要改)"
+local appid,appsecret = "27548549","3wdKWuRZ"
 
 local function connectWifi()
     log.info("wlan", "wlan_init:", wlan.init())
@@ -30,7 +30,7 @@ local function connectWifi()
 end
 
 local function requestHttp()
-    local code, headers, body = http2.request("GET","http://apicn.luatos.org:23328/luatos-calendar/v1?mac=111&battery=10&location="..location.."&appid="..appid.."&appsecret="..appsecret).wait()
+    local code, headers, body = http.request("GET","http://apicn.luatos.org:23328/luatos-calendar/v1?mac=111&battery=10&location="..location.."&appid="..appid.."&appsecret="..appsecret).wait()
     if code == 200 then
         return body
     else

+ 1 - 1
tools/api_get.py

@@ -118,7 +118,7 @@ def get_modules(file_list, start="/*", end="*/"):
 
         for mstep in range(len(modules)-1,-1,-1):
             if modules[mstep]["module"] == module["module"]:
-                module["api"] = modules[mstep]["api"]
+                module = modules[mstep]
                 del modules[mstep]
                 module["url"] = ""
 

+ 1 - 1
tools/make_doc_file.py

@@ -18,7 +18,7 @@ for bsp in bsp_header_list:
 def get_tags(tag):
     r = []
     for bsp in bsp_header_list:
-        if bsp["url"].find(" "+tag) >= 0:
+        if bsp["url"].find(" "+tag+" ") >= 0 or bsp["url"].find(" "+tag+"\r") >= 0 or bsp["url"].find(" "+tag+"\n") >= 0:
             r.append("{bdg-primary}`" + bsp["name"] + "`")
     return " ".join(r)