2011-10-12 07:44:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Free Software Foundation, Inc.
|
|
|
|
*
|
2019-10-13 17:08:00 +00:00
|
|
|
* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribution.
|
2011-10-12 07:44:40 +00:00
|
|
|
*
|
|
|
|
* This use of this software may be subject to additional restrictions.
|
|
|
|
* See the LEGAL file in the main directory for details.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-11-26 03:18:30 +00:00
|
|
|
#ifndef SIGPROCLIB_H
|
|
|
|
#define SIGPROCLIB_H
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
#include "Vector.h"
|
|
|
|
#include "Complex.h"
|
2013-06-16 10:30:58 +00:00
|
|
|
#include "BitVector.h"
|
2013-11-09 19:30:41 +00:00
|
|
|
#include "signalVector.h"
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2016-03-06 11:44:34 +00:00
|
|
|
/* Burst lengths */
|
2017-03-17 23:03:17 +00:00
|
|
|
#define NORMAL_BURST_NBITS 148
|
|
|
|
#define EDGE_BURST_NBITS 444
|
|
|
|
#define EDGE_BURST_NSYMS (EDGE_BURST_NBITS / 3)
|
2016-03-06 11:44:34 +00:00
|
|
|
|
2017-03-17 22:00:34 +00:00
|
|
|
/** Codes for burst types of received bursts*/
|
|
|
|
enum CorrType{
|
|
|
|
OFF, ///< timeslot is off
|
|
|
|
TSC, ///< timeslot should contain a normal burst
|
2018-10-22 00:25:23 +00:00
|
|
|
EXT_RACH, ///< timeslot should contain an extended access burst
|
2017-03-17 22:00:34 +00:00
|
|
|
RACH, ///< timeslot should contain an access burst
|
2024-02-21 18:33:09 +00:00
|
|
|
SCH,
|
2017-03-17 22:00:34 +00:00
|
|
|
EDGE, ///< timeslot should contain an EDGE burst
|
|
|
|
IDLE ///< timeslot is an idle (or dummy) burst
|
|
|
|
};
|
|
|
|
|
2017-03-17 22:23:06 +00:00
|
|
|
enum SignalError {
|
2015-05-18 20:57:54 +00:00
|
|
|
SIGERR_NONE,
|
|
|
|
SIGERR_BOUNDS,
|
|
|
|
SIGERR_CLIP,
|
|
|
|
SIGERR_UNSUPPORTED,
|
|
|
|
SIGERR_INTERNAL,
|
|
|
|
};
|
|
|
|
|
2017-03-17 22:29:09 +00:00
|
|
|
/*
|
|
|
|
* Burst detection threshold
|
|
|
|
*
|
|
|
|
* Decision threshold value for burst gating on peak-to-average value of
|
|
|
|
* correlated synchronization sequences. Lower values pass more bursts up
|
|
|
|
* to upper layers but will increase the false detection rate.
|
|
|
|
*/
|
|
|
|
#define BURST_THRESH 4.0
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
/** Setup the signal processing library */
|
2016-03-06 08:58:56 +00:00
|
|
|
bool sigProcLibSetup();
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
/** Destroy the signal processing library */
|
|
|
|
void sigProcLibDestroy(void);
|
|
|
|
|
2017-03-18 00:22:33 +00:00
|
|
|
/** Operate soft slicer on a soft-bit vector */
|
2019-07-01 15:55:01 +00:00
|
|
|
void vectorSlicer(float *dest, const float *src, size_t len);
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
/** GMSK modulate a GSM burst of bits */
|
|
|
|
signalVector *modulateBurst(const BitVector &wBurst,
|
2017-03-17 23:03:17 +00:00
|
|
|
int guardPeriodLength,
|
|
|
|
int sps, bool emptyPulse = false);
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2016-03-06 11:08:01 +00:00
|
|
|
/** 8-PSK modulate a burst of bits */
|
|
|
|
signalVector *modulateEdgeBurst(const BitVector &bits,
|
|
|
|
int sps, bool emptyPulse = false);
|
|
|
|
|
|
|
|
/** Generate a EDGE burst with random payload - 4 SPS (625 samples) only */
|
|
|
|
signalVector *generateEdgeBurst(int tsc);
|
|
|
|
|
2016-03-07 04:57:34 +00:00
|
|
|
/** Generate an empty burst - 4 or 1 SPS */
|
|
|
|
signalVector *generateEmptyBurst(int sps, int tn);
|
|
|
|
|
|
|
|
/** Generate a normal GSM burst with random payload - 4 or 1 SPS */
|
|
|
|
signalVector *genRandNormalBurst(int tsc, int sps, int tn);
|
|
|
|
|
2016-03-23 14:06:32 +00:00
|
|
|
/** Generate an access GSM burst with random payload - 4 or 1 SPS */
|
2016-03-25 15:28:34 +00:00
|
|
|
signalVector *genRandAccessBurst(int delay, int sps, int tn);
|
2016-03-23 14:06:32 +00:00
|
|
|
|
2016-03-07 04:57:34 +00:00
|
|
|
/** Generate a dummy GSM burst - 4 or 1 SPS */
|
|
|
|
signalVector *generateDummyBurst(int sps, int tn);
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
/**
|
|
|
|
Apply a scalar to a vector.
|
|
|
|
@param x The vector of interest.
|
|
|
|
@param scale The scalar.
|
|
|
|
*/
|
|
|
|
void scaleVector(signalVector &x,
|
2017-03-17 23:03:17 +00:00
|
|
|
complex scale);
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2024-02-21 18:33:09 +00:00
|
|
|
signalVector *delayVector(const signalVector *in, signalVector *out, float delay);
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
/**
|
2017-03-15 20:23:36 +00:00
|
|
|
Rough energy estimator.
|
|
|
|
@param rxBurst A GSM burst.
|
2011-10-12 07:44:40 +00:00
|
|
|
@param windowLength The number of burst samples used to compute burst energy
|
2017-03-15 20:23:36 +00:00
|
|
|
@return The average power of the received burst.
|
2011-10-12 07:44:40 +00:00
|
|
|
*/
|
2017-03-18 05:35:02 +00:00
|
|
|
float energyDetect(const signalVector &rxBurst,
|
2017-03-15 20:23:36 +00:00
|
|
|
unsigned windowLength);
|
2019-07-04 11:02:12 +00:00
|
|
|
|
|
|
|
/** Struct used to fill out parameters in detectAnyBurst(): estimated burst parameters
|
|
|
|
@param amplitude The estimated amplitude of received TSC burst.
|
|
|
|
@param toa The estimated time-of-arrival of received TSC burst (in symbols).
|
2019-07-04 14:27:47 +00:00
|
|
|
@param tsc The TSC used to detect the burst.
|
2019-07-04 11:02:12 +00:00
|
|
|
*/
|
|
|
|
struct estim_burst_params {
|
|
|
|
complex amp;
|
|
|
|
float toa;
|
2019-07-04 14:27:47 +00:00
|
|
|
uint8_t tsc;
|
2019-05-14 16:23:29 +00:00
|
|
|
float ci;
|
2019-07-04 11:02:12 +00:00
|
|
|
};
|
2017-03-17 22:24:18 +00:00
|
|
|
/**
|
|
|
|
8-PSK/GMSK/RACH burst detector
|
|
|
|
@param burst The received GSM burst of interest
|
|
|
|
@param tsc Midamble type (0..7) also known as TSC
|
|
|
|
@param threshold The threshold that the received burst's post-correlator SNR is compared against to determine validity.
|
|
|
|
@param sps The number of samples per GSM symbol.
|
|
|
|
@param max_toa The maximum expected time-of-arrival (in symbols).
|
2019-07-04 11:02:12 +00:00
|
|
|
@param ebp The estimated parameters of the detected burst.
|
2017-03-17 22:24:18 +00:00
|
|
|
@return positive value (CorrType) if threshold value is reached,
|
|
|
|
negative value (-SignalError) on error,
|
|
|
|
zero (SIGERR_NONE) if no burst is detected
|
|
|
|
*/
|
2017-03-18 05:35:02 +00:00
|
|
|
int detectAnyBurst(const signalVector &burst,
|
2017-03-17 22:24:18 +00:00
|
|
|
unsigned tsc,
|
|
|
|
float threshold,
|
|
|
|
int sps,
|
|
|
|
CorrType type,
|
2019-07-04 11:02:12 +00:00
|
|
|
unsigned max_toa,
|
|
|
|
struct estim_burst_params *ebp);
|
2017-03-17 22:24:18 +00:00
|
|
|
|
2024-02-21 18:33:09 +00:00
|
|
|
enum class sch_detect_type {
|
|
|
|
SCH_DETECT_FULL,
|
|
|
|
SCH_DETECT_NARROW,
|
|
|
|
SCH_DETECT_BUFFER,
|
|
|
|
};
|
|
|
|
|
|
|
|
int detectSCHBurst(signalVector &rxBurst,
|
|
|
|
float detectThreshold,
|
|
|
|
int sps,
|
|
|
|
sch_detect_type state, struct estim_burst_params *ebp);
|
|
|
|
|
2017-03-17 23:13:51 +00:00
|
|
|
/** Demodulate burst basde on type and output soft bits */
|
2021-02-04 19:37:01 +00:00
|
|
|
SoftVector *demodAnyBurst(const signalVector &burst, CorrType type,
|
|
|
|
int sps, struct estim_burst_params *ebp);
|
2017-03-17 23:13:51 +00:00
|
|
|
|
2011-11-26 03:18:30 +00:00
|
|
|
#endif /* SIGPROCLIB_H */
|