aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-09-21 13:50:38 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-09-21 17:24:11 +0200
commit069f5cd85716b0c09054a5262f2f64ea91bd0536 (patch)
tree3e0d9842764f85ee0f8599a35751c3e89d8be245 /Transceiver52M
parentc90b2078037d3fa174b08933d19a99a497ad669d (diff)
lms,uhd: Validate band of RxFreq too
So far the validation is only done on TxFreq for all TRX. Let's also do it for RxFreq. Change-Id: I30eef2727ee96b1344aa1416edd66e2302b88964
Diffstat (limited to 'Transceiver52M')
-rw-r--r--Transceiver52M/device/lms/LMSDevice.cpp17
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.cpp17
2 files changed, 34 insertions, 0 deletions
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 30fd665..221d7e2 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -1026,8 +1026,25 @@ bool LMSDevice::setTxFreq(double wFreq, size_t chan)
bool LMSDevice::setRxFreq(double wFreq, size_t chan)
{
+ uint16_t req_arfcn;
+ enum gsm_band req_band;
+
LOGCHAN(chan, DDEV, NOTICE) << "Setting Rx Freq to " << wFreq << " Hz";
+ req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 1);
+ if (req_arfcn == 0xffff) {
+ LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz";
+ return false;
+ }
+ if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) {
+ LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Rx Frequency " << wFreq
+ << " Hz (ARFCN " << req_arfcn << " )";
+ return false;
+ }
+
+ if (!set_band(req_band))
+ return false;
+
if (LMS_SetLOFrequency(m_lms_dev, LMS_CH_RX, chan, wFreq) < 0) {
LOGCHAN(chan, DDEV, ERROR) << "Error setting Rx Freq to " << wFreq << " Hz";
return false;
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 5486822..7a8eb9b 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -1102,12 +1102,29 @@ bool uhd_device::setTxFreq(double wFreq, size_t chan)
bool uhd_device::setRxFreq(double wFreq, size_t chan)
{
+ uint16_t req_arfcn;
+ enum gsm_band req_band;
+
if (chan >= rx_freqs.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
return false;
}
ScopedLock lock(tune_lock);
+ req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 1);
+ if (req_arfcn == 0xffff) {
+ LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz";
+ return false;
+ }
+ if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) {
+ LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Rx Frequency " << wFreq
+ << " Hz (ARFCN " << req_arfcn << " )";
+ return false;
+ }
+
+ if (!set_band(req_band))
+ return false;
+
return set_freq(wFreq, chan, false);
}