Skip to content

Instantly share code, notes, and snippets.

@mr-sour
Created October 30, 2023 01:48
Show Gist options
  • Save mr-sour/d08cbc98521c8ae04f9c4ada2d12dce7 to your computer and use it in GitHub Desktop.
Save mr-sour/d08cbc98521c8ae04f9c4ada2d12dce7 to your computer and use it in GitHub Desktop.
UBLOX agps betaflight cli
import requests
import serial
#Edit me!!
token = "TOKEN" #Token getted from u-blox
comPort = "/dev/tty.usbmodem" #GPS Com port
print ("Connecting to u-blox")
r = requests.get("http://online-live1.services.u-blox.com/GetOnlineData.ashx?token=" + token + ";gnss=gps;datatype=eph,alm,aux,pos;filteronpos;format=aid", stream=True)
print ("Downloading A-GPS data")
ser = serial.Serial(comPort, 9600)
print("Waiting to GPS be free")
drainer = True
while drainer:
drainer = ser.inWaiting()
ser.read(drainer)
print("Writing AGPS data")
#print(r.content)
ser.write(r.content)
print ("Done")
buffer = True
message = ""
try:
while buffer:
buffer = ser.read()
if buffer.decode() == "$":
if message.startswith("$GPGGA"):
print (message.strip())
message = ""
message = message + buffer.decode()
except KeyboardInterrupt:
ser.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment