1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-24 00:12:25 -04:00

REST API: implemented keys renaming in example scripts

This commit is contained in:
f4exb 2019-05-07 15:35:11 +02:00
parent 6771c6de5b
commit f0ff5473fb
12 changed files with 72 additions and 72 deletions

View File

@ -36,7 +36,7 @@ def main():
global base_url global base_url
base_url = "http://%s/sdrangel" % options.address base_url = "http://%s/sdrangel" % options.address
device_url = base_url + ("/deviceset/%d/channel" % options.device_index) device_url = base_url + ("/deviceset/%d/channel" % options.device_index)
r = requests.post(url=device_url, json={"tx": 0, "channelType": options.channel_id}) r = requests.post(url=device_url, json={"direction": 0, "channelType": options.channel_id})
if r.status_code / 100 == 2: if r.status_code / 100 == 2:
print("Success") print("Success")
print json.dumps(r.json(), indent=4, sort_keys=True) print json.dumps(r.json(), indent=4, sort_keys=True)

View File

@ -65,13 +65,13 @@ def main():
global base_url global base_url
base_url = "http://%s/sdrangel" % options.address base_url = "http://%s/sdrangel" % options.address
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set") r = callAPI("/deviceset", "POST", {"direction": 1}, None, "Add Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
deviceset_url = "/deviceset/%d" % options.device_index deviceset_url = "/deviceset/%d" % options.device_index
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "LimeSDR", "tx": 1}, "setup LimeSDR on Tx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "LimeSDR", "direction": 1}, "setup LimeSDR on Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
@ -91,7 +91,7 @@ def main():
if r is None: if r is None:
exit(-1) exit(-1)
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod") r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "direction": 1}, "Create NFM mod")
if r is None: if r is None:
exit(-1) exit(-1)

View File

@ -61,7 +61,7 @@ def main():
global base_url global base_url
base_url = "http://%s/sdrangel" % options.address base_url = "http://%s/sdrangel" % options.address
settings = callAPI("/deviceset/0/channel", "POST", None, {"channelType": "NFMDemod", "tx": 0}, "Create NFM demod") settings = callAPI("/deviceset/0/channel", "POST", None, {"channelType": "NFMDemod", "direction": 0}, "Create NFM demod")
if settings is None: if settings is None:
exit(-1) exit(-1)
@ -72,11 +72,11 @@ def main():
if r is None: if r is None:
exit(-1) exit(-1)
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set") r = callAPI("/deviceset", "POST", {"direction": 1}, None, "Add Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
settings = callAPI("/deviceset/1/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod") settings = callAPI("/deviceset/1/channel", "POST", None, {"channelType": "NFMMod", "direction": 1}, "Create NFM mod")
if settings is None: if settings is None:
exit(-1) exit(-1)

View File

@ -1,13 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
''' '''
PTT (Push To Talk) script example. PTT (Push To Talk) script example.
Assumes Rx and Tx are contiguous device sets with Rx at index i and Tx at index i+1 Assumes Rx and Tx are contiguous device sets with Rx at index i and Tx at index i+1
When going from Rx to Tx (push) the device set index specified must be the Rx one When going from Rx to Tx (push) the device set index specified must be the Rx one
When going from Tx to Rx (release) the device set index specified must be the Tx one When going from Tx to Rx (release) the device set index specified must be the Tx one
Defaults are Rx at index 0 and Tx at index 1 Defaults are Rx at index 0 and Tx at index 1
Default web API base address is http://127.0.0.1:8091/sdrangel (default of sdrangel web API) Default web API base address is http://127.0.0.1:8091/sdrangel (default of sdrangel web API)
You may change the address and port portion with the -a parameter. Ex: -a 44.168.40.128:8888 You may change the address and port portion with the -a parameter. Ex: -a 44.168.40.128:8888
''' '''
@ -105,7 +105,7 @@ def main():
if deviceSets is not None: if deviceSets is not None:
if len(deviceSets) > 1: if len(deviceSets) > 1:
if options.transmit: if options.transmit:
if deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index + 1]["samplingDevice"]["tx"] == 1: if deviceSets[options.deviceset_index]["samplingDevice"]["direction"] == 0 and deviceSets[options.deviceset_index + 1]["samplingDevice"]["direction"] == 1:
stopDevice(options.deviceset_index) stopDevice(options.deviceset_index)
time.sleep(1) time.sleep(1)
startDevice(options.deviceset_index + 1) startDevice(options.deviceset_index + 1)
@ -113,7 +113,7 @@ def main():
else: else:
print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index, options.deviceset_index + 1)) print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index, options.deviceset_index + 1))
else: else:
if deviceSets[options.deviceset_index - 1]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 1: if deviceSets[options.deviceset_index - 1]["samplingDevice"]["direction"] == 0 and deviceSets[options.deviceset_index]["samplingDevice"]["direction"] == 1:
stopDevice(options.deviceset_index) stopDevice(options.deviceset_index)
time.sleep(1) time.sleep(1)
startDevice(options.deviceset_index - 1) startDevice(options.deviceset_index - 1)

