diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am index 5d116f96..613af1e7 100644 --- a/CommonLibs/Makefile.am +++ b/CommonLibs/Makefile.am @@ -52,4 +52,5 @@ noinst_HEADERS = \ Vector.h \ Logger.h \ trx_vty.h \ - debug.h + debug.h \ + config_defs.h diff --git a/CommonLibs/config_defs.h b/CommonLibs/config_defs.h new file mode 100644 index 00000000..86261668 --- /dev/null +++ b/CommonLibs/config_defs.h @@ -0,0 +1,20 @@ +#pragma once + +/* + * This file contains structures used by both VTY (C, dir CommonLibs) and + * osmo-trx (CXX, dir Transceiver52) + */ + +enum FillerType { + FILLER_DUMMY, + FILLER_ZERO, + FILLER_NORM_RAND, + FILLER_EDGE_RAND, + FILLER_ACCESS_RAND, +}; + +enum ReferenceType { + REF_INTERNAL, + REF_EXTERNAL, + REF_GPS, +}; diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index d9c231d6..8ebd9ed6 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -71,7 +71,7 @@ TransceiverState::~TransceiverState() } } -bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay) +bool TransceiverState::init(FillerType filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay) { signalVector *burst; @@ -81,19 +81,19 @@ bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc, un for (size_t n = 0; n < 8; n++) { for (size_t i = 0; i < 102; i++) { switch (filler) { - case Transceiver::FILLER_DUMMY: + case FILLER_DUMMY: burst = generateDummyBurst(sps, n); break; - case Transceiver::FILLER_NORM_RAND: + case FILLER_NORM_RAND: burst = genRandNormalBurst(rtsc, sps, n); break; - case Transceiver::FILLER_EDGE_RAND: + case FILLER_EDGE_RAND: burst = generateEdgeBurst(rtsc); break; - case Transceiver::FILLER_ACCESS_RAND: + case FILLER_ACCESS_RAND: burst = genRandAccessBurst(rach_delay, sps, n); break; - case Transceiver::FILLER_ZERO: + case FILLER_ZERO: default: burst = generateEmptyBurst(sps, n); } @@ -102,8 +102,8 @@ bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc, un fillerTable[i][n] = burst; } - if ((filler == Transceiver::FILLER_NORM_RAND) || - (filler == Transceiver::FILLER_EDGE_RAND)) { + if ((filler == FILLER_NORM_RAND) || + (filler == FILLER_EDGE_RAND)) { chanType[n] = TSC; } } @@ -161,7 +161,7 @@ Transceiver::~Transceiver() * are still expected to report clock indications through control channel * activity. */ -bool Transceiver::init(int filler, size_t rtsc, unsigned rach_delay, bool edge) +bool Transceiver::init(FillerType filler, size_t rtsc, unsigned rach_delay, bool edge) { int d_srcport, d_dstport, c_srcport, c_dstport; diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h index ad7a4698..f9b54f03 100644 --- a/Transceiver52M/Transceiver.h +++ b/Transceiver52M/Transceiver.h @@ -30,6 +30,10 @@ #include #include +extern "C" { +#include "config_defs.h" +} + class Transceiver; /** Channel descriptor for transceiver object and channel number pair */ @@ -54,7 +58,7 @@ struct TransceiverState { ~TransceiverState(); /* Initialize a multiframe slot in the filler table */ - bool init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay); + bool init(FillerType filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay); int chanType[8]; @@ -109,7 +113,7 @@ public: ~Transceiver(); /** Start the control loop */ - bool init(int filler, size_t rtsc, unsigned rach_delay, bool edge); + bool init(FillerType filler, size_t rtsc, unsigned rach_delay, bool edge); /** attach the radioInterface receive FIFO */ bool receiveFIFO(VectorFIFO *wFIFO, size_t chan) @@ -144,14 +148,6 @@ public: LOOPBACK ///< similar go VII, used in loopback testing } ChannelCombination; - enum FillerType { - FILLER_DUMMY, - FILLER_ZERO, - FILLER_NORM_RAND, - FILLER_EDGE_RAND, - FILLER_ACCESS_RAND, - }; - private: int mBasePort; std::string mLocalAddr; diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index db0a8138..dc4e1c8e 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -91,7 +91,7 @@ struct trx_config { unsigned rach_delay; bool extref; bool gpsref; - Transceiver::FillerType filler; + FillerType filler; bool mcbts; double offset; double rssi_offset; @@ -140,19 +140,19 @@ bool trx_setup_config(struct trx_config *config) refstr = "Internal"; switch (config->filler) { - case Transceiver::FILLER_DUMMY: + case FILLER_DUMMY: fillstr = "Dummy bursts"; break; - case Transceiver::FILLER_ZERO: + case FILLER_ZERO: fillstr = "Disabled"; break; - case Transceiver::FILLER_NORM_RAND: + case FILLER_NORM_RAND: fillstr = "Normal busrts with random payload"; break; - case Transceiver::FILLER_EDGE_RAND: + case FILLER_EDGE_RAND: fillstr = "EDGE busrts with random payload"; break; - case Transceiver::FILLER_ACCESS_RAND: + case FILLER_ACCESS_RAND: fillstr = "Access busrts with random payload"; break; } @@ -348,7 +348,7 @@ static void handle_options(int argc, char **argv, struct trx_config *config) config->rach_delay = 0; config->extref = false; config->gpsref = false; - config->filler = Transceiver::FILLER_ZERO; + config->filler = FILLER_ZERO; config->mcbts = false; config->offset = 0.0; config->rssi_offset = 0.0; @@ -389,7 +389,7 @@ static void handle_options(int argc, char **argv, struct trx_config *config) config->gpsref = true; break; case 'f': - config->filler = Transceiver::FILLER_DUMMY; + config->filler = FILLER_DUMMY; break; case 'o': config->offset = atof(optarg); @@ -402,11 +402,11 @@ static void handle_options(int argc, char **argv, struct trx_config *config) break; case 'r': config->rtsc = atoi(optarg); - config->filler = Transceiver::FILLER_NORM_RAND; + config->filler = FILLER_NORM_RAND; break; case 'A': config->rach_delay = atoi(optarg); - config->filler = Transceiver::FILLER_ACCESS_RAND; + config->filler = FILLER_ACCESS_RAND; break; case 'R': config->rssi_offset = atof(optarg); @@ -448,8 +448,8 @@ static void handle_options(int argc, char **argv, struct trx_config *config) goto bad_config; } - if (config->edge && (config->filler == Transceiver::FILLER_NORM_RAND)) - config->filler = Transceiver::FILLER_EDGE_RAND; + if (config->edge && (config->filler == FILLER_NORM_RAND)) + config->filler = FILLER_EDGE_RAND; if ((config->tx_sps != 1) && (config->tx_sps != 4) && (config->rx_sps != 1) && (config->rx_sps != 4)) { @@ -521,11 +521,11 @@ static int trx_start(struct trx_config *config) iface = RadioDevice::MULTI_ARFCN; if (config->extref) - ref = RadioDevice::REF_EXTERNAL; + ref = REF_EXTERNAL; else if (config->gpsref) - ref = RadioDevice::REF_GPS; + ref = REF_GPS; else - ref = RadioDevice::REF_INTERNAL; + ref = REF_INTERNAL; usrp = RadioDevice::make(config->tx_sps, config->rx_sps, iface, config->chans, config->offset, config->tx_paths, config->rx_paths); diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index dfa1c78f..9913de00 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -18,6 +18,10 @@ #include #include +extern "C" { +#include "config_defs.h" +} + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -43,12 +47,6 @@ class RadioDevice { MULTI_ARFCN, }; - enum ReferenceType { - REF_INTERNAL, - REF_EXTERNAL, - REF_GPS, - }; - static RadioDevice *make(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chans = 1, double offset = 0.0, const std::vector& tx_paths = std::vector(1, ""),