SkayaWiki

Carte3G

JeromePetazzoni :: DerniersChangements :: DerniersCommentaires? :: ParametresUtilisateur :: http://www.enix.org/ :: Vous êtes 216.73.216.79
Quelques commandes AT pour les cartes 3G (et probablement les téléphones aussi) :


ATE1 (switches on echo - if echo was off you won't see this)
AT+CREG=1 (you get notified when logging on to GSM)
AT+CGREG=1 (you get notified when attaching onto GPRS +CGREG:1 (interwiki) means attached)
AT+CGREG? (shows if you're attached to GPRS)
AT+CPIN="xxxx" (where xxxx is the PIN code ONLY when you need a PIN code) *
AT+CPIN? (You should get SIM READY)
AT+COPS? (should display your network)
AT+CGATT=1 (to attach)
AT+CSQ (This returns the signal strength, for GPRS you normally will need 15 or higher).
AT+CGDCONT=1,,"APN" (where APN is the APN required in your network-your network may not require an APN) *.
AT+CGDCONT? (In the response you should see a string in the response identical to your APN)
AT$NWRAT? (shows whether the card has been set to use GPRS/3G, GPRS or 3G only)
you get 3 values ; 0,2,6=GPRS/3G ; 1,2,6=GPRS only ; 2,2,3=3G only
AT$NWRAT=0,2 (use GPRS or 3G)
AT$NWRAT=1,2 (use only GPRS)
AT$NWRAT=2,2 (use only 3G)
Alternatively :
at_opsys=0,2 (GPRS only),
at_opsys=1,2 (UMTS only),
at_opsys=2,2 (prefers GPRS),
at_opsys=3,2 (prefers UMTS)


Le script /etc/chatscripts/vmcc-connect (remplacer xxxx par le code PIN) :
#!/usr/bin/python
import signal, sys, tty, os, time

def say(msg):
        print >>sys.stderr, "I say: ", repr(msg)
        os.write(1, msg+"\r\n")

def expect(msg, timeout):
        print >>sys.stderr, "I expect: ", repr(msg)
        signal.alarm(timeout)
        buffer = ""
        while msg not in buffer:
                buffer += os.read(0, 4096)
                print >>sys.stderr, "I got: ", repr(buffer)
        signal.alarm(0)
        #print >>sys.stderr, "I returned: ", repr(buffer)
        return buffer

say( "AT" )
expect("OK", 4)
say( "AT+CPIN?" )
answer = expect("+CPIN:", 1)
if "SIM PIN" in answer:
        say( "AT+CPIN=xxxx" )
        expect("OK", 1)
tries=60
while tries:
        say( "AT+CREG?" )
        answer = expect("+CREG:", 1)
        if "0,1" in answer: break
        time.sleep(1)
        tries-=1
assert tries
say( 'AT+CGDCONT=1,"IP","internetpro","",0,0' )
expect("OK", 1)
say(  "ATD*99***1#" )
expect("CONNECT", 10)


Le script /etc/chatscripts/vmcc-disconnect :
#!/bin/sh
#
# send break
/usr/sbin/chat -V -s -S    \
ABORT           "BUSY"          \
ABORT           "ERROR"         \
ABORT           "NO DIALTONE"   \
SAY             "\nSending break to the modem\n"        \
""              "\K"            \
""              "+++ATH"        \
SAY             "\nPDP context detached\n"

pccardctl eject
sleep 2
pccardctl insert


Le fichier de config /etc/ppp/peers/vmcc :
noauth
/dev/vmcc

# Serial port line speed
38400

nocrtscts
local

connect /etc/chatscripts/vmcc-connect
disconnect /etc/chatscripts/vmcc-disconnect

noipdefault
ipcp-accept-local
ipcp-accept-remote

novj
novjccomp

defaultroute
replacedefaultroute
usepeerdns

ipparam vmcc

persist
maxfail 0


À ajouter dans /etc/udev/rules.d/custom.rules (ou ailleurs) : NB il faut une version récente d'udev &co, sinon la commande de REMOVE n'est pas exécutée correctement
BUS=="pcmcia", SYSFS{prod_id2}=="Merlin UMTS Modem", SYMLINK+="vmcc", RUN+="/sbin/ifup vmcc", ENV{REMOVE_CMD}="/sbin/ifdown vmcc"


Dans le /etc/network/interfaces, j'ai tout simplement :
iface vmcc inet ppp
        pre-up sleep 4
        provider vmcc

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]