forked from ptrkrysik/gr-gsm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apps/grgsm_trx: add baseband frequency shift feature
An ability to shift the baseband frequency would allow one to run both base stations and (OsmocomBB-based) mobile stations on any frequency (e.g. in 2.4 GHz WiFi band)! This is achieved by adding a given frequency offset to the result of "ARFCN -> RX/TX frequency" calculation. Usage example: grgsm_trx --freq-offset -500M Both RX (Downlink) and TX (Uplink) frequencies will be shifted by 500 MHz back, e.g. tuning request to ARFCN 105 would result in tuning the radio to 456.0 MHz (instead of 956.0 MHz). Related: OS#3520 (https://osmocom.org/versions/136) Change-Id: I42e397e47402a87f4141ef31b25eff4c8c1267e2
- Loading branch information
1 parent
840885f
commit 97dc84e
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# GR-GSM based transceiver | ||
# Follow graph implementation | ||
# | ||
# (C) 2016-2017 by Vadim Yanitskiy <[email protected]> | ||
# (C) 2016-2018 by Vadim Yanitskiy <[email protected]> | ||
# (C) 2017 by Piotr Krysik <[email protected]> | ||
# | ||
# All Rights Reserved | ||
|
@@ -29,6 +29,7 @@ | |
|
||
from math import pi | ||
|
||
from gnuradio import eng_notation | ||
from gnuradio import digital | ||
from gnuradio import blocks | ||
from gnuradio import uhd | ||
|
@@ -59,6 +60,7 @@ def change_sign(self, msg): | |
|
||
class radio_if(gr.top_block): | ||
# PHY specific variables | ||
freq_offset_hz = None | ||
rx_freq = 935e6 | ||
tx_freq = 890e6 | ||
osr = 4 | ||
|
@@ -274,11 +276,21 @@ def calc_phase_inc(self, fc): | |
return self.ppm / 1.0e6 * 2 * pi * fc / self.sample_rate | ||
|
||
def set_rx_freq(self, fc): | ||
if self.freq_offset_hz is not None: | ||
fc += self.freq_offset_hz | ||
print("[#] Shifting RX freq. to %s (offset is %s)" | ||
% (eng_notation.num_to_str(fc), | ||
eng_notation.num_to_str(self.freq_offset_hz))) | ||
self.phy_src.set_center_freq(fc, 0) | ||
self.rotator_src.set_phase_inc(self.calc_phase_inc(fc)) | ||
self.rx_freq = fc | ||
|
||
def set_tx_freq(self, fc): | ||
if self.freq_offset_hz is not None: | ||
fc += self.freq_offset_hz | ||
print("[#] Shifting TX freq. to %s (offset is %s)" | ||
% (eng_notation.num_to_str(fc), | ||
eng_notation.num_to_str(self.freq_offset_hz))) | ||
self.phy_sink.set_center_freq(fc, 0) | ||
self.rotator_sink.set_phase_inc(-self.calc_phase_inc(fc)) | ||
self.tx_freq = fc | ||
|