Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
| 4 | # GR-GSM based transceiver |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 5 | # Extending a GRC flowgraph gr-gsm/examples/trx_radio_if/radio_if_grc.grc |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 6 | # |
| 7 | # (C) 2016-2017 by Vadim Yanitskiy <axilirator@gmail.com> |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 8 | # (C) 2017 by Piotr Krysik <ptrkrysik@gmail.com> |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 9 | # |
| 10 | # All Rights Reserved |
| 11 | # |
| 12 | # This program is free software; you can redistribute it and/or modify |
| 13 | # it under the terms of the GNU General Public License as published by |
| 14 | # the Free Software Foundation; either version 2 of the License, or |
| 15 | # (at your option) any later version. |
| 16 | # |
| 17 | # This program is distributed in the hope that it will be useful, |
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | # GNU General Public License for more details. |
| 21 | # |
| 22 | # You should have received a copy of the GNU General Public License along |
| 23 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 25 | |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 26 | from grgsm.trx import radio_if_grc |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 27 | |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 28 | class radio_if(radio_if_grc): |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 29 | # Application state flags |
| 30 | trx_started = False |
Vadim Yanitskiy | 89aa469 | 2017-11-14 00:15:20 +0700 | [diff] [blame] | 31 | |
Vadim Yanitskiy | 790b6f0 | 2017-10-17 11:47:36 +0700 | [diff] [blame] | 32 | def __init__(self, phy_args, phy_sample_rate, |
| 33 | phy_rx_gain, phy_tx_gain, phy_ppm, |
| 34 | phy_rx_antenna, phy_tx_antenna, |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 35 | trx_remote_addr, trx_base_port, |
| 36 | phy_tx_freq=938900000, |
| 37 | phy_rx_freq=938900000-45e6, |
| 38 | delay_correction=285.616e-6, |
| 39 | uplink_shift=-(6.0/1625000*(156.25)*3), |
| 40 | timing_advance=0): |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 41 | |
Vadim Yanitskiy | 790b6f0 | 2017-10-17 11:47:36 +0700 | [diff] [blame] | 42 | print("[i] Init Radio interface") |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 43 | |
Piotr Krysik | d2f162f | 2017-11-30 12:50:00 +0100 | [diff] [blame] | 44 | radio_if_grc.__init__(self, |
| 45 | samp_rate=phy_sample_rate, |
| 46 | tx_gain=phy_tx_gain, rx_gain=phy_rx_gain, |
| 47 | tx_freq=phy_tx_freq, rx_freq=phy_rx_freq, |
| 48 | osr=4, ppm=phy_ppm, |
| 49 | trx_base_port=str(trx_base_port), |
| 50 | trx_remote_addr=trx_remote_addr, |
| 51 | delay_correction=delay_correction, |
| 52 | uplink_shift=uplink_shift, |
| 53 | timing_advance=timing_advance) |
Piotr Krysik | 902f4eb | 2017-09-19 08:04:33 +0200 | [diff] [blame] | 54 | |
| 55 | def shutdown(self): |
| 56 | print("[i] Shutdown Radio interface") |
| 57 | self.stop() |
| 58 | self.wait() |
| 59 | |