1

Temat: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Witam,
z chęcią podzielę się moimi doświadczeniami i skryptami związanymi z połączeniami przez modemy 3G w trybie NDIS/CDC, kilku modemów z multiwanem.

Przykładowa konfiguracja to:

  • Router Linksys WRT160NL

  • 2 modemy HUAWEI E173

  • hub USB

  • OpenWrt Backfire 10.03.1

  • 2 karty SIM Aero2

  • port WAN podłączny do modemu kablowego (to konfiguracja testowa)

Założenia:

  • Szybsze nawiązywanie połączania i większy transfer dzięki NDIS

  • Niezawodne wznawianie połączenia

  • Prawie wszystko konfigurowalne z /etc/config/network

Na początek instalacja CDC tak aby modemy mogły pracować w trybie NDIS:
(Jest to wszystko świetnie opisane u Cezarego http://eko.one.pl/?p=openwrt-ndis więc nie będzie tu szczegułów)

opkg update
opkg install kmod-usb-net-cdc-ether

Teraz ustawienia dla network:

uci set network.wan2=interface
uci set network.wan2.ifname=usb0
uci set network.wan2.proto=dhcp
uci set network.wan2.comm=/dev/ttyUSB2
uci set network.wan2.mode="AT^SYSCFG=2,2,3FFFFFFF,2,4"
uci set network.wan2.pincode=
uci set network.wan2.apn=darmowy
uci set network.wan2.username=
uci set network.wan2.password=
uci set network.wan2.macaddr=00:01:02:03:04:05
uci set network.wan2.auto=0
uci set network.wan2.defaultroute=0
uci set network.wan2.peerdns=0
uci set network.wan2.dns='8.8.8.8 8.8.4.4'

uci set network.wan3=interface
uci set network.wan3.ifname=usb1
uci set network.wan3.proto=dhcp
uci set network.wan3.comm=/dev/ttyUSB5
uci set network.wan3.mode="AT^SYSCFG=2,2,3FFFFFFF,2,4"
uci set network.wan3.pincode=
uci set network.wan3.apn=darmowy
uci set network.wan3.username=
uci set network.wan3.password=
uci set network.wan3.macaddr=00:01:02:03:04:05
uci set network.wan3.auto=0
uci set network.wan3.defaultroute=0
uci set network.wan3.peerdns=0
uci set network.wan3.dns='8.8.8.8 8.8.4.4'

uci commit network

Dodatkiem są dwa parametry:
- “comm” to port komunikacyjny (najczęściej ostatni dla danego modemu)
- “mode” identycznie jak w rozwiązaniach Cezarego, dodatkowe ustawianie trybu pracy modemu.

Poniżej podpowiedź ja skonstruować komendę według własnych potrzeb:

AT^SYSCFG=$mode, $acqOrder, $band, $roam, $srvDomain

$mode
2=Auto-Select
13=GSM only
14=WCDMA only
16=no Change

$acqOrder
0=Automatic
1=GSM prefered
2=WCDMA prefered
3=no Change

$band
EGSM(900): 00000100
DCS(1800): 00000080
PCS(1900): 00200000
GSM850: 00080000
WCDMA2100: 00400000
3fffffff = All

$roam
0=Not Supported
1=Supported
2=no Change

$srvDomain
0=Circuit-Switched only
1=Packet-Switched only
2=Circuit- & Packet-Switched
3=Any
4=no Change

I przykłady:
Any : AT^SYSCFG=2,0,3FFFFFFF,2,4
2G only : AT^SYSCFG=13,1,3FFFFFFF,2,4
3G only : AT^SYSCFG=14,2,3FFFFFFF,2,4
2G preferred : AT^SYSCFG=2,1,3FFFFFFF,2,4
3G preferred : AT^SYSCFG=2,2,3FFFFFFF,2,4

Teraz fire wall:

uci add firewall zone
uci set firewall.@zone[-1]=zone
uci set firewall.@zone[-1].name=wan2
uci set firewall.@zone[-1].network=wan2
uci set firewall.@zone[-1].input=REJECT
uci set firewall.@zone[-1].output=ACCEPT
uci set firewall.@zone[-1].forward=REJECT
uci set firewall.@zone[-1].masq=1
uci set firewall.@zone[-1].mtu_fix=1

uci add firewall forwarding
uci set firewall.@forwarding[-1]=forwarding
uci set firewall.@forwarding[-1].src=lan
uci set firewall.@forwarding[-1].dest=wan2

uci add firewall zone
uci set firewall.@zone[-1]=zone
uci set firewall.@zone[-1].name=wan3
uci set firewall.@zone[-1].network=wan3
uci set firewall.@zone[-1].input=REJECT
uci set firewall.@zone[-1].output=ACCEPT
uci set firewall.@zone[-1].forward=REJECT
uci set firewall.@zone[-1].masq=1
uci set firewall.@zone[-1].mtu_fix=1

uci add firewall forwarding
uci set firewall.@forwarding[-1]=forwarding
uci set firewall.@forwarding[-1].src=lan
uci set firewall.@forwarding[-1].dest=wan3

uci commit firewall

Następnie edytujemy plik /etc/rc.local dodając na końcu dwie linie:

sleep 5
/bin/3gtester.sh

Jeszcze pozostaje dodanie do crontab wywołanie 3gtestera, linijka może wyglądać tak:

*/2 * * * * /bin/3gtester.sh

I jeszcze instalacja i konfiguracja multiwan-u:

opkg update
opkg install multiwan

uci set multiwan.config=multiwan
uci set multiwan.config.health_monitor=serial
uci set multiwan.config.default_route=balancer
uci set multiwan.config.debug=0

uci set multiwan.wan=interface
uci set multiwan.wan.health_fail_retries=3
uci set multiwan.wan.health_interval=10
uci set multiwan.wan.health_recovery_retries=5
uci set multiwan.wan.weight=10
uci set multiwan.wan.icmp_hosts=dns
uci set multiwan.wan.timeout=3
uci set multiwan.wan.failover_to=balancer
uci set multiwan.wan.dns=auto

uci set multiwan.wan2=interface
uci set multiwan.wan2.health_fail_retries=3
uci set multiwan.wan2.health_interval=10
uci set multiwan.wan2.health_recovery_retries=5
uci set multiwan.wan2.weight=10
uci set multiwan.wan2.icmp_hosts=dns
uci set multiwan.wan2.timeout=3
uci set multiwan.wan2.failover_to=balancer
uci set multiwan.wan2.dns='8.8.8.8 8.8.4.4'

uci set multiwan.wan3=interface
uci set multiwan.wan3.health_fail_retries=3
uci set multiwan.wan3.health_interval=10
uci set multiwan.wan3.health_recovery_retries=5
uci set multiwan.wan3.weight=10
uci set multiwan.wan3.icmp_hosts=dns
uci set multiwan.wan3.timeout=3
uci set multiwan.wan3.failover_to=balancer
uci set multiwan.wan3.dns='8.8.8.8 8.8.4.4'

uci delete multiwan.@mwanfw[-1]
uci delete multiwan.@mwanfw[-1]
uci delete multiwan.@mwanfw[-1]
uci add multiwan mwanfw
uci set multiwan.@mwanfw[-1]=mwanfw
uci set multiwan.@mwanfw[-1].wanrule=fastbalancer
uci add multiwan mwanfw
uci set multiwan.@mwanfw[-1]=mwanfw
uci set multiwan.@mwanfw[-1].wanrule=wan
uci add multiwan mwanfw
uci set multiwan.@mwanfw[-1]=mwanfw
uci set multiwan.@mwanfw[-1].wanrule=wan2
uci add multiwan mwanfw
uci set multiwan.@mwanfw[-1]=mwanfw
uci set multiwan.@mwanfw[-1].wanrule=wan3

uci commit multiwan

/etc/init.d/multiwan start
/etc/init.d/multiwan enable

A tu zaczyna się coś najważniejszego w tej koncepcjismile

Tak wygląda skrypt do podnoszenia połączenia 3G, należy wkleić go do pliku /bin/3gtester.sh

#!/bin/sh
# Establishing 3G modem connection in dialup or NDIS mode
# Script version 1.00 Rafal Drzymala 2012
#
# Changelog
# 1.00 RD First stable code
#
SCR=$(basename $0)
ICMP="8.8.8.8"
WANS=$(uci show network | awk -F[.=] '{if (($3=="proto" && $4=="3g") || ($3=="ifname" && match($4,"usb[0-9]"))) print $2}')
for WAN in $WANS; do
    NDIS="N"
    [ $(uci -q get network.$WAN.proto) != "3g" ] && NDIS="Y"
    DEV_IFNAME=$(uci -q get network.$WAN.ifname)
    DEV_APN=$(uci -q get network.$WAN.apn)
    DEV_PINCODE=$(uci -q get network.$WAN.pincode)
    DEV_MODE=$(uci -q get network.$WAN.mode)
    [ "$NDIS" == "Y" ] && DEV_COMM=$(uci -q get network.$WAN.comm)
    [ "$NDIS" == "N" ] && DEV_COMM=$(uci -q get network.$WAN.device)
    DEV_AUTO="1"
    [ "$NDIS" == "N" ] && DEV_AUTO=$(uci -q get network.$WAN.auto)
    logger -t $SCR "Checking $WAN for active connection"
    logger -t $SCR " interface=$DEV_IFNAME"
    logger -t $SCR " apn=$DEV_APN"
    logger -t $SCR " comm=$DEV_COMM"
    [ "$DEV_MODE" != "" ] && logger -t $SCR " mode=$DEV_MODE"
    if [ "$DEV_AUTO" == "1" ]; then
        if [ -e $DEV_COMM ]; then
            if ping -q -c 1 -W 5 -I $DEV_IFNAME $ICMP > /dev/null; then
                logger -t $SCR "ICMP successfully sent via $WAN"
            else
                logger -t $SCR "Restarting $WAN connection"
                if [ "$NDIS" == "N" ]; then
                    (ifdown $WAN; sleep 2; ifup $WAN) &
                else
                    (ifdown $WAN; PINCODE=$DEV_PINCODE APN=$DEV_APN MODE=$DEV_MODE gcom -d $DEV_COMM -s /etc/gcom/ndisup.gcom; sleep 5; ifup $WAN) &
                fi
            fi
        else
            logger -t $SCR "Device $DEV_COMM for $WAN not exist"
        fi
    fi
done
# Done

A oto skrypt dla gcom, należy go wkleić do pliku /etc/gcom/ndisup.gcom

opengt
    let $x="ndisup:"+$basename($dev())+" "
    print $x+"Establishing 3G modem connection in NDIS mode\n"
    print $x+"Script for comgt version 1.00 Rafal Drzymala 2012\n"
#
# Changelog
# 1.00 RD First stable code
#
# Modem succesfuly tested
# - HUAWEI E173        11.126.85.00.209
# Modem tested, not supported 
# - HUAWEI E160G    11.608.02.02.55
# - HUAWEI E160        11.604.09.00.00
# - HUAWEI E220
#
    set com 115200n81
    set ignorecase on
    set comecho off
    set senddelay 0.02

    let $a=$env("APN")
    let $m=$env("MODE")
    let $p=$env("PINCODE")

    if  $a = "" print $x+"APN environment var not specified\n" goto  finish    
    let r1=0

:start
# Initializing communication with modem
    if r1=1 print $x+"Try to communicate with modem\n"
    if r1>1 print $x+"Again try to communicate with modem (",r1,")\n"
    waitquiet 2 0.5
    send "ATQ0; E0^m"
    waitfor 1 "OK"
    if % = -1 goto comm_timeout
    send "AT+CMEE=2^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5
    send "AT\^CURC=0^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5

# Getting device information
    print $x+"Getting device information\n"
    waitquiet 1 0.2 
    send "AT+CGMI^m"
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    waitquiet 1 0.1
    send "AT+CGMM^m"
    get 1 "^mOK^m" $i2
    if % != 0 goto comm_timeout
    waitquiet 1 0.1 
    send "AT+CGMR^m"
    get 1 "^mOK^m" $i3
    if % != 0 goto comm_timeout
    waitquiet 1 0.1
    send "AT+CGSN^m"
    get 1 "^mOK^m" $i4
    if % != 0 goto comm_timeout
    if len($i1)>1 let $i1=$right($i1,len($i1)-1)
    if len($i2)>1 let $i2=$right($i2,len($i2)-1)
    if len($i3)>1 let $i3=$right($i3,len($i3)-1)
    if len($i4)>1 let $i4=$right($i4,len($i4)-1)
    print $x+"- modem: "+$toupper($i1)+" "+$toupper($i2)+"\n"
    print $x+"- firmware: "+$i3+"\n"
    print $x+"- IMEI: "+$i4+"\n"
:end_devinfo

# Checking modem for NDIS support
    print $x+"Checking modem for NDIS support\n"
    send "AT\^DIALMODE?^m" 
    waitfor 5 "\^DIALMODE:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % > 0 print $x+"- This modem doesn't support NDIS mode\n" goto abort
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    let $i1=$left($i1,1)
    if $i1 = "1" goto ok_ndis_check
    if $i1 = "2" goto ok_ndis_check
    print $x+"- This modem doesn't support NDIS mode\n"
    goto abort
:ok_ndis_check
    print $x+"- NDIS mode is supported by this modem\n"
    waitquiet 1 1

# Checking for password input request
    print $x+"Checking for password input request\n"
    let u=0
    send "AT+CPIN?^m"
    waitfor 5 "+CPIN: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while checking for password input request\n" goto end_chkpin
    if % = 2 gosub cme_error print $x+"Error "+$e+" while checking for password input request\n" goto end_chkpin
    if % = 3 print $x+"Command not supported\n" goto end_chkpin
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    let $d="Unknown modem response ("+$i1+")"
    if $i1 = "READY" let $d="MT without password input request"
    if $i1 = "SIM PIN" let $d="UICC/SIM PIN password request"
    if $i1 = "SIM PUK" let $d="UICC/SIM PUK password request, to unblock the SIM PIN which was blocked for 3 verification failure"
    if $i1 = "SIM PIN2" let $d="PIN2 password request"
    if $i1 = "SIM PUK2" let $d="PUK2 password request, to unblock the SIM PIN2 which was blocked for 3 verification failure"
    if $i1 = "PH-SIM PIN" let $d="SIM lock (phone-to-SIM) is required"
    if $i1 = "PH-NET PIN" let $d="Network personnalisation is required"
    print $x+"- state: "+$d+"\n"
    if $i1 = "SIM PIN" goto do_pin_unlock
    if $i1 <> "READY" goto finish
:end_chkpin

# Unlock the PIN 
    goto end_pin_unlock
:do_pin_unlock
    print $x+"UICC/SIM unlocking by PIN\n"
    if $p = "" print $x+"PINCODE environment var not specified\n" goto abort
    send "AT+CPIN="+$p"^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while unlocking by PIN\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while unlocking by PIN\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto end_chkpin
    print $x+"UICC/SIM unlocked successfully\n"
    let r2=0
:wait_for_reg
    let r2=r2+1
    if r2>5 print $x+"Number of retries exhausted\n" goto abort
    print $x+"Waiting for network registration (",r2,")\n"
    send "AT+CGREG=0; +CGREG?^m"
    waitfor 2 "+CGREG: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting network registration status\n" goto end_pin_unlock
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting network registration status\n" goto end_pin_unlock
    if % = 3 print $x+"Command not supported\n" goto end_pin_unlock
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^m^mOK^m" $i2
    if % != 0 goto comm_timeout
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" waitquiet 1 5 goto wait_for_reg
    if $i2 = "1" goto end_pin_unlock
    if $i2 = "2" waitquiet 1 5 goto wait_for_reg
    if $i2 = "3" let $d="Registration rejected"
    if $i2 = "4" let $d="Unknown reasons"
    if $i2 = "5" goto end_pin_unlock
    print $x+"- error: "+$d+"\n"
    goto abort
:end_pin_unlock

# Getting system information
:do_sysinfo
    print $x+"Getting system information\n"
    send "AT\^SYSINFO^m"
    waitfor 5 "\^SYSINFO:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting system information\n" goto end_sysinfo
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting system information\n" goto end_sysinfo
    if % = 3 print $x+"Command not supported\n" goto end_sysinfo
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "," $i2
    if % != 0 goto comm_timeout
    get 1 "," $i3
    if % != 0 goto comm_timeout
    get 1 "," $i4
    if % != 0 goto comm_timeout
    get 1 "^mOK^m" $i5
    if % != 0 goto comm_timeout
    if len($i5)>3 let $i6=$right($i5,1)
    let $i5=$left($i5,1)
    let $d="Unknown modem response ("+$i1+")"
    if $i1 = "0" let $d="No service"
    if $i1 = "1" let $d="Restricted service"
    if $i1 = "2" let $d="Valid service"
    if $i1 = "3" let $d="Restricted regional service"
    if $i1 = "4" let $d="Power-saving and deep sleep state"
    print $x+"- service state: "+$d+"\n"
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" let $d="No service"
    if $i2 = "1" let $d="Only CS service"
    if $i2 = "2" let $d="Only PS service"
    if $i2 = "3" let $d="PS+CS service"
    if $i2 = "4" let $d="CS and PS not registered, searching"
    print $x+"- domain: "+$d+"\n"    
    let $d="Unknown modem response ("+$i3+")"
    if $i3 = "0" let $d="Non roaming state"
    if $i3 = "1" let $d="Roaming state"
    print $x+"- roaming: "+$d+"\n"
    let $d="Unknown modem response ("+$i4+")"
    if $i4 = "0" let $d="No service"
    if $i4 = "1" let $d="AMPS mode"
    if $i4 = "2" let $d="CDMA mode"
    if $i4 = "3" let $d="GSM/GPRS mode"
    if $i4 = "4" let $d="HDR mode"
    if $i4 = "5" let $d="WCDMA mode"
    if $i4 = "6" let $d="GPS mode"
    if $i4 = "7" let $d="GSM/WCDMA"
    if $i4 = "8" let $d="CDMA/HDR HYBRID"
    if $i4 = "15" let $d="TD-SCDMA mode"
    print $x+"- mode: "+$d+"\n"
    let $d="Unknown modem response ("+$i5+")"
    if $i5 = "0" let $d="Invalid USIM card state or pin code locked"
    if $i5 = "1" let $d="Valid USIM card state"
    if $i5 = "2" let $d="USIM is invalid in case of CS"
    if $i5 = "3" let $d="USIM is invalid in case of PS"
    if $i5 = "4" let $d="USIM is invalid in case of either CS or PS"
    if $i5 = "255" let $d="USIM card is not existent"
    print $x+"- SIM: "+$d+"\n"
    let $d="Unknown modem response ("+$i6+")"
    if $i6 = "0" let $d="No service"
    if $i6 = "1" let $d="GSM mode"
    if $i6 = "2" let $d="GPRS mode"
    if $i6 = "3" let $d="EDGE mode"
    if $i6 = "4" let $d="WCDMA mode"
    if $i6 = "5" let $d="HSDPA mode"
    if $i6 = "6" let $d="HSUPA mode"
    if $i6 = "7" let $d="HSDPA mode and HSUPA mode"
    if $i6 = "8" let $d="TD_SCDMA mode"
    if $i6 = "9" let $d="HSPA+ mode"
    if $i6 = "17" let $d="HSPA+(64QAM) mode"
    if $i6 = "18" let $d="HSPA+(MIMO) mode"
    print $x+"- sub mode: "+$d+"\n"
    # Invalid state for finish
    if $i2 = "1" goto abort
    if $i5 = "0" goto abort
    if $i5 = "3" goto finish
    if $i5 = "4" goto finish
    if $i5 = "255" goto finish
    # Invalid state for restart_modem
    if $i1 = "0" goto restart_modem
    if $i1 = "4" goto restart_modem
    if $i2 = "0" goto restart_modem
    if $i2 = "4" goto restart_modem
    if $i4 = "0" goto restart_modem
:end_sysinfo

# Getting received signal strength
    print $x+"Getting received signal strength\n"
    send "AT+CSQ^m"
    waitfor 5 "+CSQ: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting received signal strength\n" goto end_sigstr
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting received signal strength\n" goto end_sigstr
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^mOK^m" $i2
    if % != 0 goto comm_timeout
    if $i1 = "99" print $x+" signal strength: unknown\n" goto end_sigstr
    let s1=val($i1)
    let s2=(s1*2)-113 
    let s3=((s1*100000)/31000)
    print $x+"- signal strength: (",s1,"), ",s2," dBm, ",s3,"%\n"
    let s3=s3/5
    let $s3=$left("####################",s3)+$left("--------------------",20-s3)
    print $x+"- signal strength: ["+$s3+"]\n"
:end_sigstr

# Getting network registration status
    print $x+"Getting network registration status\n"
    let $i2=""
    send "AT+CGREG=2; +CGREG?^m"
    waitfor 2 "+CGREG: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting network registration status\n" goto end_cgreg
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting network registration status\n" goto end_cgreg
    if % = 3 print $x+"Command not supported\n" goto end_cgreg
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^m^mOK^m" $i4
    if % != 0 goto comm_timeout
    let $i2=$left($i4,1)
    if len($i4)>2 let $i3=$mid($i4,2,len($i4)-2)
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" let $d="Not registered. The MS is not searching the new operators to be registered"
    if $i2 = "1" let $d="Local network is registered"
    if $i2 = "2" let $d="Not registered. But the MS is searching the new operators to be registered"
    if $i2 = "3" let $d="Registration rejected"
    if $i2 = "4" let $d="Unknown reasons"
    if $i2 = "5" let $d="Roaming network is registered"
    print $x+"- status: "+$d+"\n"
    print $x+"- lac, ci: "+$i3+"\n"
    send "AT+CGREG=0^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5
:end_cgreg

# Disable CME error report
    send "AT+CMEE=0^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout

# Verify if the modem is connected
    print $x+"Verify if the modem is connected\n"
    send "AT\^DHCP?^m"
    waitfor 5 "\^DHCP:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 0 print $x+"Modem is already connected\n" goto do_disconnect
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"No connection detected\n"

# Disconnecting from current APN
goto end_disconnect
:do_disconnect
    print $x+"Disconnecting from current APN\n"
    send "AT\^NDISDUP=1,0^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while disconnecting from current APN\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while disconnecting from current APN\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Disconnected successfully\n"
    waitquiet 1 0.5
:end_disconnect    

# Setting mode
    if $m = "" goto end_mode_set
    print $x+"Setting mode "+$m+"\n"
    send $m+"^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while setting mode error\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while setting mode error\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Mode set successfully\n"
:end_mode_set

# Establishing connection
    print $x+"Try to establish connection via APN "+$a+"\n"
    send "AT\^NDISDUP=1,1,\""+$a+"\"^m" 
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while connecting\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while connecting\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Waiting for establish connection\n"
    let r3=0
:wait_for_connection    
    let r3=r3+1
    if r3>20 goto restart_modem
    send "AT\^DHCP?^m"
    waitfor 5 "\^DHCP:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 0 print $x+"Connection established\n" goto finish
    if % = 1 waitquiet 1 1 goto wait_for_connection
    if % = 2 waitquiet 1 1 goto wait_for_connection
    if % = 3 print $x+"Command not supported\n" goto abort

# In case of normal exit
:finish
    print $x+"Done.\n"
    exit 0

# In case of occurred an error
:abort
    print $x+"Done!\n"
    exit 1

# Error CME routine
:cme_error
    get 1 "^m" $e
    let $e="'"+$e+"'"
    return

# Restarting modem and start all
:restart_modem
    let r1=r1+1
    if r1>5 print $x+"Number of retries exhausted\n" goto abort
    print $x+"Restarting modem\n"
    waitquiet 2 2
    send "AT\^NDISDUP=1,0^m"
    waitquiet 2 1
    send "ATZ^m"
    waitquiet 2 1
    send "AT&F^m"
    waitquiet 2 1
    send "AT+CFUN=1^m"
    waitquiet 2 1
    goto start

# Timeout detected
:comm_timeout
    print $x+"Modem is not responding, timeout detected\n"
    goto restart_modem
# Done

Będę wdzięczny za uwagi. Pozdrawiam.

install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

2

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Jak zachowuje Ci się E173 na ndisie w sensie stabilności?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Posiadam 3 sztuki (firmware 11.126.85.00.209) pracujące nonstop (3*Aero2). Bez najmniejszych problemów działają 2, trzeci ma uszkodzone gniazdo, przez co ma słaby sygnał i jemu zdarza się rozłączanie.
Pomijając oczywiście rozłączanie wszystkich przez operatora, co 60 minut:(

install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

4

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Multiwan jest trochę ociężały, jeżeli chcesz się jeszcze pobawić sprawdź mwan2: https://forum.openwrt.org/viewtopic.php?id=33129 jak będzie się zachowywał.

Dobra robota tak BTW.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

5

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Dzięki, sprawdzę.

install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

6 (edytowany przez Rafciq 2014-01-21 23:12:32)

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

I jeszcze uzupełnienie opisu ustawiania trybu pracy modemu komendą AT^SYSCFG.

Składnia:
AT^SYSCFG=$mode,$acqOrder,$band,$roam,$srvDomain

$mode

  • 2 = Auto-Select

  • 13 = GSM only

  • 14 = WCDMA only

  • 16 = no Change

$acqOrder

  • 0 = Automatic

  • 1 = GSM prefered

  • 2 = WCDMA prefered

  • 3 = no Change

$band

  • 00080000 = GSM 850

  • 00000080 = GSM 1800 (DCS)

  • 00000100 = EGSM 900

  • 00000200 = PGSM 900

  • 00100000 = RGSM 900

  • 00200000 = GSM 1900 (PCS)

  • 00400000 = WCDMA 2100

  • 00800000 = WCDMA 1900

  • 04000000 = WCDMA 850

  • 2000000000000 = WCDMA 900

  • 4000000000000 = WCDMA 1700

  • 3FFFFFFF = all Bands

  • 40000000 = no Change

$roam

  • 0 = Not Supported

  • 1 = Supported

  • 2 = no Change

$srvDomain

  • 0 = Circuit-Switched only

  • 1 = Packet-Switched only

  • 2 = Circuit & Packet-Switched

  • 3 = Any

  • 4 = no Change

Przykłady:

  • AT^SYSCFG=2,0,3FFFFFFF,2,4 = Any

  • AT^SYSCFG=13,1,3FFFFFFF,2,4 = 2G only

  • AT^SYSCFG=14,2,3FFFFFFF,2,4 = 3G only

  • AT^SYSCFG=2,1,3FFFFFFF,2,4 = 2G preferred

  • AT^SYSCFG=2,2,3FFFFFFF,2,4 = 3G preferred

  • AT^SYSCFG=14,2,2000000000000,1,1 = Aero2 BDI (WCDMA 900)

install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

7

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Precyzując - dotyczy to modemów Huawei. Taki ZTE ma np. inne polecenia.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

8 (edytowany przez frutis 2012-03-26 19:54:47)

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Nowsze modemy Huawei konfiguruje się komendą AT^SYSCFGEX=$acqOrder,$band,$roam,$srvDomain,$lteband

$acqOrder

  • "00" = Automatic search

  • "01" = GSM

  • "02" = WCDMA

  • "03" = LTE

  • "04" = CDMA

  • "05" = TD-SCDMA

  • "06" = Wimax

  • "99" = No change

$lteband

  • 1 = LTE BC1

  • 40 = LTE BC7

  • 2000 = LTE BC13

  • 20000 = LTE BC17

  • 10000000000 = LTE BC40

  • 7FFFFFFFFFFFFFFF = all Bands

Pozostałe parametry jak przy SYSCFG.

Przykład:
AT^SYSCFGEX:"030201",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF = LTE, WCDMA, GSM any band

9

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

A to nowa wersja skryptu do podnoszenia połączenia 3G (plik /bin/3gtester.sh) wzbogacona o wykluczanie kolizji podczas równoległego uruchomienia gcom dla tego samego modemu w tym samym czasie.
Dzięki temu dodatkowi możliwe jest częste uruchamianie tego skryptu bez obawy, że w danym momencie z modemem będzie próbowała się komunikować więcej niż jedna instancja gcom.

#!/bin/sh
# Establishing 3G modem connection in dialup or NDIS mode
# Script version 1.01 Rafal Drzymala 2012
#
# Changelog
# 1.00 RD First stable code
# 1.01 RD Prevent from parallel comgt/gcom execution
#
SCR=$(basename $0)
ICMP="8.8.8.8"
COMGT_APP="gcom"
NDISUP="/etc/gcom/ndisup.gcom"
WANS=$(uci show network | awk -F[.=] '{if (($3=="proto" && $4=="3g") || ($3=="ifname" && match($4,"usb[0-9]"))) print $2}')
for WAN in $WANS; do
    NDIS="N"
    [ $(uci -q get network.$WAN.proto) != "3g" ] && NDIS="Y"
    DEV_IFNAME=$(uci -q get network.$WAN.ifname)
    DEV_APN=$(uci -q get network.$WAN.apn)
    DEV_PINCODE=$(uci -q get network.$WAN.pincode)
    DEV_MODE=$(uci -q get network.$WAN.mode)
    [ "$NDIS" == "Y" ] && DEV_COMM=$(uci -q get network.$WAN.comm)
    [ "$NDIS" == "N" ] && DEV_COMM=$(uci -q get network.$WAN.device)
    DEV_AUTO="1"
    [ "$NDIS" == "N" ] && DEV_AUTO=$(uci -q get network.$WAN.auto)
    logger -t $SCR "Checking $WAN for active connection"
    logger -t $SCR " interface=$DEV_IFNAME"
    logger -t $SCR " apn=$DEV_APN"
    logger -t $SCR " comm=$DEV_COMM"
    [ "$DEV_MODE" != "" ] && logger -t $SCR " mode=$DEV_MODE"
    if [ "$DEV_AUTO" == "1" ]; then
        if [ -e $DEV_COMM ]; then
            if ping -q -c 1 -W 5 -I $DEV_IFNAME $ICMP > /dev/null; then
                logger -t $SCR "ICMP successfully sent via $WAN"
            else
                logger -t $SCR "Restarting $WAN connection"
                if [ "$NDIS" == "N" ]; then
                    (ifdown $WAN; sleep 2; ifup $WAN) &
                else
                    COMGT_DEV="-d $DEV_COMM"
                    COMGT_SCR="-s $NDISUP"
                    if pgrep -l -f "$COMGT_APP $COMGT_DEV $COMGT_SCR"> /dev/null; then
                        logger -t $SCR "Connection $WAN is already restarted"
                    elif pgrep -l -f "$COMGT_APP $COMGT_DEV"> /dev/null; then
                        logger -t $SCR "Device $DEV_COMM used by another instance of $COMGT_APP"
                    elif ([ "$DEV_COMM" == "/dev/ttyUSB2" ] || [ "$DEV_COMM" == "/dev/noz2" ] || [ "$DEV_COMM" == "/dev/modem" ]) && pgrep -l -f  "$COMGT_APP" | grep -q -v "\-d"> /dev/null; then
                        logger -t $SCR "Device $DEV_COMM used by another instance of $COMGT_APP"
                    else
                        (ifdown $WAN; PINCODE=$DEV_PINCODE APN=$DEV_APN MODE=$DEV_MODE $COMGT_APP $COMGT_DEV $COMGT_SCR; sleep 2; ifup $WAN) &
                    fi
                fi
            fi
        else
            logger -t $SCR "Device $DEV_COMM for $WAN not exist"
        fi
    fi
done
# Done
install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

10 (edytowany przez jarek7714 2012-03-28 15:33:23)

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Od 1 marca nadajnik Polkomtela zrobił mi nie miłą niespodziankę związaną z całkowitym zanikiem HSPA na 2100MHz (złożyłem stosowne zgłoszenie reklamacyjne). No ale używając sieci w trybie HSDPA wytrzymałem 20dni (makabra to przeskok jak z HSDPA na EDGE), mam modem uniwersalny UMTS900/2100 E-367 ale na kompie (Macbooku) w żaden sposób nie mogłem połączyć się z iPlusem przez Aero2 (dostępna sieć macierzysta na 2100). Przeszukałem forum i za pomocą routera MR-3420 z Gargoyle for Cezary i gotowych podpowiedzi z eko zmusiłem modem do pracy wyłącznie na UMTS900- zasięg niemal full -59dB. Po tygodniu użytkowania (transfery nawet lepsze niż w Plusie ale stabilność 3-liga w porównaniu z 1,5roku użytkowania HSPA Polkomtela). Ale przed wczoraj net co chwila dostawał zadyszek i masowego gubienia pingów lub trzymania połączenia bez transferu (choć max. długość połączenia z siecią to 30-pare godzin z tym że router dawał sobie z tym radę odnawiając je). Zaglądając na forum zaciekawił mnie post @Rafciq z tym NDIS-em i multiwanami. Oczywiście zainstalowałem wszystko jak leci i jeszcze pewnie namieszałem w skryptach ale połączenie działało ok. doby-minus to obciążenie CPU na maxa.(aż trudno było się dostać do GUI i SSH).  Kolejne zmiany wymusił na mnie operator Aero2 nie przyjmując mojej karty do sieci (znów reklamacja, teraz szybko poszło i osobiście do mnie dziś zadzwonił konsultant przyjmujący wczorajsze zgłoszenie z zapyt. czy już jest ok!), z aktualizowałem soft, ustawiłem modem na UMTS900 i zapisałem cały ostatni skrypt @Rafciq (nie wiem czy to tak powinienem zrobić) i odpaliłem starter BDI, bez problemu nawiązał połączenie, transfer max., www otwierają się bardzo płynnie a teraz po zresetowaniu SIM testuje iPlusa (modem bez problemu nawiązał połączenie, transfery w dół ok 25% wyższe, strony www otwierają się w locie,CPU pracuje bez zadyszki, zobaczymy jak to będzie działać w dłuższej perspektywie) , a pyt. do @Rafciq lub innej osoby zorientowanej w temacie komend AT do E-367-jak w nim wyłączyć funkcję wirtualnego CD-ROM-u?

11

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

AT^SETPORT zobacz czy w nim działa.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

12

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Czy mogę wysłać w jakiś inny sposób (bez modyfikacji skryptu połączenia w routerze)? Jeżeli nie to sprawdzę to przy następnych modyfikacjach. smile i smile

13

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Zainstaluj sobie picocom, podłącz się do modemu i możesz działać.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

14

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Cezary napisał/a:

Zainstaluj sobie picocom, podłącz się do modemu i możesz działać.

Zainstalowałem w routerze i wysłałem komendę (przy aktywnym połączeniu z siecią) , niestety error. sad

15

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

No niestety, E367 nie mam, więc konkretnie Ci nie podam czy i co on obsługuje.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

16 (edytowany przez frutis 2012-03-28 20:25:40)

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Pokaż odpowiedź na komendy:

  • AT^GETPORTMODE?

  • AT^SETPORT?

  • AT^U2DIAG?

17

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Wprowadziłem modyfikacje do pliku /etc/gcom/ndisup.gcom, polegające na przeniesieniu wyżej sekcji pobierania siły sygnału, poprawiłem resetowanie modemu i zwiększyłem czas oczekiwania na ustanowienie połączenia z 20 na 30 sekund.

opengt
    let $x="ndisup:"+$basename($dev())+" "
    print $x+"Establishing 3G modem connection in NDIS mode\n"
    print $x+"Script for comgt version 1.01 Rafal Drzymala 2012\n"
#
# Changelog
#    1.00    RD    First stable code
#    1.01    RD    Move "Getting received signal strength" section
#                Reset command changed from ATZ to ATZ0
#                Changed wait time for establish connection from 20 to 30 secs
#
# Modem succesfuly tested
# - HUAWEI E173        11.126.85.00.209
# Modem tested, not supported 
# - HUAWEI E160G    11.608.02.02.55
# - HUAWEI E160        11.604.09.00.00
# - HUAWEI E220
#
    set com 115200n81
    set ignorecase on
    set comecho off
    set senddelay 0.02

    let $a=$env("APN")
    let $m=$env("MODE")
    let $p=$env("PINCODE")

    if  $a = "" print $x+"APN environment var not specified\n" goto finish    
    let r1=1

:start
# Initializing communication with modem
    if r1=1 print $x+"Try to communicate with modem\n"
    if r1>1 print $x+"Again try to communicate with modem (",r1,")\n"
    waitquiet 2 0.5
    send "ATQ0; E0^m"
    waitfor 1 "OK"
    if % = -1 goto comm_timeout
    send "AT+CMEE=2^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5
    send "AT\^CURC=0^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5

# Getting device information
    print $x+"Getting device information\n"
    waitquiet 1 0.2 
    send "AT+CGMI^m"
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    waitquiet 1 0.1
    send "AT+CGMM^m"
    get 1 "^mOK^m" $i2
    if % != 0 goto comm_timeout
    waitquiet 1 0.1 
    send "AT+CGMR^m"
    get 1 "^mOK^m" $i3
    if % != 0 goto comm_timeout
    waitquiet 1 0.1
    send "AT+CGSN^m"
    get 1 "^mOK^m" $i4
    if % != 0 goto comm_timeout
    if len($i1)>1 let $i1=$right($i1,len($i1)-1)
    if len($i2)>1 let $i2=$right($i2,len($i2)-1)
    if len($i3)>1 let $i3=$right($i3,len($i3)-1)
    if len($i4)>1 let $i4=$right($i4,len($i4)-1)
    print $x+"- modem: "+$toupper($i1)+" "+$toupper($i2)+"\n"
    print $x+"- firmware: "+$i3+"\n"
    print $x+"- IMEI: "+$i4+"\n"
:end_devinfo

# Getting received signal strength
    print $x+"Getting received signal strength\n"
    send "AT+CSQ^m"
    waitfor 5 "+CSQ: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting received signal strength\n" goto end_sigstr
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting received signal strength\n" goto end_sigstr
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^mOK^m" $i2
    if % != 0 goto comm_timeout
    if $i1 = "99" print $x+" signal strength: unknown\n" goto end_sigstr
    let s1=val($i1)
    let s2=(s1*2)-113 
    let s3=((s1*100000)/31000)
    print $x+"- signal strength: (",s1,"), ",s2," dBm, ",s3,"%\n"
    let s3=s3/5
    let $s3=$left("####################",s3)+$left("--------------------",20-s3)
    print $x+"- signal strength: ["+$s3+"]\n"
:end_sigstr

# Checking modem for NDIS support
    print $x+"Checking modem for NDIS support\n"
    send "AT\^DIALMODE?^m" 
    waitfor 5 "\^DIALMODE:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % > 0 print $x+"- This modem doesn't support NDIS mode\n" goto abort
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    let $i1=$left($i1,1)
    if $i1 = "1" goto ok_ndis_check
    if $i1 = "2" goto ok_ndis_check
    print $x+"- This modem doesn't support NDIS mode\n"
    goto abort
:ok_ndis_check
    print $x+"- NDIS mode is supported by this modem\n"
    waitquiet 1 1

# Checking for password input request
    print $x+"Checking for password input request\n"
    let u=0
    send "AT+CPIN?^m"
    waitfor 5 "+CPIN: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while checking for password input request\n" goto end_chkpin
    if % = 2 gosub cme_error print $x+"Error "+$e+" while checking for password input request\n" goto end_chkpin
    if % = 3 print $x+"Command not supported\n" goto end_chkpin
    get 1 "^mOK^m" $i1
    if % != 0 goto comm_timeout
    let $d="Unknown modem response ("+$i1+")"
    if $i1 = "READY" let $d="MT without password input request"
    if $i1 = "SIM PIN" let $d="UICC/SIM PIN password request"
    if $i1 = "SIM PUK" let $d="UICC/SIM PUK password request, to unblock the SIM PIN which was blocked for 3 verification failure"
    if $i1 = "SIM PIN2" let $d="PIN2 password request"
    if $i1 = "SIM PUK2" let $d="PUK2 password request, to unblock the SIM PIN2 which was blocked for 3 verification failure"
    if $i1 = "PH-SIM PIN" let $d="SIM lock (phone-to-SIM) is required"
    if $i1 = "PH-NET PIN" let $d="Network personnalisation is required"
    print $x+"- state: "+$d+"\n"
    if $i1 = "SIM PIN" goto do_pin_unlock
    if $i1 <> "READY" goto finish
:end_chkpin

# Unlock the PIN 
    goto end_pin_unlock
:do_pin_unlock
    print $x+"UICC/SIM unlocking by PIN\n"
    if $p = "" print $x+"PINCODE environment var not specified\n" goto abort
    send "AT+CPIN="+$p"^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while unlocking by PIN\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while unlocking by PIN\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto end_chkpin
    print $x+"UICC/SIM unlocked successfully\n"
    let r2=0
:wait_for_reg
    let r2=r2+1
    if r2>5 print $x+"Number of retries exhausted\n" goto abort
    print $x+"Waiting for network registration (",r2,")\n"
    send "AT+CGREG=0; +CGREG?^m"
    waitfor 2 "+CGREG: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting network registration status\n" goto end_pin_unlock
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting network registration status\n" goto end_pin_unlock
    if % = 3 print $x+"Command not supported\n" goto end_pin_unlock
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^m^mOK^m" $i2
    if % != 0 goto comm_timeout
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" waitquiet 1 5 goto wait_for_reg
    if $i2 = "1" goto end_pin_unlock
    if $i2 = "2" waitquiet 1 5 goto wait_for_reg
    if $i2 = "3" let $d="Registration rejected"
    if $i2 = "4" let $d="Unknown reasons"
    if $i2 = "5" goto end_pin_unlock
    print $x+"- error: "+$d+"\n"
    goto abort
:end_pin_unlock

# Getting system information
:do_sysinfo
    print $x+"Getting system information\n"
    send "AT\^SYSINFO^m"
    waitfor 5 "\^SYSINFO:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting system information\n" goto end_sysinfo
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting system information\n" goto end_sysinfo
    if % = 3 print $x+"Command not supported\n" goto end_sysinfo
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "," $i2
    if % != 0 goto comm_timeout
    get 1 "," $i3
    if % != 0 goto comm_timeout
    get 1 "," $i4
    if % != 0 goto comm_timeout
    get 1 "^mOK^m" $i5
    if % != 0 goto comm_timeout
    if len($i5)>3 let $i6=$right($i5,1)
    let $i5=$left($i5,1)
    let $d="Unknown modem response ("+$i1+")"
    if $i1 = "0" let $d="No service"
    if $i1 = "1" let $d="Restricted service"
    if $i1 = "2" let $d="Valid service"
    if $i1 = "3" let $d="Restricted regional service"
    if $i1 = "4" let $d="Power-saving and deep sleep state"
    print $x+"- service state: "+$d+"\n"
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" let $d="No service"
    if $i2 = "1" let $d="Only CS service"
    if $i2 = "2" let $d="Only PS service"
    if $i2 = "3" let $d="PS+CS service"
    if $i2 = "4" let $d="CS and PS not registered, searching"
    print $x+"- domain: "+$d+"\n"    
    let $d="Unknown modem response ("+$i3+")"
    if $i3 = "0" let $d="Non roaming state"
    if $i3 = "1" let $d="Roaming state"
    print $x+"- roaming: "+$d+"\n"
    let $d="Unknown modem response ("+$i4+")"
    if $i4 = "0" let $d="No service"
    if $i4 = "1" let $d="AMPS mode"
    if $i4 = "2" let $d="CDMA mode"
    if $i4 = "3" let $d="GSM/GPRS mode"
    if $i4 = "4" let $d="HDR mode"
    if $i4 = "5" let $d="WCDMA mode"
    if $i4 = "6" let $d="GPS mode"
    if $i4 = "7" let $d="GSM/WCDMA"
    if $i4 = "8" let $d="CDMA/HDR HYBRID"
    if $i4 = "15" let $d="TD-SCDMA mode"
    print $x+"- mode: "+$d+"\n"
    let $d="Unknown modem response ("+$i5+")"
    if $i5 = "0" let $d="Invalid USIM card state or pin code locked"
    if $i5 = "1" let $d="Valid USIM card state"
    if $i5 = "2" let $d="USIM is invalid in case of CS"
    if $i5 = "3" let $d="USIM is invalid in case of PS"
    if $i5 = "4" let $d="USIM is invalid in case of either CS or PS"
    if $i5 = "255" let $d="USIM card is not existent"
    print $x+"- SIM: "+$d+"\n"
    let $d="Unknown modem response ("+$i6+")"
    if $i6 = "0" let $d="No service"
    if $i6 = "1" let $d="GSM mode"
    if $i6 = "2" let $d="GPRS mode"
    if $i6 = "3" let $d="EDGE mode"
    if $i6 = "4" let $d="WCDMA mode"
    if $i6 = "5" let $d="HSDPA mode"
    if $i6 = "6" let $d="HSUPA mode"
    if $i6 = "7" let $d="HSDPA mode and HSUPA mode"
    if $i6 = "8" let $d="TD_SCDMA mode"
    if $i6 = "9" let $d="HSPA+ mode"
    if $i6 = "17" let $d="HSPA+(64QAM) mode"
    if $i6 = "18" let $d="HSPA+(MIMO) mode"
    print $x+"- sub mode: "+$d+"\n"
    # Invalid state do finish
    if $i2 = "1" goto abort
    if $i5 = "0" goto abort
    if $i5 = "3" goto finish
    if $i5 = "4" goto finish
    if $i5 = "255" goto finish
    # Invalid state do restart_modem
    if $i1 = "0" goto restart_modem
    if $i1 = "4" goto restart_modem
    if $i2 = "0" goto restart_modem
    if $i2 = "4" goto restart_modem
    if $i4 = "0" goto restart_modem
:end_sysinfo

# Getting network registration status
    print $x+"Getting network registration status\n"
    let $i2=""
    send "AT+CGREG=2; +CGREG?^m"
    waitfor 2 "+CGREG: ","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while getting network registration status\n" goto end_cgreg
    if % = 2 gosub cme_error print $x+"Error "+$e+" while getting network registration status\n" goto end_cgreg
    if % = 3 print $x+"Command not supported\n" goto end_cgreg
    get 1 "," $i1
    if % != 0 goto comm_timeout
    get 1 "^m^mOK^m" $i4
    if % != 0 goto comm_timeout
    let $i2=$left($i4,1)
    if len($i4)>2 let $i3=$mid($i4,2,len($i4)-2)
    let $d="Unknown modem response ("+$i2+")"
    if $i2 = "0" let $d="Not registered. The MS is not searching the new operators to be registered"
    if $i2 = "1" let $d="Local network is registered"
    if $i2 = "2" let $d="Not registered. But the MS is searching the new operators to be registered"
    if $i2 = "3" let $d="Registration rejected"
    if $i2 = "4" let $d="Unknown reasons"
    if $i2 = "5" let $d="Roaming network is registered"
    print $x+"- status: "+$d+"\n"
    print $x+"- lac, ci: "+$i3+"\n"
    send "AT+CGREG=0^m"
    waitfor 1 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 2 waitquiet 1 0.5
:end_cgreg

# Disable CME error report
    send "AT+CMEE=0^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout

# Verify if the modem is connected to APN
    print $x+"Verify if the modem is connected to APN\n"
    send "AT\^DHCP?^m"
    waitfor 5 "\^DHCP:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 0 print $x+"Modem is already connected\n" goto do_disconnect
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"No connection detected\n"

# Disconnecting from current APN
goto end_disconnect
:do_disconnect
    print $x+"Disconnecting from current APN\n"
    send "AT\^NDISDUP=1,0^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while disconnecting from current APN\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while disconnecting from current APN\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Disconnected successfully\n"
    waitquiet 1 0.5
:end_disconnect    

# Setting mode
    if $m = "" goto end_mode_set
    print $x+"Setting mode "+$m+"\n"
    send $m+"^m"
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while setting mode error\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while setting mode error\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Mode set successfully\n"
:end_mode_set

# Establishing connection
    print $x+"Try to establish connection via APN "+$a+"\n"
    send "AT\^NDISDUP=1,1,\""+$a+"\"^m" 
    waitfor 5 "OK","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 1 print $x+"Error while connecting\n" goto abort
    if % = 2 gosub cme_error print $x+"Error "+$e+" while connecting\n" goto abort
    if % = 3 print $x+"Command not supported\n" goto abort
    print $x+"Waiting for establish connection\n"
    let r3=0
:wait_for_connection    
    let r3=r3+1
    if r3>30 goto restart_modem
    send "AT\^DHCP?^m"
    waitfor 5 "\^DHCP:","ERROR","+CME ERROR: ","COMMAND NOT SUPPORT"
    if % = -1 goto comm_timeout
    if % = 0 print $x+"Connection established\n" goto finish
    if % = 1 waitquiet 1 1 goto wait_for_connection
    if % = 2 waitquiet 1 1 goto wait_for_connection
    if % = 3 print $x+"Command not supported\n" goto abort

# In case of normal exit
:finish
    print $x+"Done.\n"
    exit 0

# In case of occurred an error
:abort
    print $x+"Done!\n"
    exit 1

# Error CME routine
:cme_error
    get 1 "^m" $e
    let $e="'"+$e+"'"
    return

# Restarting modem and start all
:restart_modem
    let r1=r1+1
    if r1>5 print $x+"Number of restart retries was exhausted\n" goto abort
    print $x+"Restarting modem\n"
    waitquiet 2 2
    send "AT\^NDISDUP=1,0^m"
    waitquiet 2 1
    send "ATZ0^m"
    waitquiet 2 1
    send "AT&F^m"
    waitquiet 2 1
    send "AT+CFUN=1^m"
    waitquiet 2 1
    goto start

# Timeout detected
:comm_timeout
    print $x+"Modem is not responding, timeout detected\n"
    goto restart_modem
# Done
install.sh - Aktualizacja systemu, sysinfo.sh - Info.o systemie, openvpn-auth.sh - Login dla OpenVPN
Tu moje skrypty na GitHub

18

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

frutis napisał/a:

Pokaż odpowiedź na komendy:

  • AT^GETPORTMODE?

  • AT^SETPORT?

  • AT^U2DIAG?

Po wpisaniu : AT^GETPORTMODE
^getportmode:type:WCDMA:Qualcomm,MDM:0,NDIS:1,DIAG:2,PCUI:3,CDROM:4

OK
AT^CURC=0
OK
AT+CSQ
+CSQ: 27,99

OK
ATE1; +CGMI
huawei

OK
AT^SYSINFO
^SYSINFO:2,2,0,5,1,,9

OK
AT+COPS=3,2; +COPS?
+COPS: 0,2,"26001",2

OK
AT+CREG=2; +CREG?
+CREG: 2,0

OK
AT+CGREG=2; +CGREG?
+CGREG: 2,1, C353, 450CCA1

OK
AT+CGEQNEG=1
+CGEQNEG: 1,2,1024,6016,0,0,0,1500,"1E4","1E5",0,1000,2

OK
ATE1; +CGMM
E367

OK
Wpisując AT^SETPORT wyskakuje: ERROR  a po wpisaniu AT^U2DIAG : COMMAND NOT SUPPORT.

19

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

jarek7714 napisał/a:

Wpisując AT^SETPORT wyskakuje: ERROR  a po wpisaniu AT^U2DIAG : COMMAND NOT SUPPORT.

Wpisując te komendy dodajesz "?" na końcu?

20

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

frutis napisał/a:

Wpisując te komendy dodajesz "?" na końcu?

Wysyłałem bez ?

21

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

To dodaj to ?. Jest potrzebne.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

22

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Teraz dla odmiany pierwsza odpowiada błędem: AT^GETPORTMODE?
ERROR
AT^GETPORTMODE?
ERROR
AT^SETPORT?
A1,A2:1,2,3,7,A1,A2

OK
AT^U2DIAG?
COMMAND NOT SUPPORT

23

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Pokaż jeszcze wynik AT^SETPORT=? (z pytajnikiem).
To właśnie tą komendą konfiguruje się cdrom i porty.

24

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

frutis napisał/a:

Pokaż jeszcze wynik AT^SETPORT=? (z pytajnikiem).
To właśnie tą komendą konfiguruje się cdrom i porty.

Teraz sypnęło odpowiedziami: AT^SETPORT=?
1:MODEM
2:PCUI
3:DIAG
4:PCSC
5:GPS
6:GPS CONTROL
7:NDIS
A:BLUE TOOTH
B:FINGER PRINT
D:MMS
E:PC VOICE
A1:CDROM
A2:SD

25 (edytowany przez frutis 2012-03-29 19:46:08)

Odp: Modemy 3G w trybie NDIS/CDC i multiwan inaczej

Sprawdz: AT^SETPORT=A2;1,2,3,7,A2
Ale nie wiem czy zadziała. Nie testowałem smile
Po wysłaniu tej komendy wpisz: AT^GETPORTMODE i pokaż wynik.