11-Aug-2010 12:20 PM - last edited on 11-Aug-2010 12:21 PM
I've made a small PowerShell Script which lets you switch GPS on/off. In contrast to the other solutions you don't need to install any software.
If you haven't enabled PowerShell to execute local scripts, open a PowerShell as Administrator and enter "Set-ExecutionPolicy RemoteSigned" (w/o quotes). Then make a new .txt file, name it agps.ps1 and copy/paste the following script to it (set in courier). If the GPS isn't using the standard ports on your machine, you have to change the ports in the script (COM5/COM4). Also you have to change the APN to your own (mine is internet.t-mobile). Then move agps.ps1 to System32 or some other folder that is in your environment path.
Param ($modus)
if (($modus -eq "on") -or ($modus -eq "off")) {
$port = new-Object System.IO.Ports.SerialPort
$port.PortName = "COM5"
$port.BaudRate = 9600
$port.Parity = "None"
$port.DataBits = 8
$port.StopBits = 1
$port.Open()
if ($modus -eq "on") {
$port.Write("AT_OGPSP = 7,2 `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPSCONT = 1, IP, internet.t-mobile `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPSLS = 1, http://supl.nokia.com `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPS = 2 `r `n")
}
else {
$port.Write("AT_OGPS = 0 `r `n")
}
$port.Close()
}
elseif ($modus -eq "log") {
$port = new-Object System.IO.Ports.SerialPort
$port.PortName = "COM4"
$port.BaudRate = 9600
$port.Parity = "None"
$port.DataBits = 8
$port.StopBits = 1
$port.Open()
$port.ReadExisting()
$port.Close()
}
else {
$error = "Invalid parameter. Valid parameters are `"on`", `"off`" and `"log`"."
Write-Error $error
return
}
Now you are ready to enable GPS with it. Open PowerShell and enter...
"agps on" to start A-GPS tracking
"agps off" to stop it
"agps log" to have a short look at whats going on on COM4, i.e. if it works.
11-Aug-2010 03:06 PM
It seems the port settings aren't necessary. Also forgot to mention that COM5 is the GPS Control Interface and COM4 the GPS Data Interface. Here is the shorter version of that script:
# COM5 = GPS Control Interface
# COM4 = GPS Data Interface
Param ($modus)
if (($modus -eq "on") -or ($modus -eq "off")) {
$port = new-Object System.IO.Ports.SerialPort COM5
$port.Open()
if ($modus -eq "on") {
$port.Write("AT_OGPSP = 7,2 `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPSCONT = 1, IP, internet.t-mobile `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPSLS = 1, http://supl.nokia.com `r `n")
Start-Sleep -m 500
$port.Write("AT_OGPS = 2 `r `n")
}
else {
$port.Write("AT_OGPS = 0 `r `n")
}
$port.Close()
}
elseif ($modus -eq "log") {
$port = new-Object System.IO.Ports.SerialPort COM4
$port.Open()
$port.ReadExisting()
$port.Close()
}
else {
$error = "Invalid parameter. Valid parameters are `"on`", `"off`" and `"log`"."
Write-Error $error
return
}
14-Aug-2010 01:10 AM
Thank you my friend you are really a genius ![]()