Browse Source

MCP: tune the gain when a receiver is set up, and handle the channels a retune moves

listen and scan measure and set the receiver gain, as tune_gain does, when
they create a device set or move one to another band, and leave it alone on
a move within a band or a change of mode, or when told tuneGain false. On a
new device set this replaces the fixed 40 dB profile, which stays only when
tuning is declined.

A retune moves every channel on the device set, since each is an offset from
the centre. Channels the intent tools did not add are now kept on the
frequency they had, by moving their offset, where the new baseband still
holds them; an audio demodulator it cannot hold is removed, since all it
could do is play noise; a file sink, an analyser or anything else without
audio is left in place and named in the reply. The offset key is read from
the channel's own settings, as it differs by type.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
chirpmodem-v8.0.0
Jon Beniston 3 months ago
parent
commit
f0e5a78067
  1. 5
      plugins/feature/mcpserver/bandguide.md
  2. 903
      plugins/feature/mcpserver/mcptools.cpp
  3. 19
      plugins/feature/mcpserver/mcptools.h
  4. 2
      plugins/feature/mcpserver/readme.md

5
plugins/feature/mcpserver/bandguide.md

@ -208,7 +208,10 @@ converter's, sets the floor, short of overload. Use it @@ -208,7 +208,10 @@ converter's, sets the floor, short of overload. Use it
after tuning to the band of interest and before judging weak signals; the reply's table shows
where the front end starts to overload. It turns the device's AGC off, which a manual gain
requires. It knows the RTL-SDR, HackRF, Airspy, LimeSDR, PlutoSDR and USRP; for another
device read `describe_settings` and give it the gain key and values.
device read `describe_settings` and give it the gain key and values. `listen` and `scan` run
it themselves when they create a device set or move one to another band, and say what they
set; pass `tuneGain` false to keep a gain you have chosen. A change of mode or a move within a
band does not trigger it, as the gain suits the band and the antenna rather than the mode.
RTL-SDR `gain` is in tenths of a decibel (402 is 40.2 dB) and only the values in
`get_device_report`'s supported list take effect; `agc` hands control to the tuner, which is

903
plugins/feature/mcpserver/mcptools.cpp

File diff suppressed because it is too large Load Diff

19
plugins/feature/mcpserver/mcptools.h

@ -206,8 +206,13 @@ private: @@ -206,8 +206,13 @@ private:
// Shared by the intent level tools
QJsonObject channelReport(int deviceSetIndex, int channelIndex);
void postChannelAction(int deviceSetIndex, int channelIndex, const QJsonObject& actions);
//!< doomed: uids of channels the caller is about to remove, which the reused set is not counted as carrying
QJsonObject pickReceiver(const QJsonObject& args, int minBaseband, const QSet<uint64_t>& doomed = QSet<uint64_t>());
//!< doomed: uids of channels the caller is about to remove, which the reused set is not counted as carrying.
//!< profileGain: give a device set this creates the fixed receiver gain profile; false when the gain is about to be measured
QJsonObject pickReceiver(const QJsonObject& args, int minBaseband, const QSet<uint64_t>& doomed = QSet<uint64_t>(), bool profileGain = true);
//!< The tune_gain tool: sweeps the gain and applies the best, with the table it measured
QJsonObject tuneGain(const QJsonObject& args);
//!< Whether listen or scan should measure the gain: a device set they created, or a retune to another band
static bool gainWorthTuning(bool reused, double previousCentre, double centre);
static uint64_t channelUid(const void *channel);
void trackIntentChannel(const void *channel);
void untrackIntentChannel(const void *channel);
@ -219,9 +224,17 @@ private: @@ -219,9 +224,17 @@ private:
QStringList reclaimIntentChannels(int deviceSetIndex, const void *keep = nullptr);
//!< The channel a previous listen added that a new one of this type can retune instead of replacing, or null
const void *reusableIntentChannel(int deviceSetIndex, const QString& channelType, int& channelIndex);
//!< What a retune of a reused device set did to the channels listen and scan did not add
struct RetuneOutcome
{
QStringList m_kept; //!< Re-offset so that they stay on the frequency they had
QStringList m_removed; //!< Audio demodulators the new baseband could not hold, which would only have made noise
QStringList m_stranded; //!< Left where they were: not audio, or the baseband unknown
};
RetuneOutcome retuneOtherChannels(int deviceSetIndex, double previousCentre, double centre, int baseband);
//!< What listen and scan tell the caller about the rest of the device set once their own channels are in
QStringList intentNotes(int deviceSetIndex, const QSet<const void *>& added, const QStringList& reclaimed,
bool reused, double previousCentre, double centre);
bool reused, double previousCentre, double centre, const RetuneOutcome& outcome);
//!< Channel type ids for a direction, independent of how list_channel_types formats them
QStringList channelTypeIds(int direction);
//!< Where a channel is now. The intent tools sleep for many seconds without holding the

2
plugins/feature/mcpserver/readme.md

@ -102,7 +102,7 @@ With a token set, the header goes alongside it: @@ -102,7 +102,7 @@ With a token set, the header goes alongside it:
<h2>Tools</h2>
The intent tools do a whole task in one call: `listen` sets up a receiver on a frequency in a given mode, `scan` sets up a Frequency Scanner over a list or range of frequencies and reports every frequency above the threshold with its level (and, for intermittent signals, where the scanner parked), stepping by the channel spacing usual for the mode unless told otherwise and refusing modes that live on fixed frequencies, and `get_status` returns one line per device set and feature. Both `listen` and `scan` keep track of the channels they add: by default the next of either on the same device set removes them first, so that exploring a band does not leave a trail of demodulators all playing audio, and `cleanup` removes them all. A `listen` that finds a demodulator of the type it needs among them retunes it instead, as a person would, so stepping through a band in one mode keeps one channel open throughout. Channels added any other way are never touched; the reply says which of those the retune may have left outside the baseband. The rest mirror the Web API. Creation tools wait for SDRangel to complete the operation and return the index of the new object; the `set_*` tools reply with only the keys that were changed, since a client carries every reply in its context for the rest of the conversation.
The intent tools do a whole task in one call: `listen` sets up a receiver on a frequency in a given mode, `scan` sets up a Frequency Scanner over a list or range of frequencies and reports every frequency above the threshold with its level (and, for intermittent signals, where the scanner parked), stepping by the channel spacing usual for the mode unless told otherwise and refusing modes that live on fixed frequencies, and `get_status` returns one line per device set and feature. Both `listen` and `scan` keep track of the channels they add: by default the next of either on the same device set removes them first, so that exploring a band does not leave a trail of demodulators all playing audio, and `cleanup` removes them all. A `listen` that finds a demodulator of the type it needs among them retunes it instead, as a person would, so stepping through a band in one mode keeps one channel open throughout. Both measure and set the receiver gain, as `tune_gain` does, when they create a device set or move one to another band, and leave it alone otherwise or when told `tuneGain` false. Channels added any other way are kept on the frequency they had, by moving their offset, when the retuned baseband still holds them; an audio demodulator it cannot hold is removed, since all it could do is play noise, while anything else (a file sink, an analyser) is left in place and named in the reply. The rest mirror the Web API. Creation tools wait for SDRangel to complete the operation and return the index of the new object; the `set_*` tools reply with only the keys that were changed, since a client carries every reply in its context for the rest of the conversation.
| Area | Tools |
|------|-------|

Loading…
Cancel
Save