View File

@ -158,12 +158,12 @@ def device_run(deviceset_index):
''' Reply with the expected reply of a working device ''' ''' Reply with the expected reply of a working device '''
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
originator_index = None originator_index = None
tx = None direction = None
content = request.get_json(silent=True) content = request.get_json(silent=True)
if content: if content:
originator_index = content.get('originatorIndex') originator_index = content.get('originatorIndex')
tx = content.get('tx') direction = content.get('direction')
if originator_index is None or tx is None: if originator_index is None or direction is None:
print('device_run: SDRangel reverse API v4.5.2 or higher required. No or invalid originator information') print('device_run: SDRangel reverse API v4.5.2 or higher required. No or invalid originator information')
return "" return ""
sdrangel_ip = get_sdrangel_ip(request) sdrangel_ip = get_sdrangel_ip(request)
@ -174,7 +174,7 @@ def device_run(deviceset_index):
global RUNNING global RUNNING
print(f'device_run: Device: {originator_index} Other device: {other_device_index} Running: {RUNNING}') print(f'device_run: Device: {originator_index} Other device: {other_device_index} Running: {RUNNING}')
if request.method == 'POST': if request.method == 'POST':
print(f'device_run: Device {originator_index} (tx={tx}) has started at {sdrangel_ip}:{SDRANGEL_API_PORT}') print(f'device_run: Device {originator_index} (direction={direction}) has started at {sdrangel_ip}:{SDRANGEL_API_PORT}')
if originator_index not in RUNNING: if originator_index not in RUNNING:
RUNNING.add(originator_index) RUNNING.add(originator_index)
if other_device_index in RUNNING: if other_device_index in RUNNING:
@ -186,7 +186,7 @@ def device_run(deviceset_index):
reply = { "state": "idle" } reply = { "state": "idle" }
return jsonify(reply) return jsonify(reply)
elif request.method == 'DELETE': elif request.method == 'DELETE':
print(f'device_run: Device {originator_index} (tx={tx}) has stopped at {sdrangel_ip}:{SDRANGEL_API_PORT}') print(f'device_run: Device {originator_index} (direction={direction}) has stopped at {sdrangel_ip}:{SDRANGEL_API_PORT}')
if originator_index in RUNNING: if originator_index in RUNNING:
RUNNING.remove(originator_index) RUNNING.remove(originator_index)
if other_device_index not in RUNNING: if other_device_index not in RUNNING:

View File

