From 55d1c4d7038045c63f29056adfa0dae220c49439 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Wed, 16 Jan 2013 22:50:04 +0100 Subject: host/layer23: Initial import of the transceiver application Build is optional because it depends on some extra libraries Signed-off-by: Sylvain Munaut --- src/host/layer23/src/transceiver/main.c | 101 ++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/host/layer23/src/transceiver/main.c (limited to 'src/host/layer23/src/transceiver/main.c') diff --git a/src/host/layer23/src/transceiver/main.c b/src/host/layer23/src/transceiver/main.c new file mode 100644 index 00000000..3b7281dd --- /dev/null +++ b/src/host/layer23/src/transceiver/main.c @@ -0,0 +1,101 @@ +/* + * main.c + * + * Tranceiver main program + * + * Copyright (C) 2013 Sylvain Munaut + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include +#include + +#include + +#include "app.h" +#include "l1ctl.h" +#include "l1ctl_link.h" +#include "trx.h" +#include "gmsk.h" +#include "gsm_ab.h" + + +void *l23_ctx = NULL; + + +int main(int argc, char *argv[]) +{ + struct app_state _as, *as = &_as; + int rv; + + /* Options */ + if (argc != 2) { + fprintf(stderr, "Usage: %s arfcn_sync\n", argv[0]); + return -1; + } + + /* App state init */ + memset(as, 0x00, sizeof(struct app_state)); + + as->arfcn_sync = atoi(argv[1]); + printf("%d\n", as->arfcn_sync); + + /* Init talloc */ + l23_ctx = talloc_named_const(NULL, 1, "l23 app context"); + + /* Init logging */ + log_init(&log_info, l23_ctx); + + as->stderr_target = log_target_create_stderr(); + + log_add_target(as->stderr_target); + log_set_all_filter(as->stderr_target, 1); + + /* Init signal processing */ + /* Init GMSK tables */ + as->gs = osmo_gmsk_init(1); + if (!as->gs) + exit(-1); + + /* Init AB corr seq */ + as->train_ab = osmo_gmsk_trainseq_generate(as->gs, gsm_ab_train, GSM_AB_TRAIN_LEN); + if (!as->train_ab) + exit(-1); + + /* TRX interface with OpenBTS */ + as->trx = trx_alloc("127.0.0.1", 5700, &as->l1l); + if (!as->trx) + exit(-1); + + /* Establish l1ctl link */ + rv = l1l_open(&as->l1l, "/tmp/osmocom_l2", l1ctl_recv, as); + if (rv) + exit(-1); + + /* Reset phone */ + l1ctl_tx_reset_req(&as->l1l, L1CTL_RES_T_FULL); + + /* Main loop */ + while (1) { + osmo_select_main(0); + } + + return 0; +} -- cgit v1.2.3