Search Discussions:
Advanced Search...
Welcome to Nokia Support Discussions! Here you can share advice and tips with thousands of other Nokia users around the world in English. Many Nokia employees also follow and participate in the discussions, see our guidelines for more information. Everyone can search and read the discussions, but to post your own question or reply to others, simply login with your Nokia account. If this is your first time here, you can choose an alias to represent you. And if you don't have a Nokia account yet, please register.
Reply

Re: Enable your GPS with PowerShell!

Advisor
debilo_2
Posts: 22

Enable your GPS with PowerShell!

[ Edited ]

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.

 

 

Please use plain text.
Advisor
debilo_2
Posts: 22

Re: Enable your GPS with PowerShell!

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

}


Please use plain text.
Sage
alzaeem80
Posts: 372

Re: Enable your GPS with PowerShell!

Thank you my friend you are  really a genius :smileywink:

phones i have 2730c - C1
KUDOS ME IF YOU FIND MY ANSWERS HELP FULL
Please use plain text.