-
Notifications
You must be signed in to change notification settings - Fork 1
/
Registration.cpp
59 lines (48 loc) · 1.86 KB
/
Registration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2022 Nicholas Corgan
// SPDX-License-Identifier: GPL-3.0-or-later
#include "spyserver_client.h"
#include "SoapySpyServerClient.hpp"
#include <SoapySDR/Registry.hpp>
#include <SoapySDR/Types.hpp>
#include <SoapySDR/Version.hpp>
#include <cassert>
/***********************************************************************
* Find
**********************************************************************/
static std::vector<SoapySDR::Kwargs> findSpyServerClient(const SoapySDR::Kwargs &args)
{
std::vector<SoapySDR::Kwargs> results;
try
{
const auto client = SoapySpyServerClient::makeSDRPPClient(args);
assert(args.count("host"));
assert(args.count("port"));
assert(client.client);
assert(client.client->isOpen());
results.emplace_back();
auto &result = results.front();
const auto &devInfo = client.client->devInfo;
result["host"] = args.at("host");
result["port"] = args.at("port");
result["device"] = SoapySpyServerClient::DeviceEnumToName(devInfo.DeviceType);
result["serial"] = std::to_string(devInfo.DeviceSerial);
result["url"] = SoapySpyServerClient::ParamsToSpyServerURL(args.at("host"), args.at("port"));
}
catch(...){ results.clear(); }
return results;
}
/***********************************************************************
* Make
**********************************************************************/
static SoapySDR::Device *makeSpyServerClient(const SoapySDR::Kwargs &args)
{
return new SoapySpyServerClient(args);
}
/***********************************************************************
* Registration
**********************************************************************/
static SoapySDR::Registry registerSpyServerClient(
"spyserver",
&findSpyServerClient,
&makeSpyServerClient,
SOAPY_SDR_ABI_VERSION);