Просмотр исходного кода

add:mobile里增加控制默认APN是否需要激活IPV6功能。必须在sim卡准备好前就设置好

alienwalker 3 лет назад
Родитель
Сommit
7ded1adee9

+ 17 - 0
components/mobile/luat_lib_mobile.c

@@ -276,6 +276,22 @@ static int l_mobile_apn(lua_State* L) {
     return 1;
 }
 
+/**
+是否默认开启IPV6功能,必须在LTE网络连接前就设置好
+@api mobile.ipv6(onff)
+@boolean 开关 true开启 false 关闭
+@return boolean true 当前是开启的,false 当前是关闭的
+ */
+static int l_mobile_ipv6(lua_State* L) {
+    // char buff[24] = {0};
+	uint8_t onoff;
+    if (LUA_TBOOLEAN == lua_type(L, 1)) {
+    	luat_mobile_set_default_pdn_ipv6(lua_toboolean(L, 1));
+    }
+    lua_pushboolean(L, luat_mobile_get_default_pdn_ipv6());
+    return 1;
+}
+
 /**
 获取csq
 @return int 当前CSQ值, 若失败返回0
@@ -533,6 +549,7 @@ static const rotable_Reg_t reg_mobile[] = {
 	{"number",       ROREG_FUNC(l_mobile_number)},
     {"muid",        ROREG_FUNC(l_mobile_muid)},
     {"apn",         ROREG_FUNC(l_mobile_apn)},
+	{"ipv6",         ROREG_FUNC(l_mobile_ipv6)},
     {"csq",         ROREG_FUNC(l_mobile_csq)},
     {"rssi",        ROREG_FUNC(l_mobile_rssi)},
     {"rsrq",        ROREG_FUNC(l_mobile_rsrq)},

+ 14 - 1
components/mobile/luat_mobile.h

@@ -110,6 +110,20 @@ int luat_mobile_get_sim_id(int *id);
  */
 int luat_mobile_set_sim_id(int id);
 
+/**
+ * @brief 设置默认PDN激活时是否要IPV6网络,现在默认情况下不开
+ * @param onoff 1开 0关
+ * @return uint8_t 1开 0关
+ */
+void luat_mobile_set_default_pdn_ipv6(uint8_t onoff);
+
+/**
+ * @brief 返回默认PDN激活时是否要IPV6网络
+ * @return uint8_t 1开 0关
+ */
+uint8_t luat_mobile_get_default_pdn_ipv6(void);
+
+
 /**
  * @brief 获取配置的apn name,并不一定支持
  * 
@@ -153,7 +167,6 @@ int luat_mobile_set_apn_base_info(int sim_id, int cid, uint8_t type, uint8_t* ap
  */
 int luat_mobile_set_apn_auth_info(int sim_id, int cid, uint8_t protocol, uint8_t *user_name, uint8_t user_name_len, uint8_t *password, uint8_t password_len);
 
-
 /**
  * @brief 手动激活/去激活APN
  *

+ 1 - 1
demo/http/main.lua

@@ -43,6 +43,7 @@ sys.taskInit(function()
         --mobile.simid(2)
         LED = gpio.setup(27, 0, gpio.PULLUP)
         device_id = mobile.imei()
+        log.info("ipv6", mobile.ipv6(true))
         sys.waitUntil("IP_READY", 30000)
     end
 
@@ -54,7 +55,6 @@ sys.taskInit(function()
     -------------------------------------
     -------- HTTP 演示代码 --------------
     -------------------------------------
-
     while 1 do
         -- 最普通的Http GET请求
         -- local code, headers, body = http.request("GET", "https://yanqiyu.info/").wait()

+ 2 - 1
demo/socket/EC618/async_socket_demo.lua

@@ -1,5 +1,6 @@
 -- netlab.luatos.com上打开TCP,然后修改IP和端口号,自动回复netlab下发的数据,自收自发测试
-local server_ip = "2603:c023:1:5fcc:c028:8ed:49a7:6e08"
+
+local server_ip = "152.70.80.204"
 local server_port = 55619
 local UDP_port = 37834
 local ssl_port = 35528