Merge branch 'zecke/calib-pch-agch-follow'
Introduce bcch_ccch to scan the PCH on top of the BCCH. The AGCH is included in the PCH. CBCH/NCH are not included at this point.
This commit is contained in:
commit
dc9148d035
|
@ -1,5 +1,5 @@
|
|||
CFLAGS=`pkg-config --cflags libosmocore` -Wall -Werror
|
||||
LIBS=`pkg-config --libs libosmocore`
|
||||
LIBS=`pkg-config --libs libosmocore libosmogsm`
|
||||
|
||||
all: sysmobts-calib
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <sysmocom/femtobts/superfemto.h>
|
||||
#include <sysmocom/femtobts/gsml1types.h>
|
||||
|
||||
#include <osmocom/gsm/gsm_utils.h>
|
||||
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
#include "sysmobts-layer1.h"
|
||||
|
@ -41,12 +43,14 @@ enum actions {
|
|||
ACTION_SCAN,
|
||||
ACTION_CALIB,
|
||||
ACTION_BCCH,
|
||||
ACTION_BCCH_CCCH,
|
||||
};
|
||||
|
||||
static const char *modes[] = {
|
||||
[ACTION_SCAN] = "scan",
|
||||
[ACTION_CALIB] = "calibrate",
|
||||
[ACTION_BCCH] = "bcch",
|
||||
[ACTION_BCCH_CCCH] = "bcch_ccch",
|
||||
};
|
||||
|
||||
static const char *bands[] = {
|
||||
|
@ -80,6 +84,32 @@ static const char *clk_source[] = {
|
|||
[SuperFemto_ClkSrcId_NetList] = "netlisten",
|
||||
};
|
||||
|
||||
static const struct value_string sapi_names[GsmL1_Sapi_NUM+1] = {
|
||||
{ GsmL1_Sapi_Fcch, "FCCH" },
|
||||
{ GsmL1_Sapi_Sch, "SCH" },
|
||||
{ GsmL1_Sapi_Sacch, "SACCH" },
|
||||
{ GsmL1_Sapi_Sdcch, "SDCCH" },
|
||||
{ GsmL1_Sapi_Bcch, "BCCH" },
|
||||
{ GsmL1_Sapi_Pch, "PCH" },
|
||||
{ GsmL1_Sapi_Agch, "AGCH" },
|
||||
{ GsmL1_Sapi_Cbch, "CBCH" },
|
||||
{ GsmL1_Sapi_Rach, "RACH" },
|
||||
{ GsmL1_Sapi_TchF, "TCH/F" },
|
||||
{ GsmL1_Sapi_FacchF, "FACCH/F" },
|
||||
{ GsmL1_Sapi_TchH, "TCH/H" },
|
||||
{ GsmL1_Sapi_FacchH, "FACCH/H" },
|
||||
{ GsmL1_Sapi_Nch, "NCH" },
|
||||
{ GsmL1_Sapi_Pdtch, "PDTCH" },
|
||||
{ GsmL1_Sapi_Pacch, "PACCH" },
|
||||
{ GsmL1_Sapi_Pbcch, "PBCCH" },
|
||||
{ GsmL1_Sapi_Pagch, "PAGCH" },
|
||||
{ GsmL1_Sapi_Ppch, "PPCH" },
|
||||
{ GsmL1_Sapi_Pnch, "PNCH" },
|
||||
{ GsmL1_Sapi_Ptcch, "PTCCH" },
|
||||
{ GsmL1_Sapi_Prach, "PRACH" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static int action = ACTION_SCAN;
|
||||
static int band = GsmL1_FreqBand_900;
|
||||
static int calib = SuperFemto_ClkSrcId_Ocxo;
|
||||
|
@ -102,7 +132,7 @@ static void print_help(void)
|
|||
printf(" -s --calibration-source "
|
||||
"ocxo|tcxo|external|gps|trx|rx|edge|netlisten\n");
|
||||
printf(" -b --band 850|900|1800|1900\n");
|
||||
printf(" -m --mode scan|calibrate|bcch\n");
|
||||
printf(" -m --mode scan|calibrate|bcch|bcch_ccch\n");
|
||||
printf(" -a --arfcn NR arfcn for calibration\n");
|
||||
printf(" -d --dsp-flags NR dsp mask for debug log\n");
|
||||
printf(" -t --threshold level\n");
|
||||
|
@ -432,16 +462,31 @@ static int bcch_follow(void)
|
|||
rc = follow_bcch(layer1);
|
||||
CHECK_RC_MSG(rc, "Follow BCCH");
|
||||
|
||||
/* follow the pch */
|
||||
if (action == ACTION_BCCH_CCCH) {
|
||||
rc = follow_pch(layer1);
|
||||
CHECK_RC_MSG(rc, "Follow BCCH/CCCH");
|
||||
}
|
||||
|
||||
/* now wait for the PhDataInd */
|
||||
for (;;) {
|
||||
uint32_t fn;
|
||||
uint8_t block;
|
||||
uint8_t data[23];
|
||||
size_t size;
|
||||
struct gsm_time gsmtime;
|
||||
GsmL1_Sapi_t sapi;
|
||||
|
||||
rc = wait_for_data(data, &size);
|
||||
rc = wait_for_data(data, &size, &fn, &block, &sapi);
|
||||
if (rc == 1)
|
||||
continue;
|
||||
CHECK_RC_MSG(rc, "No Data Indication");
|
||||
printf("Data: %s\n", osmo_hexdump(data, size));
|
||||
|
||||
gsm_fn2gsmtime(&gsmtime, fn);
|
||||
printf("%02u/%02u/%02u %6s %s\n",
|
||||
gsmtime.t1, gsmtime.t2, gsmtime.t3,
|
||||
get_value_string(sapi_names, sapi),
|
||||
osmo_hexdump(data, size));
|
||||
}
|
||||
|
||||
rc = mph_close(layer1);
|
||||
|
@ -470,7 +515,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if (action == ACTION_SCAN)
|
||||
return scan_band();
|
||||
else if (action == ACTION_BCCH)
|
||||
else if (action == ACTION_BCCH || action == ACTION_BCCH_CCCH)
|
||||
return bcch_follow();
|
||||
else {
|
||||
if (source == SuperFemto_ClkSrcId_NetList)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Layer1 handling for the DSP/FPGA */
|
||||
/*
|
||||
* (C) 2012 Holger Hans Peter Freyther
|
||||
* (C) 2012-2013 Holger Hans Peter Freyther
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
|
@ -481,16 +481,16 @@ int follow_sch(int band, int arfcn, int clock, int ref, HANDLE *layer1)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int follow_bcch(HANDLE layer1)
|
||||
static int follow_sapi(HANDLE layer1, const GsmL1_Sapi_t sapi)
|
||||
{
|
||||
int rc;
|
||||
GsmL1_Prim_t prim;
|
||||
|
||||
/* 1.) Activate BCCH... */
|
||||
/* 1.) Activate BCCH or such... */
|
||||
memset(&prim, 0, sizeof(prim));
|
||||
prim.u.mphActivateReq.hLayer1 = layer1;
|
||||
prim.u.mphActivateReq.u8Tn = 0;
|
||||
prim.u.mphActivateReq.sapi = GsmL1_Sapi_Bcch;
|
||||
prim.u.mphActivateReq.sapi = sapi;
|
||||
prim.u.mphActivateReq.dir = GsmL1_Dir_RxDownlink;
|
||||
|
||||
rc = send_recv_sig_prim(GsmL1_PrimId_MphActivateReq, &prim);
|
||||
|
@ -511,23 +511,33 @@ int follow_bcch(HANDLE layer1)
|
|||
return rc;
|
||||
}
|
||||
|
||||
if (prim.u.phConnectInd.sapi != GsmL1_Sapi_Bcch) {
|
||||
if (prim.u.phConnectInd.sapi != sapi) {
|
||||
printf("Got a connect indication for the wrong type: %d\n",
|
||||
prim.u.phConnectInd.sapi);
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* 3.) Wait for PhDataInd... */
|
||||
printf("Waiting for BCCH data.\n");
|
||||
printf("Waiting for data.\n");
|
||||
rc = wait_for_indication(GsmL1_PrimId_PhDataInd, &prim);
|
||||
if (rc != 0) {
|
||||
printf("Didn't get BCCH data.\n");
|
||||
printf("Didn't get data.\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int follow_bcch(HANDLE layer1)
|
||||
{
|
||||
return follow_sapi(layer1, GsmL1_Sapi_Bcch);
|
||||
}
|
||||
|
||||
int follow_pch(HANDLE layer1)
|
||||
{
|
||||
return follow_sapi(layer1, GsmL1_Sapi_Pch);
|
||||
}
|
||||
|
||||
int find_bsic(void)
|
||||
{
|
||||
int rc, i;
|
||||
|
@ -701,7 +711,7 @@ int wait_for_sync(HANDLE layer1, int cor, int calib, int source)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int wait_for_data(uint8_t *data, size_t *size)
|
||||
int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block, GsmL1_Sapi_t *sap)
|
||||
{
|
||||
GsmL1_Prim_t prim;
|
||||
int rc;
|
||||
|
@ -713,6 +723,9 @@ int wait_for_data(uint8_t *data, size_t *size)
|
|||
return 1;
|
||||
|
||||
*size = prim.u.phDataInd.msgUnitParam.u8Size;
|
||||
*fn = prim.u.phDataInd.u32Fn;
|
||||
*block = prim.u.phDataInd.u8BlockNbr;
|
||||
*sap = prim.u.phDataInd.sapi;
|
||||
memcpy(data, prim.u.phDataInd.msgUnitParam.u8Buffer, *size);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ extern int rf_clock_info(int *clkErr, int *clkErrRes);
|
|||
extern int mph_close(HANDLE layer1);
|
||||
extern int wait_for_sync(HANDLE layer1, int cor, int calib, int source);
|
||||
extern int follow_bcch(HANDLE layer1);
|
||||
extern int wait_for_data(uint8_t *data, size_t *size);
|
||||
extern int follow_pch(HANDLE layer1);
|
||||
extern int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block, GsmL1_Sapi_t *sapi);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue