#!/bin/bash

modprobe qcserial
modprobe qmi_wwan


function printit(){
	echo "SIM_slot_swith&read is $1"
}

echo "This program is setting or reading FWA-1012VC SIM slot  !"
case $1 in
  "1")
   echo "Swicth SIM slot as slot1"
   chat -V -s -t 1 '' 'at!uims=0 ' 'OK' '' > /dev/ttyUSB2 < /dev/ttyUSB2; echo
   chat -V -s -t 1 '' 'at!uims? ' 'OK' '' > /dev/ttyUSB2 < /dev/ttyUSB2; echo
   echo "suggest user reboot system to initial SIM_slot switch setting"
   exit 	
	;;
  "2")
   echo "Swicth SIM slot as slot2"
   chat -V -s -t 1 '' 'at!uims=1 ' 'OK' '' > /dev/ttyUSB2 < /dev/ttyUSB2; echo
   chat -V -s -t 1 '' 'at!uims? ' 'OK' '' > /dev/ttyUSB2 < /dev/ttyUSB2; echo
   echo "suggest user reboot system to initial SIM_slot switch setting"
   exit
	;;
  "3")
   echo "read SIM_slot setting (!UIMS: 0 mean slot1, !UIMS: 1 mean slot2 )"
   chat -V -s -t 1 '' 'at!uims? ' 'OK' '' > /dev/ttyUSB2 < /dev/ttyUSB2; echo
   exit
	;;
  *)
   echo "please add paramter {1|2|3} in command line"
   echo "example: read SIM_slot setting"
   echo "fwa1012_SIM_slot_swicth.sh 3"  
	;;
esac