@ -41,65 +41,65 @@ def getInputOptions():
def get_channel_static_data(channel_info): def get_channel_static_data(channel_info):
if channel_info["id"] == "AMDemod": if channel_info["id"] == "AMDemod":
settings_key = "AMDemodSettings" settings_key = "AMDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "AMMod": elif channel_info["id"] == "AMMod":
settings_key = "AMModSettings" settings_key = "AMModSettings"
tx = 1 direction = 1
elif channel_info["id"] == "ATVMod": elif channel_info["id"] == "ATVMod":
settings_key = "ATVModSettings" settings_key = "ATVModSettings"
tx = 1 direction = 1
elif channel_info["id"] == "BFMDemod": elif channel_info["id"] == "BFMDemod":
settings_key = "BFMDemodSettings" settings_key = "BFMDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "DSDDemod": elif channel_info["id"] == "DSDDemod":
settings_key = "DSDDemodSettings" settings_key = "DSDDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "NFMDemod": elif channel_info["id"] == "NFMDemod":
settings_key = "NFMDemodSettings" settings_key = "NFMDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "NFMMod": elif channel_info["id"] == "NFMMod":
settings_key = "NFMModSettings" settings_key = "NFMModSettings"
tx = 1 direction = 1
elif channel_info["id"] == "RemoteSink": elif channel_info["id"] == "RemoteSink":
settings_key = "RemoteSinkSettings" settings_key = "RemoteSinkSettings"
tx = 0 direction = 0
elif channel_info["id"] == "RemoteSource": elif channel_info["id"] == "RemoteSource":
settings_key = "RemoteSourceSettings" settings_key = "RemoteSourceSettings"
tx = 1 direction = 1
elif channel_info["id"] == "SSBMod": elif channel_info["id"] == "SSBMod":
settings_key = "SSBModSettings" settings_key = "SSBModSettings"
tx = 1 direction = 1
elif channel_info["id"] == "SSBDemod": elif channel_info["id"] == "SSBDemod":
settings_key = "SSBDemodSettings" settings_key = "SSBDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "UDPSource": elif channel_info["id"] == "UDPSource":
settings_key = "UDPSourceSettings" settings_key = "UDPSourceSettings"
tx = 1 direction = 1
elif channel_info["id"] == "UDPSink": elif channel_info["id"] == "UDPSink":
settings_key = "UDPSinkSettings" settings_key = "UDPSinkSettings"
tx = 0 direction = 0
elif channel_info["id"] == "WFMDemod": elif channel_info["id"] == "WFMDemod":
settings_key = "WFMDemodSettings" settings_key = "WFMDemodSettings"
tx = 0 direction = 0
elif channel_info["id"] == "WFMMod": elif channel_info["id"] == "WFMMod":
settings_key = "WFMModSettings" settings_key = "WFMModSettings"
tx = 1 direction = 1
else: else:
settings_key = None settings_key = None
tx = None direction = None
return settings_key, tx return settings_key, direction
# ====================================================================== # ======================================================================
def randomize_channels_colors(options, channels): def randomize_channels_colors(options, channels):
for channel_info in channels: for channel_info in channels:
settings_key, tx = get_channel_static_data(channel_info) settings_key, direction = get_channel_static_data(channel_info)
if settings_key is None: if settings_key is None:
continue continue
color = random.randint(0, (1<<24)) color = random.randint(0, (1<<24))
rn, gn, bn = color_to_rgb(color) rn, gn, bn = color_to_rgb(color)
payload_json = { payload_json = {
"channelType": channel_info["id"], "channelType": channel_info["id"],
"tx": tx, "direction": direction,
settings_key: { settings_key: {
"rgbColor": color "rgbColor": color
} }
@ -114,7 +114,7 @@ def randomize_channels_colors(options, channels):
# ====================================================================== # ======================================================================
def randomize_channels_hsv(options, channels): def randomize_channels_hsv(options, channels):
for channel_info in channels: for channel_info in channels:
settings_key, tx = get_channel_static_data(channel_info) settings_key, direction = get_channel_static_data(channel_info)
settings_url = base_url + ("/deviceset/{0}/channel/{1}/settings".format(options.device_index, channel_info["index"])) settings_url = base_url + ("/deviceset/{0}/channel/{1}/settings".format(options.device_index, channel_info["index"]))
rep = requests.get(url=settings_url) rep = requests.get(url=settings_url)
if rep.status_code / 100 == 2: if rep.status_code / 100 == 2:
@ -139,7 +139,7 @@ def randomize_channels_hsv(options, channels):
new_color = rgb_to_color(rn, gn, bn) new_color = rgb_to_color(rn, gn, bn)
payload_json = { payload_json = {
"channelType": channel_info["id"], "channelType": channel_info["id"],
"tx": tx, "direction": direction,
settings_key: { settings_key: {
"rgbColor": new_color "rgbColor": new_color
} }

View File

@ -49,7 +49,7 @@ def getRtlSdrSettings():
def patchRtlSdrSettings(settings): def patchRtlSdrSettings(settings):
new_settings = {"deviceHwType": "RTLSDR", "tx": 0, "rtlSdrSettings": settings} new_settings = {"deviceHwType": "RTLSDR", "direction": 0, "rtlSdrSettings": settings}
r = requests.patch(url=base_url + "/deviceset/0/device/settings", json=new_settings) r = requests.patch(url=base_url + "/deviceset/0/device/settings", json=new_settings)
if r.status_code / 100 == 2: if r.status_code / 100 == 2:
print json.dumps(r.json(), indent=4, sort_keys=True) print json.dumps(r.json(), indent=4, sort_keys=True)

View File

@ -53,7 +53,7 @@ def getInputOptions():
parser.add_option("--rmt-address", dest="remote_address", help="RemoteSink: destination data address", metavar="IP_ADDRESS", type="string") parser.add_option("--rmt-address", dest="remote_address", help="RemoteSink: destination data address", metavar="IP_ADDRESS", type="string")
parser.add_option("--rmt-port", dest="remote_port", help="RemoteSink: destination data port", metavar="PORT", type="int") parser.add_option("--rmt-port", dest="remote_port", help="RemoteSink: destination data port", metavar="PORT", type="int")
parser.add_option("--rmt-fec", dest="remote_fec", help="RemoteSink: number of FEC blocks per frame", metavar="NUMBER", type="int") parser.add_option("--rmt-fec", dest="remote_fec", help="RemoteSink: number of FEC blocks per frame", metavar="NUMBER", type="int")
parser.add_option("--rmt-tx-delay", dest="remote_tx_delay", help="RemoteSink: inter block UDP Tx delay percentage", metavar="PERCENT", type="int") parser.add_option("--rmt-txdelay", dest="remote_tx_delay", help="RemoteSink: inter block UDP Tx delay percentage", metavar="PERCENT", type="int")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -134,7 +134,7 @@ def setup_audio(options):
# ====================================================================== # ======================================================================
def setupDevice(deviceset_url, options): def setupDevice(deviceset_url, options):
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "tx": 0}, "setup device on Rx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "direction": 0}, "setup device on Rx device set")
if r is None: if r is None:
exit(-1) exit(-1)
@ -245,7 +245,7 @@ def setupDevice(deviceset_url, options):
def setupChannel(deviceset_url, options): def setupChannel(deviceset_url, options):
i = 0 i = 0
settings = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "tx": 0}, "Create demod") settings = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "direction": 0}, "Create demod")
if settings is None: if settings is None:
exit(-1) exit(-1)
@ -349,7 +349,7 @@ def main():
deviceset_url = "/deviceset/%d" % options.device_index deviceset_url = "/deviceset/%d" % options.device_index
if options.create: if options.create:
r = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set") r = callAPI("/deviceset", "POST", {"direction": 0}, None, "Add Rx device set")
if r is None: if r is None:
exit(-1) exit(-1)

