Преглед изворни кода

add:打印一条自定义APN列表里的信息

alienwalker пре 1 година
родитељ
комит
b9fbd3c7dd

+ 17 - 0
components/mobile/luat_lib_mobile.c

@@ -1118,7 +1118,23 @@ static int l_mobile_add_apn_table(lua_State* L) {
 	luat_mobile_add_auto_apn_item(mcc, mnc, ip_type, protocol, name, name_len, user, user_len, password, password_len, 1);
     return 0;
 }
+/**
+打印自定义APN列表里的一条信息,在没有拿到卡的情况下,测试一下对应的APN信息是否和运营商提供的匹配
+@api mobile.apnTablePrint(mcc, mnc)
+@int MCC码,16进制BCD码
+@int MNC码,16进制BCD码
+@return nil 无返回值
+@usage
+mobile.apnTableInit()
+mobile.apnTablePrint(0x202, 0x01)
+ */
+static int l_mobile_print_apn_table(lua_State* L) {
 
+	uint16_t mcc = luaL_optinteger(L, 1, 0x460);
+	uint16_t mnc = luaL_optinteger(L, 2, 0);
+	luat_mobile_print_apn_by_mcc_mnc(mcc, mnc);
+    return 0;
+}
 #include "rotable2.h"
 static const rotable_Reg_t reg_mobile[] = {
     {"status",          ROREG_FUNC(l_mobile_status)},
@@ -1159,6 +1175,7 @@ static const rotable_Reg_t reg_mobile[] = {
 	{"vsimOnOff",          ROREG_FUNC(l_mobile_vsim_onoff)},
 	{"apnTableInit",          ROREG_FUNC(l_mobile_init_apn_table)},
 	{"apnTableAdd",          ROREG_FUNC(l_mobile_add_apn_table)},
+	{"apnTablePrint",          ROREG_FUNC(l_mobile_print_apn_table)},
 	//@const UNREGISTER number 未注册
     {"UNREGISTER",                  ROREG_INT(LUAT_MOBILE_STATUS_UNREGISTER)},
     //@const REGISTERED number 已注册

+ 7 - 0
components/mobile/luat_mobile.h

@@ -990,5 +990,12 @@ void luat_mobile_add_auto_apn_item(uint16_t mcc, uint16_t mnc, uint8_t ip_type,
  * @return =0找到匹配的信息,其他未找到
  */
 int luat_mobile_find_apn_by_mcc_mnc(uint16_t mcc, uint16_t mnc, apn_info_t *apn);
+/**
+ * 通过MCC,MNC打印APN信息
+ * @param mcc
+ * @param mnc
+ * @return
+ */
+void luat_mobile_print_apn_by_mcc_mnc(uint16_t mcc, uint16_t mnc);
 /** @}*/
 #endif

+ 29 - 0
components/mobile/luat_mobile_common.c

@@ -126,6 +126,35 @@ int luat_mobile_find_apn_by_mcc_mnc(uint16_t mcc, uint16_t mnc, apn_info_t *info
 	return result;
 }
 
+LUAT_WEAK int get_apn_info_by_static(uint16_t mcc, uint16_t mnc, apn_info_t *info)
+{
+	return -1;
+}
+
+void luat_mobile_print_apn_by_mcc_mnc(uint16_t mcc, uint16_t mnc)
+{
+	apn_info_t info;
+	if(luat_mobile_find_apn_by_mcc_mnc(mcc, mnc, &info))
+	{
+		if (get_apn_info_by_static(mcc, mnc, &info))
+		{
+			LLOGD("mcc 0x%x, mnc 0x%x not find");
+			return;
+		}
+		if (!info.data)
+		{
+			LLOGD("mcc 0x%x, mnc 0x%x no need apn");
+			return;
+		}
+	}
+
+	LLOGD("mcc 0x%x, mnc 0x%x, ip_type %d, auth_type %d, apn %dbyte %.*s, user %dbyte %.*s, password %dbyte %.*s",
+			mcc, mnc, info.ip_type, info.protocol, info.name_len, info.name_len, info.data,
+			info.user_len, info.user_len, info.user_len?(info.data + info.name_len):NULL,
+			info.password_len, info.password_len, info.password_len?(info.data + info.name_len + info.user_len):NULL);
+
+}
+
 int luat_mobile_get_isp_from_plmn(uint16_t mcc, uint8_t mnc)
 {
 	uint8_t cmcc[] = {0, 2, 4, 7, 8, 13, 23, 24};