import json, base64, socket, wx # mknod pipe p # ./lorarx -f u8 -i pipe -v -N -b 7 -H -s 12 -r 1000000 -o 375000 -J 127.0.0.1:5100 -g -66 -M 433.775 -w 128 & # ./rtl_sdr -f 433.4m -g 35 -p 0 -s 1000000 -b 2000 - | tee pipe | ./lorarx -f u8 -i /dev/stdin -g -66 -v -N -b 8 -H -s 11 -w 32 -r 1000000 -o -225000 -J 127.0.0.1:5200 -M 433.175 AXUDP=("192.168.1.32",2300) #AXUDP=("192.168.1.24",12004) PORT=5100 IP=("0.0.0.0",PORT) metainfo=True longcalls=True sendjunk=True sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.bind(IP) while True: data, addr=sock.recvfrom(1500) # print(data) try: obj = json.loads(data.decode()) # print(obj) payload=base64.b64decode(obj["payload"]) #base64 coded frame print("payload=", payload) except: print("json decode error") else: if obj["crc"]!=1: print("no crc or crc error") elif obj["net"]!=0x12: print("wrong net-id") elif len(payload)>5: j=0 #seek begin of frame while (j<3) and ((payload[j]ord("9"))) and ((payload[j]ord("Z"))): j+=1 s="" for i in range(j,len(payload)): if (payload[i]!=13) & (payload[i]!=10): s+=chr(payload[i]) #remove junk and make string type head=s.find(":")+1 hasvia=s.find(",") in range(0,head) if metainfo and not hasvia and ((len(s)<=head) or (s[head]!=":")): # only if no digi path or bulletin/message/query try: v=obj["snr"] except: pass else: s+=" snr="+"{:.1f}".format(v)+"dB" try: v=obj["afc"] except: pass else: s+=" afc="+"{:.0f}".format(v)+"Hz" try: v=obj["preamb"] except: pass else: s+=" txd="+"{:.0f}".format(v)+"ms" try: v=obj["level"] except: pass else: s+=" lev="+"{:.0f}".format(v)+"dB" try: v=obj["eye"] except: pass else: s+=" q="+"{:.0f}".format(v)+"%" try: v=obj["bw"] except: pass else: s+=" bw="+"{:.0f}".format(v)+"Hz" try: v=obj["rxmhz"] except: pass else: s+=" rx="+"{:.3f}".format(v)+"MHz" try: v=obj["sf"] vi=obj["invers"] except: pass else: s+=" sf="+"{:.0f}".format(v) if vi: s+="(inv)" try: v=obj["cr"] except: pass else: s+=" cr="+"{:.0f}".format(v) try: v=obj["ver"] except: pass else: s+=" vers="+v try: print("frame:",s) except: print("print error") axmeta={"level": obj["level"], "quality": obj["eye"], "txdel": obj["preamb"], "afc": obj["afc"], "snr": obj["snr"]} if longcalls: axmeta["longcalls"]=2 if sendjunk or not hasvia: try: wx.sendax(sock, s, AXUDP, axmeta) except: print("axudp encode error") else: print("frame with via discarded") print()