def spiaprspush(data, conn, prt=False): spidtable = {} # build the table of registration and flarmid spibuildtable(conn, spidtable, prt) for fix in data['spiderpos']: # for each position that we have on the dict # extract the information to store on the DDBB ident = fix['registration'] if len(ident) > 9: ident = ident[0:9] if ident == "HBEAT": # if it is the heartbeat just ignore it continue dte = fix['date'] hora = fix['time'] station = config.location_name latitude = float(fix['Lat']) # convert to float longitude = float(fix['Long']) altitude = int(fix['altitude']) speed = int(fix['speed']) course = int(fix['heading']) roclimb = 0 rot = 0 # store the GPS accuracy on the sensitivity sensitivity = fix['sensitivity'] gps = fix['GPS'] # if GPS is OK or not uniqueid = fix["UnitID"] # internal ID dist = fix['dist'] # dist not used extpos = fix['extpos'] # store 3D/2D on the extended position if ident in spidtable: # if ID is on the table substitude the spiderid by the flramid reg = spidtable[ident] else: reg = "SPI" + ident # if not ... just add the registration prefix # build the APRS message # conver the latitude to the format required by APRS lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc = "%03d" % int(course) sss = "%03d" % int(speed) aprsmsg = reg + ">OGSPID,qAS,SPIDER:/" + hora + 'h' + lat + "/" + lon + "'" + ccc + "/" + sss + "/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude * 3.28084) aprsmsg += " id" + uniqueid + " +" + sensitivity + "dB " + id + " " + extpos + "\n" config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() print("APRSMSG : ", aprsmsg) return (True)
def adsbaprspush(datafix, conn, prt=False): for fix in datafix['adsbpos']: # for each fix on the dict id = fix['ICAOID'] # extract the information dte = fix['date'] hora = fix['time'] station = config.location_name latitude = fix['Lat'] longitude = fix['Long'] altitude = fix['altitude'] speed = fix['speed'] course = fix['course'] roclimb = fix['roc'] rot = fix['rot'] sensitivity = 0 gps = fix['GPS'] uniqueid = fix["UnitID"] uniqueid = '25'+uniqueid[3:] dist = fix['dist'] extpos = fix['extpos'] flight = fix['flight'] # build the APRS message lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc = "%03d" % int(course) sss = "%03d" % int(speed) if roclimb == None: roclimb = 0 aprsmsg = id+">OGADSB,qAS,"+config.ADSBname+":/" + \ hora+'h'+lat+"\\"+lon+"^"+ccc+"/"+sss+"/" if altitude != None and altitude > 0: aprsmsg += "A=%06d" % int(altitude) aprsmsg += " id"+uniqueid+" %+04dfpm " % (int(roclimb))+" "+str(rot)+"rot fn"+flight+" " regmodel = getadsbreg(id[3:9]) if regmodel: reg =regmodel['Reg'] model=regmodel['Model'] aprsmsg += "reg"+reg+" model"+model+" \n" else: aprsmsg += " \n" print("APRSMSG: ", aprsmsg) rtn = config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() if rtn == 0: print("Error writing msg:", aprsmsg) return (True)
def spiaprspush(data, conn, prt=False): spidtable={} spibuildtable(conn, spidtable, prt) # build the table of registration and flarmid for fix in data['spiderpos']: # for each position that we have on the dict id=fix['registration'] # extract the information to store on the DDBB if len(id) > 9: id=id[0:9] if id == "HBEAT": # if it is the heartbeat just ignore it continue dte=fix['date'] hora=fix['time'] station=config.location_name latitude=float(fix['Lat'] ) # convert to float longitude=float(fix['Long'] ) altitude=int(fix['altitude'] ) speed=int(fix['speed'] ) course=int(fix['heading'] ) roclimb=0 rot=0 sensitivity=fix['sensitivity'] # store the GPS accuracy on the sensitivity gps=fix['GPS'] # if GPS is OK or not uniqueid=fix["UnitID"] # internal ID dist=fix['dist'] # dist not used extpos=fix['extpos'] # store 3D/2D on the extended position if id in spidtable: # if ID is on the table substitude the spiderid by the flramid reg=spidtable[id] else: reg="SPI"+id # if not ... just add the registration prefix # build the APRS message lat=deg2dmslat(abs(latitude)) # conver the latitude to the format required by APRS if latitude > 0: lat += 'N' else: lat += 'S' lon=deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc="%03d"%int(course) sss="%03d"%int(speed) aprsmsg=reg+">OGSPID,qAS,SPIDER:/"+hora+'h'+lat+"/"+lon+"'"+ccc+"/"+sss+"/" if altitude > 0: aprsmsg += "A=%06d"%int(altitude*3.28084) aprsmsg += " id"+uniqueid+" +"+sensitivity+"dB "+id+" "+extpos+ "\n" rtn = config.SOCK_FILE.write(aprsmsg) print "APRSMSG : ", aprsmsg return(True)
def skylaprspush(datafix, conn, prt=False): for fix in datafix['skylpos']: # for each fix on the dict idpn = fix['pilotname'] # extract the information dte = fix['date'] hora = fix['time'] station = config.location_name latitude = fix['Lat'] longitude = fix['Long'] altitude = fix['altitude'] speed = fix['speed'] course = fix['course'] roclimb = fix['roc'] rot = 0 sensitivity = 0 gps = fix['GPS'] uniqueid = str(fix["UnitID"]) dist = fix['dist'] extpos = fix['extpos'] gliderreg = fix['gliderreg'] flarmid = getflarmid(conn, gliderreg) # build the APRS message lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc = "%03d" % int(course) sss = "%03d" % int(speed) aprsmsg = flarmid+">OGSKYL,qAS,SKYLINES:/" + \ hora+'h'+lat+"/"+lon+"'"+ccc+"/"+sss+"/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude * 3.28084) aprsmsg += " id" + uniqueid + " %+04dfpm " % (int(roclimb)) + " \n" print("APRSMSG: ", aprsmsg) config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() return (True)
def lt24aprspush(datafix, prt=False): # push the data to the OGN APRS for fix in datafix['lt24pos']: # for each fix on the dict id = fix['registration'][0:16] # extract the information if len(id) > 9: id = id[0:9] dte = fix['date'] hora = fix['time'] station = config.location_name latitude = fix['Lat'] longitude = fix['Long'] altitude = fix['altitude'] speed = fix['speed'] course = fix['course'] roc = fix['roc'] rot = 0 sensitivity = 0 gps = fix['GPS'] uniqueid = str(fix["UnitID"]) dist = fix['dist'] extpos = fix['extpos'] # build the APRS message lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc = "%03d" % int(course) sss = "%03d" % int(speed) aprsmsg = id+">OGLT24,qAS,LT24:/"+hora+'h'+lat+"/"+lon+"'"+ccc+"/"+sss+"/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude*3.28084) aprsmsg += " id"+uniqueid+" %+04dfpm " % (int(roc))+gps+" \n" print("APRSMSG : ", aprsmsg) config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() return True
def inreachaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['inreachpos']: # for each fix on the dict id = fix['registration'] # extract the information if len(id) > 9: id = id[0:9] dte = fix['date'] # date hora = fix['time'] # time latitude = float(fix['Lat']) longitude = float(fix['Long']) altitude = float(fix['altitude']) * 3.28084 speed = fix['speed'] course = fix['course'] roclimb = 0 # rate of climb rot = 0 # rate of turn sensitivity = 0 gps = fix['GPS'] # model ID gps = gps[0:6] # only six chars uniqueid = str(fix["UnitID"]) # identifier of the owner dist = fix['dist'] # distance to BASE extpos = fix['extpos'] # GPS valid fix pilotname = fix['PilotName'] # Pilot name # build the APRS message # convert the latitude to the format required by APRS lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' # convert longitude to the DDMM.MM format lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' aprsmsg = id + ">OGINRE,qAS,INREACH:/" + hora + 'h' + lat + "/" + lon + "'000/000/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude) aprsmsg += " id" + uniqueid + " " + gps + " " + extpos + " " + pilotname + " \n" print("APRSMSG : ", aprsmsg) config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() return (True)
def spotaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['spotpos']: # for each fix on the dict id = fix['registration'] # extract the information if len(id) > 9: id = id[0:9] dte = fix['date'] hora = fix['time'] latitude = fix['Lat'] longitude = fix['Long'] altitude = fix['altitude'] speed = 0 course = 0 roclimb = 0 rot = 0 sensitivity = 0 gps = fix['GPS'] # model ID uniqueid = str(fix["UnitID"]) # identifier of the owner dist = fix['dist'] # distance to BASE extpos = fix['extpos'] # battery state # build the APRS message # convert the latitude to the format required by APRS lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' # convert longitude to the DDMM.MM format lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' aprsmsg = id + ">OGSPOT,qAS,SPOT:/" + hora + 'h' + lat + "/" + lon + "'000/000/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude * 3.28084) else: aprsmsg += "A=000000" aprsmsg += " id" + uniqueid + " " + gps + " " + extpos + " \n" config.SOCK_FILE.write(aprsmsg) config.SOCK_FILE.flush() print("APRSMSG : ", aprsmsg) return (True)
def lt24aprspush(datafix, prt=False): # push the data to the OGN APRS for fix in datafix['lt24pos']: # for each fix on the dict id=fix['registration'][0:16] # extract the information if len(id) > 9: id=id[0:9] dte=fix['date'] hora=fix['time'] station=config.location_name latitude=fix['Lat'] longitude=fix['Long'] altitude=fix['altitude'] speed=fix['speed'] course=fix['course'] roc=fix['roc'] rot=0 sensitivity=0 gps=fix['GPS'] uniqueid=str(fix["UnitID"]) dist=fix['dist'] extpos=fix['extpos'] # build the APRS message lat=deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon=deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc="%03d"%int(course) sss="%03d"%int(speed) aprsmsg=id+">OGLT24,qAS,LT24:/"+hora+'h'+lat+"/"+lon+"'"+ccc+"/"+sss+"/" if altitude > 0: aprsmsg += "A=%06d"%int(altitude*3.28084) aprsmsg += " id"+uniqueid+" %+04dfpm "%(int(roc))+gps+" \n" print "APRSMSG : ", aprsmsg rtn = config.SOCK_FILE.write(aprsmsg) return True
def inreachaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['inreachpos']: # for each fix on the dict id=fix['registration'] # extract the information if len(id) > 9: id=id[0:9] dte=fix['date'] # date hora=fix['time'] latitude= float(fix['Lat']) longitude=float(fix['Long']) altitude= float(fix['altitude']) * 3.28084 speed=fix['speed'] course=fix['course'] roclimb=0 rot=0 sensitivity=0 gps=fix['GPS'] # model ID gps=gps[0:6] # only six chars uniqueid=str(fix["UnitID"]) # identifier of the owner dist=fix['dist'] # distance to BASE extpos=fix['extpos'] # GPS valid fix pilotname=fix['PilotName'] # Pilot name # build the APRS message lat=deg2dmslat(abs(latitude)) # convert the latitude to the format required by APRS if latitude > 0: lat += 'N' else: lat += 'S' lon=deg2dmslon(abs(longitude)) # convert longitude to the DDMM.MM format if longitude > 0: lon += 'E' else: lon += 'W' aprsmsg=id+">OGINRE,qAS,INREACH:/"+hora+'h'+lat+"/"+lon+"'000/000/" if altitude > 0: aprsmsg += "A=%06d"%int(altitude) aprsmsg += " id"+uniqueid+" "+gps+" "+extpos+" "+pilotname+" \n" print "APRSMSG : ", aprsmsg rtn = config.SOCK_FILE.write(aprsmsg) return(True)
def spotaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['spotpos']: # for each fix on the dict id=fix['registration'] # extract the information if len(id) > 9: id=id[0:9] dte=fix['date'] hora=fix['time'] latitude=fix['Lat'] longitude=fix['Long'] altitude=fix['altitude'] speed=0 course=0 roclimb=0 rot=0 sensitivity=0 gps=fix['GPS'] # model ID uniqueid=str(fix["UnitID"]) # identifier of the owner dist=fix['dist'] # distance to BASE extpos=fix['extpos'] # battery state # build the APRS message lat=deg2dmslat(abs(latitude)) # convert the latitude to the format required by APRS if latitude > 0: lat += 'N' else: lat += 'S' lon=deg2dmslon(abs(longitude)) # convert longitude to the DDMM.MM format if longitude > 0: lon += 'E' else: lon += 'W' aprsmsg=id+">OGSPOT,qAS,SPOT:/"+hora+'h'+lat+"/"+lon+"'000/000/" if altitude > 0: aprsmsg += "A=%06d"%int(altitude*3.28084) aprsmsg += " id"+uniqueid+" "+gps+" "+extpos+" \n" rtn = config.SOCK_FILE.write(aprsmsg) print "APRSMSG : ", aprsmsg return(True)
def captaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['captpos']: # for each fix on the dict id = fix['registration'] # extract the information if len(id) > 9: id = id[0:9] dte = fix['date'] hora = fix['time'] station = config.location_name latitude = fix['Lat'] longitude = fix['Long'] altitude = fix['altitude'] uniqueid = fix['device'] speed = fix['speed'] # build the APRS message lat = deg2dmslat(abs( latitude)) # conver the latitude to the format required by APRS if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' if speed != None: sss = "%03d" % speed else: sss = "000" aprsmsg = id + ">OGCAPT,qAS,CAPTURS:/" + hora + 'h' + lat + "/" + lon + "'000/" + sss + "/" if altitude > 0: aprsmsg += "A=%06d" % int(altitude * 3.28084) aprsmsg += " id" + uniqueid + " \n" rtn = config.SOCK_FILE.write(aprsmsg) print "APRSMSG : ", aprsmsg return (True)
def captaprspush(datafix, prt=False): # push the data into the OGN APRS for fix in datafix['captpos']: # for each fix on the dict id=fix['registration'] # extract the information if len(id) > 9: id=id[0:9] dte=fix['date'] hora=fix['time'] station=config.location_name latitude=fix['Lat'] longitude=fix['Long'] altitude=fix['altitude'] uniqueid=fix['device'] speed=fix['speed'] # build the APRS message lat=deg2dmslat(abs(latitude)) # conver the latitude to the format required by APRS if latitude > 0: lat += 'N' else: lat += 'S' lon=deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' if speed != None: sss="%03d"%speed else: sss="000" aprsmsg=id+">OGCAPT,qAS,CAPTURS:/"+hora+'h'+lat+"/"+lon+"'000/"+sss+"/" if altitude > 0: aprsmsg += "A=%06d"%int(altitude*3.28084) aprsmsg += " id"+uniqueid+" \n" rtn = config.SOCK_FILE.write(aprsmsg) print "APRSMSG : ", aprsmsg return(True)
def genaprsmsg(entry): # format the reconstructed APRS message decode = entry["DECODE"] ID = entry["ID"] station = entry["station"] hora = entry["hora"] resto = entry["rest"] latitude = decode["Lat"] longitude = decode["Lon"] altitude = decode["Alt"] course = decode["Heading"] speed = decode["Speed"] roclimb = decode["RoC"] * 3.28084 RoT = decode["RoT"] DOP = decode["DOP"] resto = resto.lstrip(' ') # swap 2nd and 3rd words in rest of message sp1 = resto.find(' ') # find the end of first word if sp1 != -1: # if not dound sp2 = resto[sp1 + 1:].find(' ') + 1 + sp1 db = resto[0:sp1] # xx.xdB khz = resto[sp1 + 1:sp2] # xx.xkHz e = resto[sp2 + 1:] # xe rt = ' ' + db + ' ' + e + ' ' + khz # the sequence now else: rt = ' ' + resto + ' 0e ' # just a a white separator # build the APRS message lat = deg2dmslat(abs(latitude)) if latitude > 0: lat += 'N' else: lat += 'S' lon = deg2dmslon(abs(longitude)) if longitude > 0: lon += 'E' else: lon += 'W' ccc = "%03d" % int(course) sss = "%03d" % int(speed) daotxt = "!W" + dao(latitude) + dao( longitude) + "!" # the extended precision DOP = 10 + DOP HorPrec = int((DOP * 2 + 5) / 10) if (HorPrec > 63): HorPrec = 63 VerPrec = int((DOP * 3 + 5) / 10) if (VerPrec > 63): VerPrec = 63 gpstxt = "gps" + str(HorPrec) + "x" + str(VerPrec) aprsmsg = ID + ">OGNTRK,OGNDELAY*," + station + ":/" + hora + lat + "/" + lon + "'" + ccc + "/" + sss + "/" aprsmsg = ID + ">OGNTRK," + station + ",OGNDELAY*:/" + hora + lat + "/" + lon + "'" + ccc + "/" + sss + "/" if altitude > 0: altitude = int(altitude * 3.28084) # convert to feet aprsmsg += "A=%06d" % altitude aprsmsg += " " + daotxt + " id06" + ID[3:] + " %+04dfpm " % ( int(roclimb)) + "%+04.1frot" % (float(RoT)) + rt + " " + gpstxt return (aprsmsg)