View File

@ -19,15 +19,15 @@ def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n") parser = OptionParser(usage="usage: %%prog [-t]\n")
parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string") parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
parser.add_option("-R", "--device-hwid-rx", dest="device_hwid_rx", help="device hardware id for Rx", metavar="HWID", type="string") parser.add_option("-R", "--device-hwidrx", dest="device_hwid_rx", help="device hardware id for Rx", metavar="HWID", type="string")
parser.add_option("-T", "--device-hwid-tx", dest="device_hwid_tx", help="device hardware id for Tx", metavar="HWID", type="string") parser.add_option("-T", "--device-hwidtx", dest="device_hwid_tx", help="device hardware id for Tx", metavar="HWID", type="string")
parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int") parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int")
parser.add_option("-f", "--channel-freq", dest="channel_freq", help="channel center frequency (Hz)", metavar="FREQ", type="int") parser.add_option("-f", "--channel-freq", dest="channel_freq", help="channel center frequency (Hz)", metavar="FREQ", type="int")
parser.add_option("-U", "--copy-to-udp", dest="udp_copy", help="UDP audio copy to <address>[:<port>]", metavar="IP:PORT", type="string") parser.add_option("-U", "--copy-to-udp", dest="udp_copy", help="UDP audio copy to <address>[:<port>]", metavar="IP:PORT", type="string")
parser.add_option("-s", "--sample-rate-rx", dest="sample_rate_rx", help="device to host (Rx) sample rate (kS/s)", metavar="RATE", type="int") parser.add_option("-s", "--sample-raterx", dest="sample_rate_rx", help="device to host (Rx) sample rate (kS/s)", metavar="RATE", type="int")
parser.add_option("-S", "--sample-rate-tx", dest="sample_rate_tx", help="host to device (Tx) sample rate (kS/s)", metavar="RATE", type="int") parser.add_option("-S", "--sample-ratetx", dest="sample_rate_tx", help="host to device (Tx) sample rate (kS/s)", metavar="RATE", type="int")
parser.add_option("-n", "--antenna-path-rx", dest="antenna_path_rx", help="antenna path index (Rx)", metavar="INDEX", type="int") parser.add_option("-n", "--antenna-pathrx", dest="antenna_path_rx", help="antenna path index (Rx)", metavar="INDEX", type="int")
parser.add_option("-N", "--antenna-path-tx", dest="antenna_path_tx", help="antenna path index (Tx)", metavar="INDEX", type="int") parser.add_option("-N", "--antenna-pathtx", dest="antenna_path_tx", help="antenna path index (Tx)", metavar="INDEX", type="int")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -101,7 +101,7 @@ def main():
nb_devicesets = r['devicesetcount'] nb_devicesets = r['devicesetcount']
if nb_devicesets == 0: # server starts without device set so add Rx device set if nb_devicesets == 0: # server starts without device set so add Rx device set
r1 = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set") r1 = callAPI("/deviceset", "POST", {"direction": 0}, None, "Add Rx device set")
if r1 is None: if r1 is None:
exit(-1) exit(-1)
@ -110,7 +110,7 @@ def main():
deviceset_index_rx = 0 deviceset_index_rx = 0
deviceset_url = "/deviceset/%d" % deviceset_index_rx deviceset_url = "/deviceset/%d" % deviceset_index_rx
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_rx, "tx": 0}, "setup device on Rx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_rx, "direction": 0}, "setup device on Rx device set")
if r is None: if r is None:
exit(-1) exit(-1)
@ -151,7 +151,7 @@ def main():
if r is None: if r is None:
exit(-1) exit(-1)
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMDemod", "tx": 0}, "Create NFM demod") r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMDemod", "direction": 0}, "Create NFM demod")
if r is None: if r is None:
exit(-1) exit(-1)
@ -185,13 +185,13 @@ def main():
# ## Tx setup # ## Tx setup
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set") r = callAPI("/deviceset", "POST", {"direction": 1}, None, "Add Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
deviceset_url = "/deviceset/%d" % (deviceset_index_rx + 1) deviceset_url = "/deviceset/%d" % (deviceset_index_rx + 1)
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_tx, "tx": 1}, "setup device on Tx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_tx, "direction": 1}, "setup device on Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
@ -222,7 +222,7 @@ def main():
if r is None: if r is None:
exit(-1) exit(-1)
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod") r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "direction": 1}, "Create NFM mod")
if r is None: if r is None:
exit(-1) exit(-1)

