Skip to content

Instantly share code, notes, and snippets.

@ryuone
Forked from j3tm0t0/connect_air.sh
Created October 18, 2015 13:31
Show Gist options
  • Save ryuone/3bf137a8d348e710ada1 to your computer and use it in GitHub Desktop.
Save ryuone/3bf137a8d348e710ada1 to your computer and use it in GitHub Desktop.
SORACOM Air + FS01BU を、Raspberry Pi や Intel Edison (debianインストール&USB-OTGケーブルで接続) で使用するための接続スクリプト(要: wvdial / usb-modeswitch)
#!/bin/bash
lsusb
# USB modem device information
vendor=1c9e # OMEGA TECHNOLOGY
product=6801 # 3G(FS01BU)
tty=/dev/ttyUSB2
init_modem()
{
usb_modeswitch -t <<EOF
DefaultVendor= 0x$1
DefaultProduct= 0x$2
TargetVendor= 0x$1
TargetProduct= 0x$2
MessageEndpoint= not set
MessageContent="55534243123456780000000080000606f50402527000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00
EOF
modprobe usbserial vendor=0x$1 product=0x$2
modprobe -v option
echo "$1 $2" > /sys/bus/usb-serial/drivers/option1/new_id
}
dialup()
{
cat > /etc/wvdial.conf << EOF
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","$2"
Dial Attempts = 3
Stupid Mode = 1
Modem Type = Analog Modem
Dial Command = ATD
Stupid Mode = yes
Baud = 460800
New PPPD = yes
Modem = $1
ISDN = 0
APN = $2
Phone = *99***1#
Username = $3
Password = $4
Carrier Check = no
Auto DNS = 1
Check Def Route = 1
EOF
echo waiting for modem device
for i in {1..30}
do
[ -e $1 ] && break
echo -n .
sleep 1
done
[ $i = 30 ] && ( echo modem not found ; exit 1 )
while [ 1 ] ; do wvdial ; sleep 60 ; done
}
lsusb | grep $vendor:$product && \
init_modem $vendor $product && \
dialup $tty soracom.io sora sora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment