- Overview - Base Station Functionality
Helping forwarding the user tags' information to the server.Using 3G communicate to the server.
- Install Debian From USB CD-ROM
Do NOT install any addiction package (space is limited)
- Install required package
apt-get install libdevice-serialport-perl
apt-get install expect
apt-get install wvdial
apt-get install rsync
apt-get install beep
apt-get install ntpdate
- Change time zone
ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
- Edit wvdial.conf
vim /etc/wvdial.conf[Dialer Defaults]Init1 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0Modem Type = USB ModemIDSN = 0New PPPD = yesPhone = *99#Modem = /dev/ttyUSB1Username = defaultPassword = defaultAsk Password = 0Dial Command = ATDStupid Mode = yes
- Create udev rule for serial device
vim /etc/udev/rules.d/taroko.ruleskerne;="ttyUSB*", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6001", SYMLINK="TAROKO"
vim /etc/udev/rules.d/battery.rulesKERNEL=="ttyUSB*", SYSFS{idVendor}=="067b", SYSFS{idProduct}=="2303", SYMLINK="BATTERY"
- Edit rc.local
vim /etc/rc.local/usr/bin/wvdialconf
/usr/bin/wvdial &sh /root/BaseStation/run &sh /root/BatteryMonitor/run &sh /root/check.shexit 0
- Copy and extract Base Station file to /root
File structure/root|
|-- BaseStation
| |-- SerialForwarder.pl
| |-- run
| |-- send
| | `-- message
| `-- wildernessnet.sql
|-- BatteryMonitor
| |-- SerialBattery.pl
| `-- run
|-- check.sh
`-- cmdSender.sh
- Add crontab tasks
crontab -e# m h dom mon dow command
* * * * * sh /root/cmdSender.sh "/sbin/ifconfig" "/root/BaseStation/send/message/" "network.log"*/10 * * * * sh /root/cmdSender.sh "sh /root/check.sh" "/root/BaseStation/send/message/" "check.log"* * * * * rsync -av --compress --remove-source-files --timeout=10 --progress /root/BaseStation/send/ YuShanNet@140.112.42.162:/home/nas/YuShanNet/StarBox/data > /root/rsync.log
- Add ssh key to server
ssh-keygen at StarBox (no passphrase)
copy the content of id_rsa.pub to the authorized_keys at the server
- Programs description
SerialForwarder.pl Receive the message from user's tag and forward to PCSerialBattery.pl Communication with the battery
check.sh PC self-check procedurecmdSender.sh Dump command inforamtionAll data that needed to send to the server will be placed under BaseStation/send directory.Once the data is sent successfully, the data will be deleted.
No comments:
Post a Comment