#!/bin/sh
RADIO="gsm"
MCC="460"
MNC="0"
LAC=14556
CID=36526
lac_max=-1
lac_min=-1
cid_max=-1
cid_min=-1
usage()
{
/bin/echo -ne "Usage:\n $0 --mcc={MCC} --mnc={MNC} --lac={LAC} --cid={CELLID} --radio=<gsm|wcdma>\n"
/bin/echo -ne " --flac={FROM} --tlac={TO} --fcid={FROM} --tcid={TO}\n\n"
/bin/echo -e "Options:"
/bin/echo -e " --flac: scan the LAC and start from the specified number"
/bin/echo -e " --tlac: scan the LAC and end with the specified number"
/bin/echo -e " --fcid: scan the CID and start from the specified number"
/bin/echo -e " --tcid: scan the CID and end with the specified number"
}
scanstation()
{
/bin/echo "Station: MCC=$MCC, MNC=$MNC, LAC=$LAC, CELLID=$CID, RADIO=$RADIO"
options="
{
\"version\": \"1.1.0\" ,
\"host\": \"maps.google.com\",
\"access_token\": \"2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe\",
\"home_mobile_country_code\": $MCC ,
\"home_mobile_network_code\": $MNC ,
\"address_language\": \"zh_CN\",
\"radio_type\": \"$RADIO\",
\"request_address\": true ,
\"cell_towers\":[
{
\"cell_id\":$CID,
\"location_area_code\": $LAC,
\"mobile_country_code\": $MCC,
\"mobile_network_code\": $MNC,
\"timing_advance\":5555
}
]
}"
ADDRESS=`curl -s -d "$options" http://www.google.com/loc/json`
/bin/echo -e "Data :\n$ADDRESS \n"
}
TEMP=`getopt -o "" --long help,radio:,mcc:,mnc:,lac:,cid:,flac:,tlac:,fcid:,tcid: -- "$@"`
if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
--radio) RADIO=$2; shift 2 ;;
--mcc) MCC=$2; shift 2 ;;
--mnc) MNC=$2; shift 2 ;;
--lac) LAC=$2; shift 2 ;;
--cid) CID=$2; shift 2 ;;
--flac) lac_min=$2; shift 2 ;;
--tlac) lac_max=$2; shift 2 ;;
--fcid) cid_min=$2; shift 2 ;;
--tcid) cid_max=$2; shift 2 ;;
--help) usage; exit 0 ;;
--) shift ; break ;;
*) echo "internal error" ; exit 1 ;;
esac
done
if [ $lac_min -eq -1 ] || [ $lac_max -eq -1 ]; then
lac_min=$LAC
lac_max=$LAC
fi
if [ $cid_min -eq -1 ] || [ $cid_max -eq -1 ]; then
cid_min=$CID
cid_max=$CID
fi
LAC=$lac_min
while [ $LAC -le $lac_max ]; do
CID=$cid_min
while [ $CID -le $cid_max ]; do
scanstation
CID=`expr $CID + 1`
done
LAC=`expr $LAC + 1`
done