View File

@ -2,11 +2,11 @@
""" """
SDRangel REST API client script SDRangel REST API client script
Simple scanner for AM and NFM channels. Builds an array of equally spaced channels. Moves device center frequency Simple scanner for AM and NFM channels. Builds an array of equally spaced channels. Moves device center frequency
so that adjacent parts of the spectrum are scanned by the array of channels. Stops when any of the channels so that adjacent parts of the spectrum are scanned by the array of channels. Stops when any of the channels
is active. Resumes when none of the channels is active. is active. Resumes when none of the channels is active.
Uses /sdrangel/deviceset/{deviceSetIndex}/channels/report API to get channel information (since v3.13.1) Uses /sdrangel/deviceset/{deviceSetIndex}/channels/report API to get channel information (since v3.13.1)
""" """
@ -178,7 +178,7 @@ def changeDeviceFrequency(fc, options):
def setupChannels(scan_control, options): def setupChannels(scan_control, options):
i = 0 i = 0
for shift in scan_control.channel_shifts: for shift in scan_control.channel_shifts:
settings = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "tx": 0}, "Create demod") settings = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "direction": 0}, "Create demod")
if settings is None: if settings is None:
exit(-1) exit(-1)
@ -314,11 +314,11 @@ def main():
if not options.rerun: # Skip device and channels settings in re-run mode if not options.rerun: # Skip device and channels settings in re-run mode
if options.create: if options.create:
r = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set") r = callAPI("/deviceset", "POST", {"direction": 0}, None, "Add Rx device set")
if r is None: if r is None:
exit(-1) exit(-1)
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": options.device_hwid, "tx": 0}, "setup device on Rx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": options.device_hwid, "direction": 0}, "setup device on Rx device set")
if r is None: if r is None:
exit(-1) exit(-1)

View File

@ -32,7 +32,7 @@
"useReverseAPI": 0, "useReverseAPI": 0,
"vgaGain": 24 "vgaGain": 24
}, },
"tx": 0 "direction": 0
}, },
"Setup HackRF on Rx 0" "Setup HackRF on Rx 0"
], ],
@ -42,7 +42,7 @@
null, null,
{ {
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Add a remote sink channel" "Add a remote sink channel"
], ],
@ -67,7 +67,7 @@
"useReverseAPI": 0 "useReverseAPI": 0
}, },
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Setup remote sink on channel 0" "Setup remote sink on channel 0"
], ],
@ -77,7 +77,7 @@
null, null,
{ {
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Add a remote sink channel" "Add a remote sink channel"
], ],
@ -102,7 +102,7 @@
"useReverseAPI": 0 "useReverseAPI": 0
}, },
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Setup remote sink on channel 1" "Setup remote sink on channel 1"
], ],
@ -112,7 +112,7 @@
null, null,
{ {
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Add a remote sink channel" "Add a remote sink channel"
], ],
@ -137,7 +137,7 @@
"useReverseAPI": 0 "useReverseAPI": 0
}, },
"channelType": "RemoteSink", "channelType": "RemoteSink",
"tx": 0 "direction": 0
}, },
"Setup remote sink on channel 2" "Setup remote sink on channel 2"
], ],

View File

@ -166,7 +166,7 @@ def setupDevice(options):
# ====================================================================== # ======================================================================
def setupChannel(options): def setupChannel(options):
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "tx": 1}, "Create modulator") r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "direction": 1}, "Create modulator")
if r is None: if r is None:
exit(-1) exit(-1)
@ -266,14 +266,14 @@ def main():
base_url = "http://%s/sdrangel" % options.address base_url = "http://%s/sdrangel" % options.address
if options.create: if options.create:
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set") r = callAPI("/deviceset", "POST", {"direction": 1}, None, "Add Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)
global deviceset_url global deviceset_url
deviceset_url = "/deviceset/%d" % options.device_index deviceset_url = "/deviceset/%d" % options.device_index
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "tx": 1}, "setup device on Tx device set") r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "direction": 1}, "setup device on Tx device set")
if r is None: if r is None:
exit(-1) exit(-1)