We have moved to a new Sailfish OS Forum. Please start new discussions there.
1 | initial version | posted 2014-02-06 03:38:10 +0200 |
I've been hacking some code together to retrieve geodata from a given GSM cell. In case anybody is looking for similar stuff, here you go:
#!/bin/sh
# Retrieve cell ID code via DBUS
# Idea from http://talk.maemo.org/showthread.php?t=72419
KEY="dxxxxxxx6-d7cb-42e2-a1f3-253axxxxxx9c"
TMP=`/bin/mktemp`
/bin/dbus-send --system --print-reply=literal --type=method_call --dest=org.ofono /ril_0 org.ofono.NetworkRegistration.GetProperties > $TMP
for INFO in LocationAreaCode CellId MobileCountryCode MobileNetworkCode; do
eval $INFO=`/bin/grep $INFO $TMP | /bin/awk -F ' [^0-9]+' '{print $2 $3}' | /bin/awk '{print $NF}'`
done
echo "Cell ID codes"
echo " MCC: $MobileCountryCode"
echo " MNC: $MobileNetworkCode"
echo " LAC: $LocationAreaCode"
echo " CELL:$CellId"
URL="http://www.opencellid.org/cell/get?key=$KEY&mnc=$MobileNetworkCode&mcc=$MobileCountryCode&lac=$LocationAreaCode&cellid=$CellId"
/usr/bin/curl -o $TMP $URL 1>/dev/null 2>&1
echo ""
if /bin/grep fail $TMP >/dev/null; then
echo "Coordinates could not be retrieved."
else
LAT=`/bin/grep lat $TMP | /bin/awk -F '"' '{print $2}'`
LON=`/bin/grep lon $TMP | /bin/awk -F '"' '{print $4}'`
echo "Geo coordinates"
echo " LAT: $LAT"
echo " LON: $LON"
fi
/bin/rm -f $TMP
2 | No.2 Revision |
I've been hacking some code together to retrieve geodata from a given GSM cell. In case anybody is looking for similar stuff, here you go:
#!/bin/sh
# Retrieve cell ID code via DBUS
# Idea from http://talk.maemo.org/showthread.php?t=72419
KEY="dxxxxxxx6-d7cb-42e2-a1f3-253axxxxxx9c"
TMP=`/bin/mktemp`
/bin/dbus-send --system --print-reply=literal --type=method_call --dest=org.ofono /ril_0 org.ofono.NetworkRegistration.GetProperties > $TMP
for INFO in LocationAreaCode CellId MobileCountryCode MobileNetworkCode; do
eval $INFO=`/bin/grep $INFO $TMP | /bin/awk -F ' [^0-9]+' '{print $2 $3}' | /bin/awk '{print $NF}'`
done
echo "Cell ID codes"
echo " MCC: $MobileCountryCode"
echo " MNC: $MobileNetworkCode"
echo " LAC: $LocationAreaCode"
echo " CELL:$CellId"
URL="http://www.opencellid.org/cell/get?key=$KEY&mnc=$MobileNetworkCode&mcc=$MobileCountryCode&lac=$LocationAreaCode&cellid=$CellId"
/usr/bin/curl -o $TMP $URL 1>/dev/null 2>&1
echo ""
if /bin/grep fail $TMP >/dev/null; then
echo "Coordinates could not be retrieved."
else
LAT=`/bin/grep lat $TMP | /bin/awk -F '"' '{print $2}'`
LON=`/bin/grep lon $TMP | /bin/awk -F '"' '{print $4}'`
echo "Geo coordinates"
echo " LAT: $LAT"
echo " LON: $LON"
fi
/bin/rm -f $TMP
3 | retagged |
I've been hacking some code together to retrieve geodata from a given GSM cell. In case anybody is looking for similar stuff, here you go:
#!/bin/sh
# Retrieve cell ID code via DBUS
# Idea from http://talk.maemo.org/showthread.php?t=72419
KEY="dxxxxxxx6-d7cb-42e2-a1f3-253axxxxxx9c"
TMP=`/bin/mktemp`
/bin/dbus-send --system --print-reply=literal --type=method_call --dest=org.ofono /ril_0 org.ofono.NetworkRegistration.GetProperties > $TMP
for INFO in LocationAreaCode CellId MobileCountryCode MobileNetworkCode; do
eval $INFO=`/bin/grep $INFO $TMP | /bin/awk -F ' [^0-9]+' '{print $2 $3}' | /bin/awk '{print $NF}'`
done
echo "Cell ID codes"
echo " MCC: $MobileCountryCode"
echo " MNC: $MobileNetworkCode"
echo " LAC: $LocationAreaCode"
echo " CELL:$CellId"
URL="http://www.opencellid.org/cell/get?key=$KEY&mnc=$MobileNetworkCode&mcc=$MobileCountryCode&lac=$LocationAreaCode&cellid=$CellId"
/usr/bin/curl -o $TMP $URL 1>/dev/null 2>&1
echo ""
if /bin/grep fail $TMP >/dev/null; then
echo "Coordinates could not be retrieved."
else
LAT=`/bin/grep lat $TMP | /bin/awk -F '"' '{print $2}'`
LON=`/bin/grep lon $TMP | /bin/awk -F '"' '{print $4}'`
echo "Geo coordinates"
echo " LAT: $LAT"
echo " LON: $LON"
fi
/bin/rm -f $TMP