1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 05:11:49 -05:00

Web API: LimeSDR Tx example: have device set index as a parameter

This commit is contained in:
f4exb 2017-12-27 09:19:23 +01:00
parent ccffb5101d
commit 6eda2fa087

View File

@ -18,12 +18,16 @@ def getInputOptions():
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("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
(options, args) = parser.parse_args()
if (options.address == None):
if options.address == None:
options.address = "127.0.0.1:8091"
if options.device_index == None:
options.device_index = 1
return options
# ======================================================================
@ -61,11 +65,13 @@ def main():
if r is None:
exit(-1)
r = callAPI("/deviceset/1/device", "PUT", None, {"hwType": "LimeSDR", "tx": 1}, "setup LimeSDR on Tx 1")
deviceset_url = "/deviceset/%d" % options.device_index
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "LimeSDR", "tx": 1}, "setup LimeSDR on Tx device set")
if r is None:
exit(-1)
settings = callAPI("/deviceset/1/device/settings", "GET", None, None, "Get LimeSDR Tx settings")
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get LimeSDR Tx settings")
if settings is None:
exit(-1)
@ -77,15 +83,15 @@ def main():
settings["limeSdrOutputSettings"]["lpfFIRBW"] = 100000
settings["limeSdrOutputSettings"]["lpfFIREnable"] = 1
r = callAPI("/deviceset/1/device/settings", "PATCH", None, settings, "Patch LimeSDR Tx settings")
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch LimeSDR Tx settings")
if r is None:
exit(-1)
r = callAPI("/deviceset/1/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod")
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod")
if r is None:
exit(-1)
settings = callAPI("/deviceset/1/channel/0/settings", "GET", None, None, "Get NFM mod settings")
settings = callAPI(deviceset_url + "/channel/0/settings", "GET", None, None, "Get NFM mod settings")
if settings is None:
exit(-1)
@ -95,11 +101,11 @@ def main():
settings["NFMModSettings"]["modAFInput"] = 4 # CW text
settings["NFMModSettings"]["toneFrequency"] = 600
r = callAPI("/deviceset/1/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
if r is None:
exit(-1)
r = callAPI("/deviceset/1/device/run", "POST", None, None, "Start device on deviceset R1")
r = callAPI(deviceset_url + "/device/run", "POST", None, None, "Start device on deviceset R1")
if r is None:
exit(-1)