Huawei 3G Module Dial-up Internet

Source: Internet
Author: User
Tags nameserver





Introduction to a development environment





Kernel version 3.19.5, 3.15 (all 2 of which I have tried)



Compilation Environment Ubuntu 12.04



SIM card Unicom





Two main steps





Support for adding 3G module drivers (option drivers for USB to serial ports) and PPP network protocols to the Linux kernel





Cross-compiling ppp-2.4.2 source code



Copy the two applications PPPD and chats required for dial-up Internet to the Development Board/usr/sbin folder.



Write PPP dial scripts WCDMA, Wcdma-chat-connect, wcdma-chat-disconnect and stored in the/etc/ppp/peers directory. Write DNS to the/etc/resolv.conf file


perform the "PPPD call WCDMA" command to dial







You can also follow these steps:






First go to make Menuconfig interface


1 Configuring 3G module Drivers


Figure 1



1 First select Device Drivers






Figure 2



2 Entering USB support






Figure 3



Go down to USB support until you find Figure 3 and select USB to serial port






Figure 4



Finally select USB driver for GSM and CDMA modems to this 3G card driver has been added complete



The main additions are driver/usb/serial/option.c and driver/usb/serial/usb_wwan.c.



Two files, although the driver has been added, but this is only a USB-to-serial driver, and can not be used as a network device directly, at this time need to support the PPP network protocol, he will ttyusb* and other devices to simulate the use of network equipment (/dev/ttyusb0<----> PPP0)





2 Adding PPP protocols


Also enter make Menuconfig interface






Figure 5



The first is also to enter the driver configuration Interface Device Drivers






Figure 6



6 Select Network Device Support







7 Choosing PPP



Both drivers and protocols have been configured successfully. The next step is to compile and download to the board.


View Development Board Dev Directory


[Email protected] ~]# LS/DEV/TTYUSB
TtyUSB0 ttyUSB1 ttyUSB2 ttyUSB3





Four writing PPP dialing scripts





Because the dial-up script needs to use CHAT,PPPD, such as commands, you need to download ppp-2.4.4



After the download is successful, the first is compile



1 Compiling ppp-2.4.4



Generally very good, but may rely on libpcap-1.6.2.tar.gz this library, zlib library. If there is an error about libcrypt.so during compilation, put the/usr/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib/libcrypt.so in your compilation tool directory This library can be copied to/usr/local/lib/.



Compile the generated CHAT,PPPD, and then copy the command to the/usr/sbin directory of the board file system.





2 Writing a dial-up script





Create three files below the/etc/ppp/peers directory of the board file system below



Wcdma,chat-wcdma-connect,chat-wcdma-disconnect



WCDMA Configuration file Contents



Debug



Nodetach



/dev/ttyusb0



115200



Usepeerdns



Noauth



Noipdefault



Novj



Novjccomp



Noccp



Defaultroute



Ipcp-accept-local



Ipcp-accept-remote



Connect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-wcdma-connect '



Disconnect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-wcdma-disconnect '






Wcdma-chat-connect Configuration file Contents



TIMEOUT 5



ABORT ' NO CARRIER '



ABORT ' ERROR '



ABORT ' Nodialtone '



ABORT ' BUSY '



ABORT ' NO ANSWER '



"' \rat



OK \ratz



Ok \rat+cgdcont=1, "IP", "3GNET", 0,0



Ok-at-ok atdt*99#



CONNECT \d\c






Wcdma-chat-disconnect Configuration file Contents



ABORT "ERROR"



ABORT "Nodialtone"



SAY "\nsending break to the modem\n"



"\k"



"+++ath"



SAY "\ngoodbay\n"






After the dial script is created, it's officially dialed.



PPPD Call wcdma&


The & symbol is mainly because after the successful dialing, the program will always execute without exiting, so thepppd call WCDMA is the function of establishing the protocol and generating the network interface ppp0. You can also modifyWCDMAScript#Nodetach, and then execute the commandPPPD call WCDMA can be run in the background.


If the following behavior occurs:






Indicates a successful dial-up.






3. Test network connectivity



Ping-i ppp0 www.baidu.com -C 5-i 1 timeout occurs



Route View routing Table



The default gateway is eth0, which removes the default gateway route del Deflaut. Add Ppp0 as default gateway route add default Dev ppp0. manually add DNS echo "nameserver 123.123.123.124" > /etc/ resolv.conf



Ping-i ppp0 www.baidu.com -C 5-s 1







Network communication is normal


Five, realize automatic dialing


Mainly wrote 2 script files, one is the configuration script init.sh, the content is as follows:



echo "NameServer 123.123.123.124" >/etc/resolv.conf
Route del Default
Route add default Dev ppp0
Ifconfig eth0 Down
ifconfig eth0 hw ether 00:12:34:56:78:90
Ifconfig eth0 up



The other is the automatic dialing script pp.sh. The contents are as follows:


dns1= "61.135.169.121" #baidu
Dns2= "61.135.157.156" #qq
PPPD Call WCDMA &
Sleep 12
/root/init.sh
While True
Do
Ping-s 1-c 5 $dns 1 #| ... To ping the first DNS
If ["$?"! = "0"] #€| ... If the ping does not pass
Then
Ping-s 1-c 2 $dns 2 # ... To ping a second DNS
If ["$?"! = "0"] #| ... If the ping does not pass
Then
Killall pppd #| ... End PPPD Process
PPPD call WCDMA & # ... Dial again.
Sleep 12 #€| ... ET 2s
Else
Sleep 5 '
Fi
Else
Sleep 120 #)

Fi
Done


With this script, you can rest assured that the Internet.



Some people also want to get the signal strength of dial-up internet in real time. There are 2 ways to do this.



1, through Microcom-s 115200/dev/ttyusb0 this way to use Ctrl+x to quit!



Input AT+CSQ



At+csq
+csq:11,99


Ok



You can see that the signal strength is 11.



2, can also write a program, through the ttyUSB2 to send the AT+CSQ command, note that this command to the end of \ R, as follows:








Six notes





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.