The GPRS internet access process of Android:
1. Open the data service device corresponding to the module in the RIL layer, such as/dev/ttyusb3.
2. Send the at + cgdcont command to the data device to specify the corresponding APN and send dialing commands such as atdt * 98*1 #.
3. After the above at command returns OK, you can start the pppd_gprs script. Before starting, set the attributes of the APN, such as user, PWD, and device.
View plain
- Property_set ("net. GPRS. User", user );
- Property_set ("net. GPRS. Password", PWD );
- Property_set ("net. GPRS. device", device );
- Property_set ("net. GPRS. PPP-Exit ","");
- Property_set ("CTL. Start", "pppd_gprs ");
4, attribute setting process in my previous blog has a detailed description of http://blog.csdn.net/yinlijun2004/article/details/6981954
See the code of the void handle_property_set_fd (int fd) function in property_service.c.
View plain
- Switch (msg. cmd ){
- Case prop_msg_setprop:
- MSG. name [PROP_NAME_MAX-1] = 0;
- MSG. value [PROP_VALUE_MAX-1] = 0;
- If (memcmp (msg. Name, "CTL.", 4) = 0 ){
- If (check_control_perms (msg. Value, Cr. uid, Cr. GID )){
- Handle_control_message (char *) MSG. Name + 4, (char *) msg. value );
- } Else {
- Error ("sys_prop: Unable to % s service CTL [% s] uid: % d PID: % d \ n ",
- MSG. Name + 4, MSG. Value, Cr. uid, Cr. PID );
- }
Call the handle_control_message function of init. c Based on the attribute key value "CTL. Start ".
View plain
- Void handle_control_message (const char * MSG, const char * Arg)
- {
- If (! Strcmp (MSG, "Start ")){
- Msg_start (ARG );
- } Else if (! Strcmp (MSG, "stop ")){
- Msg_stop (ARG );
- } Else {
- Error ("unknown control MSG '% s' \ n", MSG );
- }
- }
In msg_start, find the service named pppd_gprs. The service name is also the script name, and then start and modify the service, that is, run the pppd_gprs script.
View plain
- Static void msg_start (const char * name)
- {
- Struct Service * SVC;
- Char * TMP = NULL;
- Char * ARGs = NULL;
- If (! Strchr (name ,':'))
- SVC = service_find_by_name (name );
- Else {
- TMP = strdup (name );
- ARGs = strchr (TMP ,':');
- * ARGs = '\ 0 ';
- ARGs ++;
- SVC = service_find_by_name (TMP );
- }
- If (SVC ){
- Service_start (SVC, argS );
- } Else {
- Error ("No such service '% s' \ n", name );
- }
- If (TMP)
- Free (TMP );
- }
5. The pppd_gprs service is defined in the initialization script init. XX. RC and parsed from parser. C to service_list.
View plain
- Service pppd_gprs/system/xbin/pppd_gprs
- User Root
- Group Root
- Oneshot
- Disabled
6. The pppd_gprs script reads the attributes of the configured APN and runs the pppd process.
View plain
- User = '/system/bin/getprop net. GPRS. user'
- Password = '/system/bin/getprop net. GPRS. password'
- Device = '/system/bin/getprop net. GPRS. devic'
- /System/bin/setprop net. GPRS. PPP-Exit ""
- /System/bin/pppd-Detach $ device 115200 noipdefault noauth debug novj usepeerdns noccp ipcp-no-addresses kdebug 4 defaultroute user $ User Password $ Password
- /System/bin/setprop net. GPRS. PPP-exit $?
- # Exit $?
7. After the pppd_gprs script is executed, the RIL layer reads/sys/class/NET/ppp0/operstate to monitor the status of data network data.
From: http://blog.csdn.net/yinlijun2004/article/details/7007046
The GPRS internet access process of Android:
1. Open the data service device corresponding to the module in the RIL layer, such as/dev/ttyusb3.
2. Send the at + cgdcont command to the data device to specify the corresponding APN and send dialing commands such as atdt * 98*1 #.
3. After the above at command returns OK, you can start the pppd_gprs script. Before starting, set the attributes of the APN, such as user, PWD, and device.
View plain
- Property_set ("net. GPRS. User", user );
- Property_set ("net. GPRS. Password", PWD );
- Property_set ("net. GPRS. device", device );
- Property_set ("net. GPRS. PPP-Exit ","");
- Property_set ("CTL. Start", "pppd_gprs ");
4, attribute setting process in my previous blog has a detailed description of http://blog.csdn.net/yinlijun2004/article/details/6981954
See the code of the void handle_property_set_fd (int fd) function in property_service.c.
View plain
- Switch (msg. cmd ){
- Case prop_msg_setprop:
- MSG. name [PROP_NAME_MAX-1] = 0;
- MSG. value [PROP_VALUE_MAX-1] = 0;
- If (memcmp (msg. Name, "CTL.", 4) = 0 ){
- If (check_control_perms (msg. Value, Cr. uid, Cr. GID )){
- Handle_control_message (char *) MSG. Name + 4, (char *) msg. value );
- } Else {
- Error ("sys_prop: Unable to % s service CTL [% s] uid: % d PID: % d \ n ",
- MSG. Name + 4, MSG. Value, Cr. uid, Cr. PID );
- }
Call the handle_control_message function of init. c Based on the attribute key value "CTL. Start ".
View plain
- Void handle_control_message (const char * MSG, const char * Arg)
- {
- If (! Strcmp (MSG, "Start ")){
- Msg_start (ARG );
- } Else if (! Strcmp (MSG, "stop ")){
- Msg_stop (ARG );
- } Else {
- Error ("unknown control MSG '% s' \ n", MSG );
- }
- }
In msg_start, find the service named pppd_gprs. The service name is also the script name, and then start and modify the service, that is, run the pppd_gprs script.
View plain
- Static void msg_start (const char * name)
- {
- Struct Service * SVC;
- Char * TMP = NULL;
- Char * ARGs = NULL;
- If (! Strchr (name ,':'))
- SVC = service_find_by_name (name );
- Else {
- TMP = strdup (name );
- ARGs = strchr (TMP ,':');
- * ARGs = '\ 0 ';
- ARGs ++;
- SVC = service_find_by_name (TMP );
- }
- If (SVC ){
- Service_start (SVC, argS );
- } Else {
- Error ("No such service '% s' \ n", name );
- }
- If (TMP)
- Free (TMP );
- }
5. The pppd_gprs service is defined in the initialization script init. XX. RC and parsed from parser. C to service_list.
View plain
- Service pppd_gprs/system/xbin/pppd_gprs
- User Root
- Group Root
- Oneshot
- Disabled
6. The pppd_gprs script reads the attributes of the configured APN and runs the pppd process.
View plain
- User = '/system/bin/getprop net. GPRS. user'
- Password = '/system/bin/getprop net. GPRS. password'
- Device = '/system/bin/getprop net. GPRS. devic'
- /System/bin/setprop net. GPRS. PPP-Exit ""
- /System/bin/pppd-Detach $ device 115200 noipdefault noauth debug novj usepeerdns noccp ipcp-no-addresses kdebug 4 defaultroute user $ User Password $ Password
- /System/bin/setprop net. GPRS. PPP-exit $?
- # Exit $?
7. After the pppd_gprs script is executed, the RIL layer reads/sys/class/NET/ppp0/operstate to monitor the status of data network data.
From: http://blog.csdn.net/yinlijun2004/article/details/7007046