2015年11月9日 星期一


3G USB dongle 之撥接



"台灣人可能想都沒想過,MIT竟能打敗迪士尼體感設施的代工廠商;更沒想過,好萊塢電影產業爭相搶著合作的3D技術團隊,就在高雄。" 
- See more at: http://www.cw.com.tw/article/article.action?id=5054790&utm_source=ETU&utm_medium=referral&utm_campaign=ETU&eturec=1&ercamp=article_interested#sthash.NayOJ4n5.dpuf



Terms:
DC: Dialing Control

The overall 3G dial process is designed as a module called DC, and depicted as a timing synchronization (to handle race condition) , dialing control, modem replacement, SIM card replacement, pin code verification, error handling, dial-on-demand.

The 3G logistic schema of dialing function is designed to base on the hot-plug mechanism of MR3306a USB subsystem to have 3G dialer behavior dynamically and automatically handle 3G connection to ISP 3G network per crond cycle(i.e. the period set in crontab).

When the 3G is running, then the cron daemon will periodically call the function, cron_3g_start, a entry function of dialing control (DC), to maintain 3g connection. This is also the auto re-start mechanism, and the 3g connection will be initiated by cron daemon when no any 3G connection.

There are 3 major parts in 3G application, i.e. device management, dialer, budget control.
The device management, Our design in it mainly rely on 3 mechanism:
1. the device detection
  To look into the kernel for 3G/HSPA device id and product id to make sure what device is discovered..
     
2. USB subsystem hot-plug mechanism
   udevd handles all device discovery, we will have working rules to tell what device
2.1 plug-in detection
   serialize the signaling from kernel, exclusive successive signal.
   according to the signaling event, we define the handling routine.
2.2 unplug detection
       according to the signaling event, we define the handling routine.  
shut down 3G /HSPA service.
  
3. install device driver:
Because the 3G modem in the market is often being in the style of zeroCD, i.e. when the device insert into USB connector, then it is be identified as a storage device, like CDROM. When it is a storage mode, the usbserial driver cannot scratch it, so the driver installation is failed.
This is due to he fact that device has usb storage to store windows driver etc. as well as modem. Due to this Linux kernel drivers get confused. While Huawei seems to be working to get the appropriate modification in kernel drivers done, as of now it is not there. One way to solve is using 'usb_modeswitch' program to switch USB gear from the storage mode to the modem mode. A utility called mode switch can do that.
   driver:
       usbserial, cdcam, airprime, option, sierra, or customized

USB_ModeSwitch is a mode switching tool for controlling "flip flop" (multiple device) USB gear.

Configuration
-----------------
mainly pppd  profile and  chat script to dial up the internet
we should know  (1)3G operator server's basic settings and (2)modem device settings.
such as, 
crtscts
modem
noauth
usepeerdns
defaultroute
noipdefault
noccp
nobsdcomp

novjmodem port: /dev/ttyUSB0, baud rate:460800, AT command string

Statistics
3G access statistics information
- BC  settings and policy rules of time and data,
  remaining budget, summated elapsed time(elapse base),  download/upload/DL+UL(data base)

Troubleshooting
1. remote debugging
2.  manual mode --> pppd debug mode  to look into --> embedded  codes to verify what happen and resolve


1. Dialing Control(DC)
3G dialing control run on MR3305a/MR3306a hardware platform with embedded Linux v2.6.17 and busybox v1.01. The execution environment is configured as smc/mr3306a/accton configuration, and WAN configured to work at 3G mode. The default pin code of SIM card is enabled protection. VPC is designed to exam the pin code. Please see VPC section. For the sake of prevent SIM locked before over times, we design a VPC module to handle. To avoid the race condition at run time, we design a complicated logical mechanism to serialize the processes lines. The forbidden conditions is classified
1.1  no any modem device is detected
1.2  no dial process is initiated.
1.3  already have dial process is on-going,
1.4  pin code is wrong
1.5  no budget is over, except that budget is reset during the same billing period.

2. PIN code protection verification(VPC)
what we do is to exam PIN code consistence with both user input side and SIM card side, just a correction verification.

There are 2 times of opportunities to verify the pin code consistence. The VPC issue a command to SIM card, then SIM card reply the message according to its status.


3.hot-plug -udevd
If you do hot-plug the 3G modem, please give it a period of 5~8 seconds(suggestion)  because it need some time to shut down all wan service.
1.      Cyclically monitor 3g device exists
Monitor on-line is a mechanism to maintain 3g connection status, by means of cron schedule.  The hot-plug mechanism is not function well in all 3G modems. Some is good, and some is function bad. It needs detection on schedule when every cycle. When a device with abnormal hot-plug behavior, then we have to do clean action to let start 3g go. i.e.  remove garbage flag, information, pppd process, and drivers.

The function of cron 3g automatically restart when 3g disconnected is relying on system hot-plug mechanism.
Initially, the cron 3g process will be blocked outside the protection area of 3g dial process, but the successive cron 3g process has its own short life cycle to die. In general, it have good behavior, so you see the alias from "ps" command. But it still have its limitation when overall system is confusing and out of controlled.  After that, the cron daemon will periodically call cron 3g


4. device existence detection

Please see the file /var/3gs/simlog.
The file tell you some basic action when call comgt.
1: SIM READY -- pin code protection enable and verification OK.
2. Netowrk registrate to some local 3G ISP network.
3. signal quality



The function of cron 3g automatically restart when 3g disconnected is relying on system hot-plug mechanism.
Initially, the cron 3g process will be blocked outside the protection area of 3g dial process, but the successive cron 3g process has its own short life cycle to die. In general, it have good behavior, so you see the alias from "ps" command. But it still have its limitation when overall system is confusing and out of controlled.  After that, the cron daemon will periodically call cron 3g

If you do hot-plug the 3G modem, please give it a period of  5~8 seconds(suggestion)  because it need some time to shut down all wan service.



The variables:
wan_3g_last_setPincode_Error:
       0: Normal correct pincode
       1: Wrong PIN Code

wan_3g_connection_state:
       0: network connected
       1: dial failure code
       2: unreachable host or network
       3: gateway ip address not found
       4: 3G/HSDPA usb device not ready
       5: iface $run_if connection has ready
       6: plug-out or doesn't exist on USB port
       7: plugged in
       8: force stop 3G
       9: Wrong PIN Code
      10: No iface $run_if available
      11: time-out

wan_3g_err_pincode_count
       pin remaining attempt number



LED message lights:
3G Led fast blink -------- led_ctl 10, entering the wrong PIN code
3G Led Off --------------- led_ctl 11, when dev not exists, or dial fail
3G Led Blink slowly ---- led_ctl 12, when dev exists and dial is progressing
3G Led On ---------------- led_ctl 13, dial succeed



Start 3G by auto/manual mode
2.      Manual start
2.1  Networking settings/start mode
Scenario 1: user select what start mode is used auto start or manual start
Function name:
Start_by_mode
Meta variable: Wan_3g_start_mode
                0: automatically start
                1: manually start
Logistical:
Just only save parameters into meta when user select manually start
If user select automatically start mode, then it is work as original designed function.
     
2.2  WEB UI Information/manual start/manual stop
This is scenario is working in the manual mode only.
Scenario 2: manually start/stop 3G from information page when in manual mode
               this case does not allow automatic mode function work.

2.3  Hardware button

scenario 3: user press the button on box. the hard push button is a toggle switching 3g service on or off

沒有留言:

張貼留言