summaryrefslogtreecommitdiff
path: root/gsm-receiver
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-10-23 22:04:18 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-30 11:09:53 +0200
commit3ac3890567168dacf833842cf483e3608c7a077c (patch)
tree9b16a70b75fa82fd24ff68beca5df37613b38716 /gsm-receiver
parentef32a064f327e8ef3fb6d246eb0e515fa67173ab (diff)
gsm-receiver: EFR Support [3/3] Add option in gsm-receiver to use EFR
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'gsm-receiver')
-rw-r--r--gsm-receiver/src/lib/gsm_receiver_cf.cc35
-rw-r--r--gsm-receiver/src/lib/gsm_receiver_cf.h9
2 files changed, 39 insertions, 5 deletions
diff --git a/gsm-receiver/src/lib/gsm_receiver_cf.cc b/gsm-receiver/src/lib/gsm_receiver_cf.cc
index 2660bdc..e7b8e81 100644
--- a/gsm-receiver/src/lib/gsm_receiver_cf.cc
+++ b/gsm-receiver/src/lib/gsm_receiver_cf.cc
@@ -146,18 +146,24 @@ void gsm_receiver_cf::read_configuration(std::string configuration)
printf(" Configuration TS: %d\n", ts);
+ d_tch_mode = TM_NONE;
if((char)configuration[1] == 'C')
d_gs_ctx.ts_ctx[ts].type = TST_FCCH_SCH_BCCH_CCCH_SDCCH4;
else if((char)configuration[1] == 'B')
d_gs_ctx.ts_ctx[ts].type = TST_FCCH_SCH_BCCH_CCCH;
else if((char)configuration[1] == 'S')
d_gs_ctx.ts_ctx[ts].type = TST_SDCCH8;
- else if((char)configuration[1] == 'T')
+ else if((char)configuration[1] == 'T') {
d_gs_ctx.ts_ctx[ts].type = TST_TCHF;
- else {
+ if((char)configuration[2] == 'E')
+ d_tch_mode = TM_SPEECH_EFR;
+ else
+ d_tch_mode = TM_SPEECH_FR;
+ } else {
printf(" Invalid configuration: %c\n", (char)configuration[1]);
return;
}
+
/* any other timeslot than 0: turn TS0 off */
if(ts != 0) {
d_gs_ctx.ts_ctx[0].type = TST_OFF;
@@ -205,7 +211,7 @@ void gsm_receiver_cf::process_normal_burst(burst_counter burst_nr, const unsigne
GSM::RxBurst rxbrst(decrypted_data_float, time);
if (ts - TIMESLOT1 >= 0 && ts - TIMESLOT1 < N_TCH_DECODER) {
if ( d_tch_decoder[ts - TIMESLOT1]->processBurst( rxbrst ) == true)
- fwrite(d_tch_decoder[ts - TIMESLOT1]->get_voice_frame(), 1 , 33, d_gsm_file);
+ fwrite(d_tch_decoder[ts - TIMESLOT1]->get_voice_frame(), 1 , d_tch_decoder[ts - TIMESLOT1]->get_voice_frame_length(), d_speech_file);
else if(rxbrst.Hl() || rxbrst.Hu()) {
/* Stolen bits are set, might be FACCH */
GS_process(&d_gs_ctx, TIMESLOT0 + ts, NORMAL, &decrypted_data[3], burst_nr.get_frame_nr(), first_burst);
@@ -310,6 +316,7 @@ gsm_receiver_cf::gsm_receiver_cf(gr_feval_dd *tuner, gr_feval_dd *synchronizer,
d_failed_sch(0),
d_trace_sch(true)
{
+ const unsigned char amr_nb_magic[6] = { 0x23, 0x21, 0x41, 0x4d, 0x52, 0x0a };
int i;
gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
for (i = 0; i < TRAIN_SEQ_NUM; i++) {
@@ -327,7 +334,6 @@ gsm_receiver_cf::gsm_receiver_cf(gr_feval_dd *tuner, gr_feval_dd *synchronizer,
for (i = 0; i < N_TCH_DECODER; i++)
d_tch_decoder[i] = new GSM::TCHFACCHL1Decoder(GSM::gFACCH_TCHFMapping);
- d_gsm_file = fopen( "speech.au.gsm", "wb" ); //!!
d_hex_to_int['0'] = 0; //!!
d_hex_to_int['4'] = 4; //!!
d_hex_to_int['8'] = 8; //!!
@@ -352,6 +358,27 @@ gsm_receiver_cf::gsm_receiver_cf(gr_feval_dd *tuner, gr_feval_dd *synchronizer,
/* configuration is stored in d_gs_ctx */
read_configuration(configuration);
+ /* open speech file and configure d_tch_decoders */
+ switch (d_tch_mode) {
+
+ case TM_SPEECH_FR:
+ d_speech_file = fopen( "speech.au.gsm", "wb" );
+ for (i = 0; i < N_TCH_DECODER; i++)
+ d_tch_decoder[i]->setMode(GSM::MODE_SPEECH_FR);
+ break;
+
+ case TM_SPEECH_EFR:
+ d_speech_file = fopen( "speech.amr", "wb" );
+ fwrite(amr_nb_magic, 1, 6, d_speech_file); /* Write header */
+ for (i = 0; i < N_TCH_DECODER; i++)
+ d_tch_decoder[i]->setMode(GSM::MODE_SPEECH_EFR);
+ break;
+
+ default:
+ d_speech_file = NULL;
+
+ }
+
configure_receiver();
}
diff --git a/gsm-receiver/src/lib/gsm_receiver_cf.h b/gsm-receiver/src/lib/gsm_receiver_cf.h
index d32ad4c..fef7882 100644
--- a/gsm-receiver/src/lib/gsm_receiver_cf.h
+++ b/gsm-receiver/src/lib/gsm_receiver_cf.h
@@ -57,10 +57,17 @@ class gsm_receiver_cf : public gr_block
{
private:
std::map<char,int> d_hex_to_int;
- FILE * d_gsm_file; //!!
+ FILE * d_speech_file; //!!
byte d_KC[8]; //!!
GSM::TCHFACCHL1Decoder *d_tch_decoder[N_TCH_DECODER]; //!!
bool d_trace_sch;
+
+ enum {
+ TM_NONE,
+ TM_SPEECH_FR,
+ TM_SPEECH_EFR,
+ } d_tch_mode;
+
/**@name Configuration of the receiver */
//@{
const int d_OSR; ///< oversampling ratio
personal git repositories of Harald Welte. Your mileage may vary