1 /* "Application" code of the layer2/3 stack */
3 /* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <osmocom/bb/common/osmocom_data.h>
29 #include <osmocom/bb/common/l1ctl.h>
30 #include <osmocom/bb/common/l23_app.h>
31 #include <osmocom/bb/common/logging.h>
32 #include <osmocom/bb/common/gps.h>
33 #include <osmocom/bb/misc/cell_log.h>
35 #include <osmocore/talloc.h>
36 #include <osmocore/utils.h>
38 extern struct log_target *stderr_target;
41 char *logname = "/var/log/osmocom.log";
44 int _scan_work(struct osmocom_ms *ms)
49 int _scan_exit(struct osmocom_ms *ms)
51 /* in case there is a lockup during exit */
52 signal(SIGINT, SIG_DFL);
53 signal(SIGHUP, SIG_DFL);
54 signal(SIGTERM, SIG_DFL);
55 signal(SIGPIPE, SIG_DFL);
62 int l23_app_init(struct osmocom_ms *ms)
68 // log_parse_category_mask(stderr_target, "DL1C:DRSL:DRR:DGPS:DSUM");
69 log_parse_category_mask(stderr_target, "DSUM");
70 log_set_log_level(stderr_target, LOGL_INFO);
72 l23_app_work = _scan_work;
73 l23_app_exit = _scan_exit;
79 l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
80 printf("Mobile initialized, please start phone now!\n");
84 static int l23_cfg_supported()
86 return L23_OPT_TAP | L23_OPT_DBG;
89 static int l23_getopt_options(struct option **options)
91 static struct option opts [] = {
92 {"logfile", 1, 0, 'l'},
94 {"no-rach", 1, 0, 'n'},
100 return ARRAY_SIZE(opts);
103 static int l23_cfg_print_help()
105 printf("\nApplication specific\n");
106 printf(" -l --logfile LOGFILE Logfile for the cell log.\n");
107 printf(" -r --rach RACH Nr. of RACH bursts to send.\n");
108 printf(" -n --no-rach Send no rach bursts.\n");
109 printf(" -g --gps DEVICE /dev/ttyACM0. GPS device.\n");
110 printf(" -b --baud BAUDRAT The baud rate of the GPS device\n");
114 static int l23_cfg_handle(int c, const char *optarg)
118 logname = talloc_strdup(l23_ctx, optarg);
121 RACH_MAX = atoi(optarg);
127 snprintf(gps.device, ARRAY_SIZE(gps.device), "%s", optarg);
128 /* force string terminator */
129 gps.device[ARRAY_SIZE(gps.device) - 1] = '\0';
130 LOGP(DGPS, LOGL_INFO, "Using GPS device %s\n", gps.device);
133 gps.baud = atoi(optarg);
134 LOGP(DGPS, LOGL_INFO, "Setting GPS baudrate to %u\n", gps.baud);
141 static struct l23_app_info info = {
142 .copyright = "Copyright (C) 2010 Andreas Eversberg\n",
143 .getopt_string = "l:r:ng:b:",
144 .cfg_supported = l23_cfg_supported,
145 .cfg_getopt_opt = l23_getopt_options,
146 .cfg_handle_opt = l23_cfg_handle,
147 .cfg_print_help = l23_cfg_print_help,
150 struct l23_app_info *l23_app_info()