5-AT命令交互之-APN

APN指一种网络接入技术,是通过手机上网时必须配置的一个参数,它决定了手机通过哪种接入方式来访问网络。

对于APN在运营商上面的具体使用过程可能要查专门的信息。

百科对APN的使用过程有以下实例:

GPRS专网系统终端上网登录服务器平台的流程为:
1)用户发出GPRS登录请求,请求中包括由运营商为GPRS专网系统专门分配的专网APN;
2)根据请求中的APN,SGSN向DNS服务器发出查询请求,找到与企业服务器平台连接的GGSN,并将用户请求通过GTP隧道封装送给GGSN;
3)GGSN将用户认证信息(包括手机号码、用户账号、密码等)通过专线送至Radius进行认证;
4)Radius认证服务器看到手机号等认证信息,确认是合法用户发来的请求,向DHCP服务器请求分配用户地址;
5)Radius认证通过后,由Radius向GGSN发送携带用户地址的确认信息;
6)用户得到了IP地址,就可以携带数据包,对GPRS专网系统信息查询和业务处理平台进行访问。

在我们使用模块上网时,一般在查询到IMSI之后就要设置APN了,对于APN的设置有很多AT接口可以设置,下面以移远的和SimCom的模块进行举例

移远模块


1.AT+CGDCONT 定义 PDP 上下文

AT+CGDCONT=1,"IP","apn"
  1~3  数值型参数;用于指定 PDP 上下文标识。该参数对 TE-MT 接口而言是本地参数,
并且可用于其他 PDP 上下文相关命令
 “IP”  (分组数据协议类型)字符型参数;用于指定分组数据协议的类型。仅支持”IP”,
互联网协议 IP(Internet Protocol)(IETF STD5)
  接入点名称;表示一个字符串参数,用于选择 GGSN 或外部分组数据网络的逻辑名称。若
该参数取值为空或省略,则需要请求签约值
 字符型参数;用于表示对于特定 PDP 上下文,MT 分配的地址空间。若该参数取值为空或
省略,则 TE 在 PDP 启动过程中提供其他取值;若不能提供其他取值,则需要请求动态地
址。即便在 PDP 启动过程中已分配地址,该命令的读出形式仍继续返回为空。使用
AT+CGPADDR 命令,可读出该分配地址
 关闭(若取值省略,则该参数为缺省值);数值型参数;用于控制 PDP 数据压缩
  关闭(若取值省略,则该参数为缺省值);数值型参数;用于控制 PDP 头

2.AT+QICSGP 设置 CSD 或 或 GPRS

AT+QICSGP=1,"apn","username","passward"
 数字参数;表明无线连接模式
0  CSD 连接
1  GPRS 连接

GPRS 连接配置的参数说明:
 字符串参数;表明接入点名称
  字符串参数;表明用户名
 字符串参数;表明用户密码

 字符串参数;表明 CSD 号码
  字符串参数;表明 CSD 连接用户名
 字符串参数;表明 CSD 连接用户密码
 数字参数;表明 CSD 连接速率
0  2400
1  4800
2  9600(缺省值)
3  14400

3.AT+QIREGAPP 启动任务并设置接入点 APN 、用户名和密码

