Web Client to GNU Radio
As part of the “Remote SDR” project, it is necessary to send an audio stream and parameters from a web page to the remote SSB transmitter coded in GNU Radio.
Among the processing blocks present in GNURADIO-companion, there is the source UDP block for entering an audio data stream. To send this stream from a web client, you can use websockets. The program proposed below in python 3, retrieves the audio stream received from the web client according to the websocket protocol (port 8005) and passes this data to GNU Radio according to the UDP protocol (port 9005).
In addition this program each time an audio frame is received (packet of 512 bytes), changes the pin 26 of the GPIO of the Orange PI One Plus. This generates an alternating signal which, once rectified, will energize relays to power the transmitter. See details here.
#!/usr/bin/python3 # This is client.py file
import socket
import asyncio
import websockets
import os # To execute system command
# create a socket object
s_audio = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# get local machine name
host = '127.0.0.1'
port_audio_Web = 8005
port_audio_GR = 9005
numgpio=227 # GPIO 227 corresponds to pin 26 in Orange PI One PLUS H6
numgpio=str(numgpio)
# Préparation port commande relais
os.system("sudo echo "+numgpio+" > /sys/class/gpio/export") #activation
os.system("sudo echo out > /sys/class/gpio/gpio"+numgpio+"/direction") # Output
# connection to hostname on the port.
print ("Passerelle audio client Web vers TX")
# Receive bytes audio
async def audio(websocket_a, path):
etat=True
while True:
# on recupere les data du micro du client
donnee_audio = await websocket_a.recv()
s_audio.sendto(donnee_audio,(host,port_audio_GR))
# Oscillateur pour activer le relais alimentation via un condensateur et un redressement
# Oscillator on pin 26 as watchdog
etat=not etat #inversion à chaque trame recue
if etat:
os.system("echo 1 > /sys/class/gpio/gpio"+numgpio+"/value")
else:
os.system("echo 0 > /sys/class/gpio/gpio"+numgpio+"/value")
start_server_audio = websockets.serve(audio, "", port_audio_Web)
asyncio.get_event_loop().run_until_complete(start_server_audio)
asyncio.get_event_loop().run_forever()
For sending transmitter configuration commands, we use the xmlrpc protocol on the GNU Radio side (port 9004) and always websockets on the web client side (port 8004).
#!/usr/bin/python3 #
import asyncio
import websockets
import json
import xmlrpc.client
# create a socket object
# get local machine name
host = 'localhost'
port_para_Web = 8004
adr_local = "http://localhost:9004"
Sxml = xmlrpc.client.ServerProxy(adr_local)
print("Passerelle Parametres TX du client WEB")
async def consumer_handler(websocket_p, path):
async for message_recu in websocket_p:
F=json.loads(message_recu)
if "Fr_TX" in F :
print("Fr_TX ",F["Fr_TX"])
Sxml.set_Fr_TX(float(F["Fr_TX"]))
if "GRF_TX" in F :
print("GainRF TX ",F["GRF_TX"])
Sxml.set_GainRF_TX(float(F["GRF_TX"]))
if "GIF_TX" in F :
print("GainIF TX ",F["GIF_TX"])
Sxml.set_GainIF_TX(float(F["GIF_TX"]))
if "GBB_TX" in F :
print("GainBB TX ",F["GBB_TX"])
Sxml.set_GainBB_TX(float(F["GBB_TX"]))
if "LSB_USB" in F :
print("LSB USB ",F["LSB_USB"])
Sxml.set_LSB_USB(float(F["LSB_USB"]))
await websocket_p.send("OK")
start_server_para = websockets.serve(consumer_handler, "", port_para_Web)
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(start_server_para)
loop.run_forever()
except KeyboardInterrupt:
logging.info("Process Para interrupted")
finally:
loop.close()
logging.info("Arret Para service.")
For the receiver described here, we use the same protocols to pass the configuration parameters.
The source files are available on Github F1ATB / Remote-SDR.
Posts on Remote-SDR
- Remote SDR V5 -Raspberry 4B or Orange Pi Image Installation
- Remote SDR v5 – Manual Installation
- Remote SDR v5
- QO-100 Satellite Live
- RTTY
- Troubleshooting
- QO-100 Transceiver
- SSTV
- WSJT-X – FT8
- Omnirig – Remote SDR
- Communication Ports
- Tone generators
- Setting of GPIO outputs
- Band Scanning
- Gains and Dynamics
- Frequencies Management
- Launch of Remote SDR
- CPU Cooling
- Web GUI
- Microphone and signal processing authorization
- Configurations
- Characteristics
- Introduction to Remote SDR
- Remote SDR – Audio Channels
- CW with Remote SDR
- Rotary Knob and Morse Manipulator for Remote SDR
- VHF and UHF NBFM Transceiver
- Remote SDR v4
- Gpredict — Remote SDR
- Remote SDR V4 – Raspberry Pi 4B or Orange Pi Zero 2 image installation
- Remote SDR v4 – Manual Installation
- SA818 – RTL-SDR
- Remote SDR – Examples of realization
- Transmit over QO-100 satellite with a Smartphone
- Remote SDR V2 – Software Architecture
- Remote SDR V1- Purchase
- Remote SDR V1 – Man Machine Interface
- Remote SDR V1 – Signal Processing
- Web Client to GNU Radio
- GNU Radio to Web client
- Remote SSB Transmitter
- Remote SSB Receiver
- GPIO on Orange PI One Plus H6
- TCXO installation on HackRF
- Q0-100 Transceiver with 2 SDR – Remote SDR V1
Recent Comments