AT+QIREGAPP="apn","username","passward"
 字符串参数;表明 GPRS/CSD 接入点名称
  字符串参数;表明 GPRS/CSD 接入点用户名
 字符串参数;表明 GPRS/CSD 接入点用户密码
 表明 CSD 数据传输速率```

SimCom模块


AT+CGDCONT 定义 PDP 上下文

AT+CGDCONT=1,"IP","apn"
  1~3  数值型参数;用于指定 PDP 上下文标识。该参数对 TE-MT 接口而言是本地参数,
并且可用于其他 PDP 上下文相关命令
 “IP”  (分组数据协议类型)字符型参数;用于指定分组数据协议的类型。仅支持”IP”,
互联网协议 IP(Internet Protocol)(IETF STD5)
  接入点名称;表示一个字符串参数,用于选择 GGSN 或外部分组数据网络的逻辑名称。若
该参数取值为空或省略,则需要请求签约值
 字符型参数;用于表示对于特定 PDP 上下文,MT 分配的地址空间。若该参数取值为空或
省略,则 TE 在 PDP 启动过程中提供其他取值;若不能提供其他取值,则需要请求动态地
址。即便在 PDP 启动过程中已分配地址,该命令的读出形式仍继续返回为空。使用
AT+CGPADDR 命令,可读出该分配地址
 关闭(若取值省略,则该参数为缺省值);数值型参数;用于控制 PDP 数据压缩
  关闭(若取值省略,则该参数为缺省值);数值型参数;用于控制 PDP 头

AT+CIPCSGP 设置 CSD 或 或 GPRS

AT+CIPCSGP=1,"apn","username","passward"
 数字参数;表明无线连接模式
0  CSD 连接
1  GPRS 连接

GPRS 连接配置的参数说明:
 字符串参数;表明接入点名称
  字符串参数;表明用户名
 字符串参数;表明用户密码

 字符串参数;表明 CSD 号码
  字符串参数;表明 CSD 连接用户名
 字符串参数;表明 CSD 连接用户密码
 数字参数;表明 CSD 连接速率
0  2400
1  4800
2  9600(缺省值)
3  14400

AT+CSTT 启动任务并设置接入点 APN 、用户名和密码

AT+QIREGAPP="apn","username","passward"
 字符串参数;表明 GPRS 接入点名称
  字符串参数;表明 GPRS 接入点用户名
 字符串参数;表明 GPRS 接入点用户密码

Android系统


对于Android系统APN的设置必须要有接入点号码MCC+MNC,接入点名称APN,调用接口设置完是存在apn的数据库里面。

当前使用的apn,adb pull /data/data/com.android.providers.telephony/shared_prefs/preferred-apn.xml

默认的apn,adb pull /system/etc/apns-conf.xml

全部apn数据库,adb pull /data/data/com.android.providers.telephony/databases/telephony.db

用SQLiteSpy.exe查看db文件
file -> open database -> carriers

在/system/etc/apns-conf.xml 中添加 对应302720 这条apn 记录,然后push 进去, 删除 telephony.db 这个数据库,重启测一下

https://blog.csdn.net/Anmmei/article/details/77461530

45412:cmhk
46000,46002:cmnet
46001:3gnet
46003:ctlte
46011:ctnet
46004:cmiot
45407:3gnet
23410:giffgaff.com
52505:sct
45403:mb

APN		用户名	密码	IMSI前位
Internet	空	空	52003
cmhk		空	空	45412
m-wap		mms	mms	45201
celcom3g	空	空	50219
indosatgprs	空	空	51001
Telkomsel	空	空	51010
MCC
202, "Greece",   "GR", "希腊" 
204, "Netherlands, The", "NL", "荷兰" 
206, "Belgium",  "BE", "比利时" 
208, "France",  "FR", "法国" 
213, "Andorra",  "AD", "安道尔共和国" 
214, "Spain",  "ES", "西班牙" 
216, "Hungary",  "HU", "匈牙利" 
218, "Bosnia and Herzegovina", "BA", "" 
219, "Croatia",  "HR", "克罗地亚" 
220, "Serbia and Montenegro", "CS", "塞尔维亚和黑山" 
222, "Italy",  "IT", "意大利" 
226, "Romania",  "RO", "罗马尼亚" 
228, "Switzerland", "CH", "瑞士" 
230, "Czech Republic", "CZ", "捷克" 
231, "Slovakia", "SK", "斯洛伐克" 
232, "Austria",  "AT", "奥地利" 
234, "United Kingdom", "GB", "英国" 
238, "Denmark",  "DK", "丹麦" 
240, "Sweden",  "SE", "瑞典" 
242, "Norway",  "NO", "挪威" 
244, "Finland",  "FI", "芬兰" 
246, "Lithuania", "LT", "立陶宛" 
247, "Latvia",  "LV", "拉脱维亚" 
248, "Estonia",  "EE", "爱沙尼亚" 
250, "Russia",  "RU", "俄罗斯" 
255, "Ukraine",  "UA", "乌克兰" 
257, "Belarus",  "BY", "" 
259, "Moldova",  "MD", "" 
260, "Poland",  "PL", "波兰" 
262, "Germany",  "DE", "德国" 
266, "Gibraltar", "GI", "直布罗陀" 
268, "Portugal", "PT", "葡萄牙" 
270, "Luxembourg", "LU", "卢森堡" 
272, "Ireland",  "IE", "爱尔兰" 
274, "Iceland",  "IS", "冰岛" 
276, "Albania",  "AL", "阿尔巴尼亚" 
278, "Malta",  "MT", "马耳他" 
280, "Cyprus",  "CY", "塞浦路斯" 
282, "Georgia",  "GE", "乔治亚州" 
283, "Armenia",  "AM", "亚美尼亚" 
284, "Bulgaria", "BG", "保加利亚" 
286, "Turkey",  "TR", "土耳其" 
288, "Faroe Islands", "FO", "" 
290, "Greenland", "GL", "格陵兰岛" 
293, "Slovenia", "SI", "斯洛文尼亚" 
294, "Macedonia, Former Yugoslav Republic of","MK", "" 
295, "Liechtenstein", "LI", "" 
302, "Canada",  "CA", "加拿大" 
310, "United States", "US", "美国" 
334, "Mexico",  "MX", "墨西哥" 
338, "Jamaica",  "JM", "牙买加" 
340, "French West Indies", "FW", "" 
342, "Barbados", "BB", "" 
344, "Antigua and Barbuda", "AG", "" 
346, "Cayman Islands", "KY", "" 
350, "Bermuda",  "BM", "百慕大" 
352, "Grenada",  "GD", "" 
362, "Netherlands Antillies", "AN", "" 
363, "Aruba",  "AW", "" 
368, "Cuba",  "CU", "古巴" 
370, "Dominican Republic", "DO", "" 
374, "Trinidad and Tobago", "TT", "" 
400, "Azerbaijan", "AZ", "" 
401, "Kazakhstan", "KZ", "哈萨克" 
402, "Bhutan",  "BT", "不丹" 
404, "India",  "IN", "印度" 
410, "Pakistan", "PK", "巴基斯坦" 
412, "Afghanistan", "AF", "阿富汗" 
413, "Sri Lanka", "LK", "" 
414, "Myanmar",  "MM", "缅甸" 
415, "Lebanon",  "LB", "黎巴嫩" 
416, "Jordan",  "JO", "约旦" 
417, "Syria",  "SY", "叙利亚" 
418, "Iraq",  "IQ", "伊拉克" 
419, "Kuwait",  "KW", "科威特" 
420, "Saudi Arabia", "SA", "" 
421, "Yemen",  "YE", "也门" 
422, "Oman",  "OM", "阿曼" 
424, "United Arab Emirates","UAE", "阿拉伯联合酋长国" 
425, "Israel",  "IL", "以色列" 
426, "Bahrain",  "BH", "巴林岛" 
427, "Qatar",  "QA", "卡塔尔" 
428, "Mongolia", "MN", "蒙古" 
429, "Nepal",  "NP", "尼泊尔" 
432, "Iran",  "IR", "伊朗" 
434, "Uzbekistan", "UZ", "乌兹别克斯坦" 
437, "Kyrgyzstan", "KG", "" 
438, "Turkmenistan","TM", "土库曼斯坦" 
440, "Japan","JP",日本
452, "Vietnam",  "VN", "越南" 
454, "Hong Kong", "HK", "香港" 
456, "Cambodia", "KH", "柬埔寨" 
457, "Laos",  "LA", "老挝" 
460, "China",  "CN", "中国" 
466, "Taiwan",  "TW", "台湾" 
467, "North Korea", "KP", "南韩" 
470, "Bangladesh", "BD", "孟加拉国" 
472, "Maldives", "MV", "马尔代夫" 
502, "Malaysia", "MY", "马来西亚" 
505, "Australia", "AU", "澳大利亚" 
510, "Indonesia", "ID", "印尼" 
515, "Philippines", "PH", "菲律宾" 
520, "Thailand", "TH", "泰国" 
525, "Singapore", "SG", "新加坡" 
528, "Brunei",  "BN", "汶莱" 
530, "New Zealand", "NZ", "" 
539, "Tonga",  "TO", "东加" 
541, "Vanuatu",  "VU", "" 
542, "Fiji Islands","FJ", "" 
544, "American Samoa", "AS", "萨摩亚"  
546, "New Caledonia","NC", "" 
547, "French Polynesia","PF", "波利尼西亚"  
550, "Micronesia", "FM", "" 
602, "Egypt",  "EG", "埃及" 
603, "Algeria",  "DZ", "阿尔及利亚" 
604, "Morocco",  "MA", "摩洛哥" 
605, "Tunisia",  "TN", "突尼斯" 
607, "Gambia, The", "GM", "冈比亚" 
608, "Senegal",  "SN", "塞内加尔" 
609, "Mauritania", "MR", "" 
610, "Mali",  "ML", "马里" 
611, "Guinea",  "GN", "几内亚" 
612, "C?te d’Ivoire", "CI", "" 
613, "Burkina Faso", "BF", "" 
614, "Niger",  "NE", "" 
615, "Togo",  "TG", "多哥" 
616, "Benin",  "BJ", "贝南" 
617, "Mauritius", "MU", "毛里求斯" 
618, "Liberia",  "LR", "利比里亚" 
620, "Ghana",  "GH", "加纳" 
621, "Nigeria",  "NG", "尼日利亚" 
622, "Chad",  "TD", "乍得" 
623, "Central African Republic","CF", "中非" 
624, "Cameroon", "CM", "喀麦隆" 
625, "Cape Verde", "CV", "" 
626, "S?o Tomé and Príncipe", "ST", "" 
627, "Equatorial Guinea", "GQ", "" 
628, "Gabon",  "GA", "加蓬" 
629, "Congo",  "CG", "刚果" 
630, "Congo (DRC)", "CD", "刚果" 
631, "Angola",  "AO", "安哥拉" 
633, "Seychelles", "SC", "" 
634, "Mozambique", "MZ", "莫桑比克" 
634, "Sudan",  "SD", "苏丹" 
635, "Rwanda",  "RW", "卢安达" 
636, "Ethiopia", "ET", "埃塞俄比亚" 
637, "Somalia",  "SO", "索马里" 
639, "Kenya",  "KE", "肯尼亚" 
640, "Tanzania", "TZ", "坦桑尼亚" 
641, "Uganda",  "UG", "乌干达" 
642, "Burundi",  "BI", "布隆迪" 
646, "Madagascar", "MG", "马达加斯加" 
647, "Reunion",  "RE", "" 
648, "Zimbabwe", "ZW", "津巴布韦" 
649, "Namibia",  "NA", "纳米比亚" 
650, "Malawi",  "MW", "马拉维" 
651, "Lesotho",  "LS", "" 
652, "Botswana", "BW", "" 
653, "Swaziland", "SZ", "" 
654, "Zambia",  "ZM", "赞比亚" 
655, "South Africa","ZA", "南非" 
702, "Belize",  "BZ", "" 
706, "El Salvador", "SV", "" 
710, "Nicaragua", "NI", "尼加拉瓜" 
712, "Costa Rica", "CR", "" 
716, "Peru",  "PE", "秘鲁" 
722, "Argentina", "AR", "阿根廷" 
724, "Brazil",  "BR", "巴西" 
730, "Chile",  "CL", "智利" 
734, "Venezuela", "VE", "委内瑞拉" 
736, "Bolivia",  "BO", "玻利维亚" 
744, "Paraguay", "PY", "巴拉圭" 
746, "Suriname", "SR", ""

你可能感兴趣的:(Modem&Module)