Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 1 | /* Siemens BS-11 microBTS configuration tool */ |
| 2 | |
Harald Welte | 5f5189e | 2010-12-14 13:14:32 +0100 | [diff] [blame] | 3 | /* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
Holger Hans Peter Freyther | acf8a0c | 2010-03-29 08:47:44 +0200 | [diff] [blame] | 6 | * This software is based on ideas (but not code) of BS11Config |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 7 | * (C) 2009 by Dieter Spaar <spaar@mirider.augusta.de> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 10 | * it under the terms of the GNU Affero General Public License as published by |
| 11 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * GNU Affero General Public License for more details. |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 18 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <unistd.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <stdio.h> |
| 27 | #include <errno.h> |
| 28 | #include <string.h> |
| 29 | #include <getopt.h> |
| 30 | #include <fcntl.h> |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 31 | #include <signal.h> |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 32 | |
| 33 | #include <sys/types.h> |
| 34 | #include <sys/stat.h> |
| 35 | |
| 36 | #include <openbsc/gsm_data.h> |
| 37 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 38 | #include <osmocom/core/msgb.h> |
| 39 | #include <osmocom/gsm/tlv.h> |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 40 | #include <openbsc/debug.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 41 | #include <osmocom/core/select.h> |
Harald Welte | 099d610 | 2009-02-21 12:59:58 +0000 | [diff] [blame] | 42 | #include <openbsc/rs232.h> |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 43 | |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 44 | /* state of our bs11_config application */ |
| 45 | enum bs11cfg_state { |
| 46 | STATE_NONE, |
| 47 | STATE_LOGON_WAIT, |
| 48 | STATE_LOGON_ACK, |
| 49 | STATE_SWLOAD, |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 50 | STATE_QUERY, |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 51 | }; |
| 52 | static enum bs11cfg_state bs11cfg_state = STATE_NONE; |
Daniel Willmann | 6a9fa73 | 2010-01-07 01:27:50 +0100 | [diff] [blame] | 53 | static char *command, *value; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 54 | struct timer_list status_timer; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 55 | |
Holger Hans Peter Freyther | acf8a0c | 2010-03-29 08:47:44 +0200 | [diff] [blame] | 56 | static const u_int8_t obj_li_attr[] = { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 57 | NM_ATT_BS11_BIT_ERR_THESH, 0x09, 0x00, |
Holger Hans Peter Freyther | acf8a0c | 2010-03-29 08:47:44 +0200 | [diff] [blame] | 58 | NM_ATT_BS11_L1_PROT_TYPE, 0x00, |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 59 | NM_ATT_BS11_LINE_CFG, 0x00, |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 60 | }; |
| 61 | static const u_int8_t obj_bbsig0_attr[] = { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 62 | NM_ATT_BS11_RSSI_OFFS, 0x02, 0x00, 0x00, |
| 63 | NM_ATT_BS11_DIVERSITY, 0x01, 0x00, |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 64 | }; |
| 65 | static const u_int8_t obj_pa0_attr[] = { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 66 | NM_ATT_BS11_TXPWR, 0x01, BS11_TRX_POWER_GSM_30mW, |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 67 | }; |
| 68 | static const char *trx1_password = "1111111111"; |
| 69 | #define TEI_OML 25 |
| 70 | |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 71 | static const u_int8_t too_fast[] = { 0x12, 0x80, 0x00, 0x00, 0x02, 0x02 }; |
| 72 | |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 73 | static struct log_target *stderr_target; |
Holger Hans Peter Freyther | b61e3b2 | 2009-12-22 22:32:51 +0100 | [diff] [blame] | 74 | |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 75 | /* dummy function to keep gsm_data.c happy */ |
| 76 | struct counter *counter_alloc(const char *name) |
| 77 | { |
| 78 | return NULL; |
| 79 | } |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 80 | |
Harald Welte | c12d52b | 2009-02-01 21:39:06 +0000 | [diff] [blame] | 81 | int handle_serial_msg(struct msgb *rx_msg); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 82 | |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 83 | /* create all objects for an initial configuration */ |
| 84 | static int create_objects(struct gsm_bts *bts) |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 85 | { |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 86 | fprintf(stdout, "Crating Objects for minimal config\n"); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 87 | abis_nm_bs11_create_object(bts, BS11_OBJ_LI, 0, sizeof(obj_li_attr), |
| 88 | obj_li_attr); |
| 89 | abis_nm_bs11_create_object(bts, BS11_OBJ_GPSU, 0, 0, NULL); |
| 90 | abis_nm_bs11_create_object(bts, BS11_OBJ_ALCO, 0, 0, NULL); |
Harald Welte | 623d531 | 2009-01-29 21:14:05 +0000 | [diff] [blame] | 91 | abis_nm_bs11_create_object(bts, BS11_OBJ_CCLK, 0, 0, NULL); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 92 | abis_nm_bs11_create_object(bts, BS11_OBJ_BBSIG, 0, |
| 93 | sizeof(obj_bbsig0_attr), obj_bbsig0_attr); |
| 94 | abis_nm_bs11_create_object(bts, BS11_OBJ_PA, 0, |
| 95 | sizeof(obj_pa0_attr), obj_pa0_attr); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 96 | abis_nm_bs11_create_envaBTSE(bts, 0); |
| 97 | abis_nm_bs11_create_envaBTSE(bts, 1); |
| 98 | abis_nm_bs11_create_envaBTSE(bts, 2); |
| 99 | abis_nm_bs11_create_envaBTSE(bts, 3); |
| 100 | |
Harald Welte | b6c92ae | 2009-02-21 20:15:32 +0000 | [diff] [blame] | 101 | abis_nm_bs11_conn_oml_tei(bts, 0, 1, 0xff, TEI_OML); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 102 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 103 | abis_nm_bs11_set_trx_power(bts->c0, BS11_TRX_POWER_GSM_30mW); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 104 | |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 105 | sleep(1); |
| 106 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 107 | abis_nm_bs11_set_trx1_pw(bts, trx1_password); |
| 108 | |
| 109 | sleep(1); |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static int create_trx1(struct gsm_bts *bts) |
| 115 | { |
| 116 | u_int8_t bbsig1_attr[sizeof(obj_bbsig0_attr)+12]; |
| 117 | u_int8_t *cur = bbsig1_attr; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 118 | struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, 1); |
| 119 | |
| 120 | if (!trx) |
| 121 | trx = gsm_bts_trx_alloc(bts); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 122 | |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 123 | fprintf(stdout, "Crating Objects for TRX1\n"); |
| 124 | |
| 125 | abis_nm_bs11_set_trx1_pw(bts, trx1_password); |
| 126 | |
| 127 | sleep(1); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 128 | |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 129 | cur = tlv_put(cur, NM_ATT_BS11_PASSWORD, 10, |
| 130 | (u_int8_t *)trx1_password); |
| 131 | memcpy(cur, obj_bbsig0_attr, sizeof(obj_bbsig0_attr)); |
| 132 | abis_nm_bs11_create_object(bts, BS11_OBJ_BBSIG, 1, |
| 133 | sizeof(bbsig1_attr), bbsig1_attr); |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 134 | abis_nm_bs11_create_object(bts, BS11_OBJ_PA, 1, |
| 135 | sizeof(obj_pa0_attr), obj_pa0_attr); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 136 | abis_nm_bs11_set_trx_power(trx, BS11_TRX_POWER_GSM_30mW); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 137 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | static char *serial_port = "/dev/ttyUSB0"; |
| 142 | static char *fname_safety = "BTSBMC76.SWI"; |
| 143 | static char *fname_software = "HS011106.SWL"; |
Harald Welte | 623d531 | 2009-01-29 21:14:05 +0000 | [diff] [blame] | 144 | static int delay_ms = 0; |
Harald Welte | 623d531 | 2009-01-29 21:14:05 +0000 | [diff] [blame] | 145 | static int win_size = 8; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 146 | static int param_disconnect = 0; |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 147 | static int param_restart = 0; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 148 | static int param_forced = 0; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 149 | static struct gsm_bts *g_bts; |
| 150 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 151 | static int file_is_readable(const char *fname) |
| 152 | { |
| 153 | int rc; |
| 154 | struct stat st; |
| 155 | |
| 156 | rc = stat(fname, &st); |
| 157 | if (rc < 0) |
| 158 | return 0; |
| 159 | |
| 160 | if (S_ISREG(st.st_mode) && (st.st_mode & S_IRUSR)) |
| 161 | return 1; |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 166 | static int percent; |
| 167 | static int percent_old; |
| 168 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 169 | /* callback function passed to the ABIS OML code */ |
| 170 | static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *msg, |
| 171 | void *data, void *param) |
| 172 | { |
| 173 | if (hook != GSM_HOOK_NM_SWLOAD) |
| 174 | return 0; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 175 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 176 | switch (event) { |
| 177 | case NM_MT_LOAD_INIT_ACK: |
| 178 | fprintf(stdout, "Software Load Initiate ACK\n"); |
| 179 | break; |
| 180 | case NM_MT_LOAD_INIT_NACK: |
| 181 | fprintf(stderr, "ERROR: Software Load Initiate NACK\n"); |
| 182 | exit(5); |
| 183 | break; |
| 184 | case NM_MT_LOAD_END_ACK: |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 185 | if (data) { |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 186 | /* we did a safety load and must activate it */ |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 187 | abis_nm_software_activate(g_bts, fname_safety, |
| 188 | swload_cbfn, g_bts); |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 189 | sleep(5); |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 190 | } |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 191 | break; |
| 192 | case NM_MT_LOAD_END_NACK: |
| 193 | fprintf(stderr, "ERROR: Software Load End NACK\n"); |
| 194 | exit(3); |
| 195 | break; |
| 196 | case NM_MT_ACTIVATE_SW_NACK: |
| 197 | fprintf(stderr, "ERROR: Activate Software NACK\n"); |
| 198 | exit(4); |
| 199 | break; |
| 200 | case NM_MT_ACTIVATE_SW_ACK: |
| 201 | bs11cfg_state = STATE_NONE; |
| 202 | |
| 203 | break; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 204 | case NM_MT_LOAD_SEG_ACK: |
| 205 | percent = abis_nm_software_load_status(g_bts); |
| 206 | if (percent > percent_old) |
| 207 | printf("Software Download Progress: %d%%\n", percent); |
| 208 | percent_old = percent; |
| 209 | break; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 210 | } |
| 211 | return 0; |
| 212 | } |
| 213 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 214 | static const char *bs11_link_state[] = { |
| 215 | [0x00] = "Down", |
| 216 | [0x01] = "Up", |
| 217 | [0x02] = "Restoring", |
| 218 | }; |
| 219 | |
| 220 | static const char *linkstate_name(u_int8_t linkstate) |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 221 | { |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 222 | if (linkstate > ARRAY_SIZE(bs11_link_state)) |
| 223 | return "Unknown"; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 224 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 225 | return bs11_link_state[linkstate]; |
| 226 | } |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 227 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 228 | static const char *mbccu_load[] = { |
| 229 | [0] = "No Load", |
| 230 | [1] = "Load BTSCAC", |
| 231 | [2] = "Load BTSDRX", |
| 232 | [3] = "Load BTSBBX", |
| 233 | [4] = "Load BTSARC", |
| 234 | [5] = "Load", |
| 235 | }; |
| 236 | |
| 237 | static const char *mbccu_load_name(u_int8_t linkstate) |
| 238 | { |
| 239 | if (linkstate > ARRAY_SIZE(mbccu_load)) |
| 240 | return "Unknown"; |
| 241 | |
| 242 | return mbccu_load[linkstate]; |
| 243 | } |
| 244 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 245 | static const char *bts_phase_name(u_int8_t phase) |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 246 | { |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 247 | switch (phase) { |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 248 | case BS11_STATE_WARM_UP: |
Harald Welte | c12d52b | 2009-02-01 21:39:06 +0000 | [diff] [blame] | 249 | case BS11_STATE_WARM_UP_2: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 250 | return "Warm Up"; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 251 | break; |
| 252 | case BS11_STATE_LOAD_SMU_SAFETY: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 253 | return "Load SMU Safety"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 254 | break; |
| 255 | case BS11_STATE_LOAD_SMU_INTENDED: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 256 | return "Load SMU Intended"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 257 | break; |
| 258 | case BS11_STATE_LOAD_MBCCU: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 259 | return "Load MBCCU"; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 260 | break; |
| 261 | case BS11_STATE_SOFTWARE_RQD: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 262 | return "Software required"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 263 | break; |
| 264 | case BS11_STATE_WAIT_MIN_CFG: |
| 265 | case BS11_STATE_WAIT_MIN_CFG_2: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 266 | return "Wait minimal config"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 267 | break; |
| 268 | case BS11_STATE_MAINTENANCE: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 269 | return "Maintenance"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 270 | break; |
| 271 | case BS11_STATE_NORMAL: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 272 | return "Normal"; |
| 273 | break; |
| 274 | case BS11_STATE_ABIS_LOAD: |
| 275 | return "Abis load"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 276 | break; |
| 277 | default: |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 278 | return "Unknown"; |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 279 | break; |
| 280 | } |
| 281 | } |
| 282 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 283 | static const char *trx_power_name(u_int8_t pwr) |
| 284 | { |
| 285 | switch (pwr) { |
| 286 | case BS11_TRX_POWER_GSM_2W: |
| 287 | return "2W (GSM)"; |
| 288 | case BS11_TRX_POWER_GSM_250mW: |
| 289 | return "250mW (GSM)"; |
| 290 | case BS11_TRX_POWER_GSM_80mW: |
| 291 | return "80mW (GSM)"; |
| 292 | case BS11_TRX_POWER_GSM_30mW: |
| 293 | return "30mW (GSM)"; |
| 294 | case BS11_TRX_POWER_DCS_3W: |
| 295 | return "3W (DCS)"; |
| 296 | case BS11_TRX_POWER_DCS_1W6: |
| 297 | return "1.6W (DCS)"; |
| 298 | case BS11_TRX_POWER_DCS_500mW: |
| 299 | return "500mW (DCS)"; |
| 300 | case BS11_TRX_POWER_DCS_160mW: |
| 301 | return "160mW (DCS)"; |
| 302 | default: |
| 303 | return "unknown value"; |
| 304 | } |
| 305 | } |
| 306 | |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 307 | static const char *pll_mode_name(u_int8_t mode) |
| 308 | { |
| 309 | switch (mode) { |
| 310 | case BS11_LI_PLL_LOCKED: |
| 311 | return "E1 Locked"; |
| 312 | case BS11_LI_PLL_STANDALONE: |
| 313 | return "Standalone"; |
| 314 | default: |
| 315 | return "unknown"; |
| 316 | } |
| 317 | } |
| 318 | |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 319 | static const char *cclk_acc_name(u_int8_t acc) |
| 320 | { |
| 321 | switch (acc) { |
| 322 | case 0: |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 323 | /* Out of the demanded +/- 0.05ppm */ |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 324 | return "Medium"; |
| 325 | case 1: |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 326 | /* Synchronized with Abis, within demanded tolerance +/- 0.05ppm */ |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 327 | return "High"; |
| 328 | default: |
| 329 | return "unknown"; |
| 330 | } |
| 331 | } |
| 332 | |
Harald Welte | f751a10 | 2010-12-14 12:52:16 +0100 | [diff] [blame] | 333 | static const char *bport_lcfg_name(u_int8_t lcfg) |
| 334 | { |
| 335 | switch (lcfg) { |
| 336 | case BS11_LINE_CFG_STAR: |
| 337 | return "Star"; |
| 338 | case BS11_LINE_CFG_MULTIDROP: |
| 339 | return "Multi-Drop"; |
| 340 | default: |
| 341 | return "unknown"; |
| 342 | } |
| 343 | } |
| 344 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 345 | static const char *obj_name(struct abis_om_fom_hdr *foh) |
| 346 | { |
| 347 | static char retbuf[256]; |
| 348 | |
| 349 | retbuf[0] = 0; |
| 350 | |
| 351 | switch (foh->obj_class) { |
| 352 | case NM_OC_BS11: |
| 353 | strcat(retbuf, "BS11 "); |
| 354 | switch (foh->obj_inst.bts_nr) { |
| 355 | case BS11_OBJ_PA: |
| 356 | sprintf(retbuf+strlen(retbuf), "Power Amplifier %d ", |
| 357 | foh->obj_inst.ts_nr); |
| 358 | break; |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 359 | case BS11_OBJ_LI: |
| 360 | sprintf(retbuf+strlen(retbuf), "Line Interface "); |
| 361 | break; |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 362 | case BS11_OBJ_CCLK: |
| 363 | sprintf(retbuf+strlen(retbuf), "CCLK "); |
| 364 | break; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 365 | } |
| 366 | break; |
| 367 | case NM_OC_SITE_MANAGER: |
| 368 | strcat(retbuf, "SITE MANAGER "); |
| 369 | break; |
Harald Welte | f751a10 | 2010-12-14 12:52:16 +0100 | [diff] [blame] | 370 | case NM_OC_BS11_BPORT: |
| 371 | sprintf(retbuf+strlen(retbuf), "BPORT%u ", |
| 372 | foh->obj_inst.bts_nr); |
| 373 | break; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 374 | } |
| 375 | return retbuf; |
| 376 | } |
| 377 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 378 | static void print_state(struct tlv_parsed *tp) |
| 379 | { |
| 380 | if (TLVP_PRESENT(tp, NM_ATT_BS11_BTS_STATE)) { |
| 381 | u_int8_t phase, mbccu; |
| 382 | if (TLVP_LEN(tp, NM_ATT_BS11_BTS_STATE) >= 1) { |
| 383 | phase = *TLVP_VAL(tp, NM_ATT_BS11_BTS_STATE); |
| 384 | printf("PHASE: %u %-20s ", phase & 0xf, |
| 385 | bts_phase_name(phase)); |
| 386 | } |
| 387 | if (TLVP_LEN(tp, NM_ATT_BS11_BTS_STATE) >= 2) { |
| 388 | mbccu = *(TLVP_VAL(tp, NM_ATT_BS11_BTS_STATE)+1); |
| 389 | printf("MBCCU0: %-11s MBCCU1: %-11s ", |
| 390 | mbccu_load_name(mbccu & 0xf), mbccu_load_name(mbccu >> 4)); |
| 391 | } |
| 392 | } |
| 393 | if (TLVP_PRESENT(tp, NM_ATT_BS11_E1_STATE) && |
| 394 | TLVP_LEN(tp, NM_ATT_BS11_E1_STATE) >= 1) { |
| 395 | u_int8_t e1_state = *TLVP_VAL(tp, NM_ATT_BS11_E1_STATE); |
| 396 | printf("Abis-link: %-9s ", linkstate_name(e1_state & 0xf)); |
| 397 | } |
| 398 | printf("\n"); |
| 399 | } |
| 400 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 401 | static int print_attr(struct tlv_parsed *tp) |
| 402 | { |
| 403 | if (TLVP_PRESENT(tp, NM_ATT_BS11_ESN_PCB_SERIAL)) { |
| 404 | printf("\tBS-11 ESN PCB Serial Number: %s\n", |
| 405 | TLVP_VAL(tp, NM_ATT_BS11_ESN_PCB_SERIAL)); |
| 406 | } |
| 407 | if (TLVP_PRESENT(tp, NM_ATT_BS11_ESN_HW_CODE_NO)) { |
| 408 | printf("\tBS-11 ESN Hardware Code Number: %s\n", |
| 409 | TLVP_VAL(tp, NM_ATT_BS11_ESN_HW_CODE_NO)+6); |
| 410 | } |
| 411 | if (TLVP_PRESENT(tp, NM_ATT_BS11_ESN_FW_CODE_NO)) { |
| 412 | printf("\tBS-11 ESN Firmware Code Number: %s\n", |
| 413 | TLVP_VAL(tp, NM_ATT_BS11_ESN_FW_CODE_NO)+6); |
| 414 | } |
| 415 | #if 0 |
| 416 | if (TLVP_PRESENT(tp, NM_ATT_BS11_BOOT_SW_VERS)) { |
| 417 | printf("BS-11 Boot Software Version: %s\n", |
| 418 | TLVP_VAL(tp, NM_ATT_BS11_BOOT_SW_VERS)+6); |
| 419 | } |
| 420 | #endif |
| 421 | if (TLVP_PRESENT(tp, NM_ATT_ABIS_CHANNEL) && |
| 422 | TLVP_LEN(tp, NM_ATT_ABIS_CHANNEL) >= 3) { |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 423 | const u_int8_t *chan = TLVP_VAL(tp, NM_ATT_ABIS_CHANNEL); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 424 | printf("\tE1 Channel: Port=%u Timeslot=%u ", |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 425 | chan[0], chan[1]); |
| 426 | if (chan[2] == 0xff) |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 427 | printf("(Full Slot)\n"); |
| 428 | else |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 429 | printf("Subslot=%u\n", chan[2]); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 430 | } |
| 431 | if (TLVP_PRESENT(tp, NM_ATT_TEI)) |
| 432 | printf("\tTEI: %d\n", *TLVP_VAL(tp, NM_ATT_TEI)); |
| 433 | if (TLVP_PRESENT(tp, NM_ATT_BS11_TXPWR) && |
| 434 | TLVP_LEN(tp, NM_ATT_BS11_TXPWR) >= 1) { |
| 435 | printf("\tTRX Power: %s\n", |
| 436 | trx_power_name(*TLVP_VAL(tp, NM_ATT_BS11_TXPWR))); |
| 437 | } |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 438 | if (TLVP_PRESENT(tp, NM_ATT_BS11_PLL_MODE) && |
| 439 | TLVP_LEN(tp, NM_ATT_BS11_PLL_MODE) >= 1) { |
| 440 | printf("\tPLL Mode: %s\n", |
| 441 | pll_mode_name(*TLVP_VAL(tp, NM_ATT_BS11_PLL_MODE))); |
| 442 | } |
Harald Welte | a7cfa03 | 2009-04-29 22:33:02 +0000 | [diff] [blame] | 443 | if (TLVP_PRESENT(tp, NM_ATT_BS11_PLL) && |
| 444 | TLVP_LEN(tp, NM_ATT_BS11_PLL) >= 4) { |
| 445 | const u_int8_t *vp = TLVP_VAL(tp, NM_ATT_BS11_PLL); |
| 446 | printf("\tPLL Set Value=%d, Work Value=%d\n", |
| 447 | vp[0] << 8 | vp[1], vp[2] << 8 | vp[3]); |
| 448 | } |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 449 | if (TLVP_PRESENT(tp, NM_ATT_BS11_CCLK_ACCURACY) && |
| 450 | TLVP_LEN(tp, NM_ATT_BS11_CCLK_ACCURACY) >= 1) { |
| 451 | const u_int8_t *acc = TLVP_VAL(tp, NM_ATT_BS11_CCLK_ACCURACY); |
| 452 | printf("\tCCLK Accuracy: %s (%d)\n", cclk_acc_name(*acc), *acc); |
| 453 | } |
| 454 | if (TLVP_PRESENT(tp, NM_ATT_BS11_CCLK_TYPE) && |
| 455 | TLVP_LEN(tp, NM_ATT_BS11_CCLK_TYPE) >= 1) { |
| 456 | const u_int8_t *acc = TLVP_VAL(tp, NM_ATT_BS11_CCLK_TYPE); |
| 457 | printf("\tCCLK Type=%d\n", *acc); |
| 458 | } |
Harald Welte | f751a10 | 2010-12-14 12:52:16 +0100 | [diff] [blame] | 459 | if (TLVP_PRESENT(tp, NM_ATT_BS11_LINE_CFG) && |
| 460 | TLVP_LEN(tp, NM_ATT_BS11_LINE_CFG) >= 1) { |
| 461 | const u_int8_t *lcfg = TLVP_VAL(tp, NM_ATT_BS11_LINE_CFG); |
| 462 | printf("\tLine Configuration: %s (%d)\n", |
| 463 | bport_lcfg_name(*lcfg), *lcfg); |
| 464 | } |
| 465 | |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 466 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 467 | |
| 468 | return 0; |
| 469 | } |
| 470 | |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 471 | static void cmd_query(void) |
| 472 | { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 473 | struct gsm_bts_trx *trx = g_bts->c0; |
| 474 | |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 475 | bs11cfg_state = STATE_QUERY; |
| 476 | abis_nm_bs11_get_serno(g_bts); |
| 477 | abis_nm_bs11_get_oml_tei_ts(g_bts); |
Harald Welte | aaf02d9 | 2009-04-29 13:25:57 +0000 | [diff] [blame] | 478 | abis_nm_bs11_get_pll_mode(g_bts); |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 479 | abis_nm_bs11_get_cclk(g_bts); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 480 | abis_nm_bs11_get_trx_power(trx); |
| 481 | trx = gsm_bts_trx_num(g_bts, 1); |
| 482 | if (trx) |
| 483 | abis_nm_bs11_get_trx_power(trx); |
Harald Welte | f751a10 | 2010-12-14 12:52:16 +0100 | [diff] [blame] | 484 | abis_nm_bs11_get_bport_line_cfg(g_bts, 0); |
| 485 | abis_nm_bs11_get_bport_line_cfg(g_bts, 1); |
Harald Welte | ef06195 | 2009-05-17 12:43:42 +0000 | [diff] [blame] | 486 | sleep(1); |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 487 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 488 | command = NULL; |
| 489 | } |
| 490 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 491 | /* handle a response from the BTS to a GET STATE command */ |
| 492 | static int handle_state_resp(enum abis_bs11_phase state) |
| 493 | { |
| 494 | int rc = 0; |
| 495 | |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 496 | switch (state) { |
| 497 | case BS11_STATE_WARM_UP: |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 498 | case BS11_STATE_LOAD_SMU_SAFETY: |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 499 | case BS11_STATE_LOAD_SMU_INTENDED: |
Harald Welte | 268bb40 | 2009-02-01 19:11:56 +0000 | [diff] [blame] | 500 | case BS11_STATE_LOAD_MBCCU: |
| 501 | break; |
| 502 | case BS11_STATE_SOFTWARE_RQD: |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 503 | bs11cfg_state = STATE_SWLOAD; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 504 | /* send safety load. Use g_bts as private 'param' |
| 505 | * argument, so our swload_cbfn can distinguish |
| 506 | * a safety load from a regular software */ |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 507 | if (file_is_readable(fname_safety)) |
Holger Hans Peter Freyther | 64278ed | 2010-05-12 23:51:46 +0800 | [diff] [blame] | 508 | rc = abis_nm_software_load(g_bts, 0xff, fname_safety, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 509 | win_size, param_forced, |
| 510 | swload_cbfn, g_bts); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 511 | else |
Harald Welte | 071f34d | 2009-01-29 09:24:38 +0000 | [diff] [blame] | 512 | fprintf(stderr, "No valid Safety Load file \"%s\"\n", |
| 513 | fname_safety); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 514 | break; |
| 515 | case BS11_STATE_WAIT_MIN_CFG: |
| 516 | case BS11_STATE_WAIT_MIN_CFG_2: |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 517 | bs11cfg_state = STATE_SWLOAD; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 518 | rc = create_objects(g_bts); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 519 | break; |
| 520 | case BS11_STATE_MAINTENANCE: |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 521 | if (command) { |
| 522 | if (!strcmp(command, "disconnect")) |
Harald Welte | f80b7d3 | 2009-02-19 03:11:13 +0000 | [diff] [blame] | 523 | abis_nm_bs11_factory_logon(g_bts, 0); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 524 | else if (!strcmp(command, "reconnect")) |
| 525 | rc = abis_nm_bs11_bsc_disconnect(g_bts, 1); |
| 526 | else if (!strcmp(command, "software") |
| 527 | && bs11cfg_state != STATE_SWLOAD) { |
| 528 | bs11cfg_state = STATE_SWLOAD; |
| 529 | /* send software (FIXME: over A-bis?) */ |
| 530 | if (file_is_readable(fname_software)) |
| 531 | rc = abis_nm_bs11_load_swl(g_bts, fname_software, |
| 532 | win_size, param_forced, |
| 533 | swload_cbfn); |
| 534 | else |
| 535 | fprintf(stderr, "No valid Software file \"%s\"\n", |
| 536 | fname_software); |
| 537 | } else if (!strcmp(command, "delete-trx1")) { |
Harald Welte | 273feca | 2009-03-28 16:53:25 +0000 | [diff] [blame] | 538 | printf("Locing BBSIG and PA objects of TRX1\n"); |
| 539 | abis_nm_chg_adm_state(g_bts, NM_OC_BS11, |
| 540 | BS11_OBJ_BBSIG, 0, 1, |
| 541 | NM_STATE_LOCKED); |
| 542 | abis_nm_chg_adm_state(g_bts, NM_OC_BS11, |
| 543 | BS11_OBJ_PA, 0, 1, |
| 544 | NM_STATE_LOCKED); |
| 545 | sleep(1); |
| 546 | printf("Deleting BBSIG and PA objects of TRX1\n"); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 547 | abis_nm_bs11_delete_object(g_bts, BS11_OBJ_BBSIG, 1); |
| 548 | abis_nm_bs11_delete_object(g_bts, BS11_OBJ_PA, 1); |
Harald Welte | 273feca | 2009-03-28 16:53:25 +0000 | [diff] [blame] | 549 | sleep(1); |
Harald Welte | f80b7d3 | 2009-02-19 03:11:13 +0000 | [diff] [blame] | 550 | abis_nm_bs11_factory_logon(g_bts, 0); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 551 | command = NULL; |
| 552 | } else if (!strcmp(command, "create-trx1")) { |
| 553 | create_trx1(g_bts); |
Harald Welte | 273feca | 2009-03-28 16:53:25 +0000 | [diff] [blame] | 554 | sleep(1); |
Harald Welte | f80b7d3 | 2009-02-19 03:11:13 +0000 | [diff] [blame] | 555 | abis_nm_bs11_factory_logon(g_bts, 0); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 556 | command = NULL; |
Harald Welte | e69f5fb | 2009-04-28 16:31:38 +0000 | [diff] [blame] | 557 | } else if (!strcmp(command, "pll-e1-locked")) { |
| 558 | abis_nm_bs11_set_pll_locked(g_bts, 1); |
| 559 | sleep(1); |
| 560 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 561 | command = NULL; |
| 562 | } else if (!strcmp(command, "pll-standalone")) { |
| 563 | abis_nm_bs11_set_pll_locked(g_bts, 0); |
| 564 | sleep(1); |
| 565 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 566 | command = NULL; |
Daniel Willmann | 6a9fa73 | 2010-01-07 01:27:50 +0100 | [diff] [blame] | 567 | } else if (!strcmp(command, "pll-setvalue")) { |
| 568 | abis_nm_bs11_set_pll(g_bts, atoi(value)); |
| 569 | sleep(1); |
| 570 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 571 | command = NULL; |
| 572 | } else if (!strcmp(command, "pll-workvalue")) { |
| 573 | /* To set the work value we need to login as FIELD */ |
| 574 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 575 | sleep(1); |
| 576 | abis_nm_bs11_infield_logon(g_bts, 1); |
| 577 | sleep(1); |
| 578 | abis_nm_bs11_set_pll(g_bts, atoi(value)); |
| 579 | sleep(1); |
| 580 | abis_nm_bs11_infield_logon(g_bts, 0); |
| 581 | command = NULL; |
Harald Welte | b6c92ae | 2009-02-21 20:15:32 +0000 | [diff] [blame] | 582 | } else if (!strcmp(command, "oml-tei")) { |
| 583 | abis_nm_bs11_conn_oml_tei(g_bts, 0, 1, 0xff, TEI_OML); |
Harald Welte | 0558f54 | 2009-02-21 20:17:12 +0000 | [diff] [blame] | 584 | command = NULL; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 585 | } else if (!strcmp(command, "restart")) { |
| 586 | abis_nm_bs11_restart(g_bts); |
| 587 | command = NULL; |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 588 | } else if (!strcmp(command, "query")) { |
| 589 | cmd_query(); |
Daniel Willmann | 65f68fa | 2009-08-10 11:49:36 +0200 | [diff] [blame] | 590 | } else if (!strcmp(command, "create-bport1")) { |
| 591 | abis_nm_bs11_create_bport(g_bts, 1); |
| 592 | sleep(1); |
| 593 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 594 | command = NULL; |
| 595 | } else if (!strcmp(command, "delete-bport1")) { |
| 596 | abis_nm_chg_adm_state(g_bts, NM_OC_BS11_BPORT, 1, 0xff, 0xff, NM_STATE_LOCKED); |
| 597 | sleep(1); |
| 598 | abis_nm_bs11_delete_bport(g_bts, 1); |
| 599 | sleep(1); |
| 600 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 601 | command = NULL; |
| 602 | } else if (!strcmp(command, "bport0-star")) { |
| 603 | abis_nm_bs11_set_bport_line_cfg(g_bts, 0, BS11_LINE_CFG_STAR); |
| 604 | sleep(1); |
| 605 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 606 | command = NULL; |
| 607 | } else if (!strcmp(command, "bport0-multidrop")) { |
| 608 | abis_nm_bs11_set_bport_line_cfg(g_bts, 0, BS11_LINE_CFG_MULTIDROP); |
| 609 | sleep(1); |
| 610 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 611 | command = NULL; |
Harald Welte | 7e72fa0 | 2010-12-14 12:35:59 +0100 | [diff] [blame] | 612 | } else if (!strcmp(command, "bport1-multidrop")) { |
| 613 | abis_nm_bs11_set_bport_line_cfg(g_bts, 1, BS11_LINE_CFG_MULTIDROP); |
| 614 | sleep(1); |
| 615 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 616 | command = NULL; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 617 | } |
Harald Welte | 7e72fa0 | 2010-12-14 12:35:59 +0100 | [diff] [blame] | 618 | |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 619 | } |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 620 | break; |
| 621 | case BS11_STATE_NORMAL: |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 622 | if (command) { |
| 623 | if (!strcmp(command, "reconnect")) |
Harald Welte | f80b7d3 | 2009-02-19 03:11:13 +0000 | [diff] [blame] | 624 | abis_nm_bs11_factory_logon(g_bts, 0); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 625 | else if (!strcmp(command, "disconnect")) |
| 626 | abis_nm_bs11_bsc_disconnect(g_bts, 0); |
| 627 | else if (!strcmp(command, "query")) { |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 628 | cmd_query(); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 629 | } |
| 630 | } else if (param_disconnect) { |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 631 | param_disconnect = 0; |
| 632 | abis_nm_bs11_bsc_disconnect(g_bts, 0); |
| 633 | if (param_restart) { |
| 634 | param_restart = 0; |
| 635 | abis_nm_bs11_restart(g_bts); |
| 636 | } |
| 637 | } |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 638 | break; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 639 | default: |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 640 | break; |
| 641 | } |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 642 | return rc; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 643 | } |
| 644 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 645 | /* handle a fully-received message/packet from the RS232 port */ |
Harald Welte | c12d52b | 2009-02-01 21:39:06 +0000 | [diff] [blame] | 646 | int handle_serial_msg(struct msgb *rx_msg) |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 647 | { |
| 648 | struct abis_om_hdr *oh; |
| 649 | struct abis_om_fom_hdr *foh; |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 650 | struct tlv_parsed tp; |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 651 | int rc = -1; |
| 652 | |
Harald Welte | c12d52b | 2009-02-01 21:39:06 +0000 | [diff] [blame] | 653 | #if 0 |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 654 | if (rx_msg->len < LAPD_HDR_LEN |
| 655 | + sizeof(struct abis_om_fom_hdr) |
| 656 | + sizeof(struct abis_om_hdr)) { |
| 657 | if (!memcmp(rx_msg->data + 2, too_fast, |
| 658 | sizeof(too_fast))) { |
| 659 | fprintf(stderr, "BS11 tells us we're too " |
| 660 | "fast, try --delay bigger than %u\n", |
| 661 | delay_ms); |
| 662 | return -E2BIG; |
| 663 | } else |
| 664 | fprintf(stderr, "unknown BS11 message\n"); |
| 665 | } |
Harald Welte | c12d52b | 2009-02-01 21:39:06 +0000 | [diff] [blame] | 666 | #endif |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 667 | |
| 668 | oh = (struct abis_om_hdr *) msgb_l2(rx_msg); |
| 669 | foh = (struct abis_om_fom_hdr *) oh->data; |
| 670 | switch (foh->msg_type) { |
Harald Welte | 043d04a | 2009-01-29 23:15:30 +0000 | [diff] [blame] | 671 | case NM_MT_BS11_LMT_LOGON_ACK: |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 672 | printf("LMT LOGON: ACK\n\n"); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 673 | if (bs11cfg_state == STATE_NONE) |
| 674 | bs11cfg_state = STATE_LOGON_ACK; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 675 | rc = abis_nm_bs11_get_state(g_bts); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 676 | break; |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 677 | case NM_MT_BS11_LMT_LOGOFF_ACK: |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 678 | printf("LMT LOGOFF: ACK\n"); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 679 | exit(0); |
| 680 | break; |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 681 | case NM_MT_BS11_GET_STATE_ACK: |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 682 | rc = abis_nm_tlv_parse(&tp, g_bts, foh->data, oh->length-sizeof(*foh)); |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 683 | print_state(&tp); |
| 684 | if (TLVP_PRESENT(&tp, NM_ATT_BS11_BTS_STATE) && |
| 685 | TLVP_LEN(&tp, NM_ATT_BS11_BTS_STATE) >= 1) |
| 686 | rc = handle_state_resp(*TLVP_VAL(&tp, NM_ATT_BS11_BTS_STATE)); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 687 | break; |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 688 | case NM_MT_GET_ATTR_RESP: |
Harald Welte | 70128d0 | 2009-04-29 13:27:56 +0000 | [diff] [blame] | 689 | printf("\n%sATTRIBUTES:\n", obj_name(foh)); |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 690 | abis_nm_tlv_parse(&tp, g_bts, foh->data, oh->length-sizeof(*foh)); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 691 | rc = print_attr(&tp); |
| 692 | //hexdump(foh->data, oh->length-sizeof(*foh)); |
| 693 | break; |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 694 | case NM_MT_BS11_SET_ATTR_ACK: |
Harald Welte | a30b1ca | 2009-03-10 11:46:02 +0000 | [diff] [blame] | 695 | printf("SET ATTRIBUTE ObjClass=0x%02x ObjInst=(%d,%d,%d) ACK\n", |
| 696 | foh->obj_class, foh->obj_inst.bts_nr, |
| 697 | foh->obj_inst.trx_nr, foh->obj_inst.ts_nr); |
| 698 | rc = 0; |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 699 | break; |
| 700 | case NM_MT_BS11_SET_ATTR_NACK: |
Harald Welte | a30b1ca | 2009-03-10 11:46:02 +0000 | [diff] [blame] | 701 | printf("SET ATTRIBUTE ObjClass=0x%02x ObjInst=(%d,%d,%d) NACK\n", |
| 702 | foh->obj_class, foh->obj_inst.bts_nr, |
| 703 | foh->obj_inst.trx_nr, foh->obj_inst.ts_nr); |
Harald Welte | 074d873d | 2009-02-21 20:41:12 +0000 | [diff] [blame] | 704 | break; |
Harald Welte | ec073e9 | 2010-12-14 13:34:35 +0100 | [diff] [blame] | 705 | case NM_MT_GET_ATTR_NACK: |
| 706 | printf("\n%sGET ATTR NACK\n", obj_name(foh)); |
| 707 | break; |
| 708 | case NM_MT_BS11_CREATE_OBJ_ACK: |
| 709 | printf("\n%sCREATE OBJECT ACK\n", obj_name(foh)); |
| 710 | break; |
| 711 | case NM_MT_BS11_CREATE_OBJ_NACK: |
| 712 | printf("\n%sCREATE OBJECT NACK\n", obj_name(foh)); |
| 713 | break; |
| 714 | case NM_MT_BS11_DELETE_OBJ_ACK: |
| 715 | printf("\n%sDELETE OBJECT ACK\n", obj_name(foh)); |
| 716 | break; |
| 717 | case NM_MT_BS11_DELETE_OBJ_NACK: |
| 718 | printf("\n%sDELETE OBJECT NACK\n", obj_name(foh)); |
| 719 | break; |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 720 | default: |
| 721 | rc = abis_nm_rcvmsg(rx_msg); |
| 722 | } |
| 723 | if (rc < 0) { |
| 724 | perror("ERROR in main loop"); |
| 725 | //break; |
| 726 | } |
| 727 | if (rc == 1) |
| 728 | return rc; |
| 729 | |
| 730 | switch (bs11cfg_state) { |
| 731 | case STATE_NONE: |
| 732 | abis_nm_bs11_factory_logon(g_bts, 1); |
| 733 | break; |
| 734 | case STATE_LOGON_ACK: |
Harald Welte | ff117a8 | 2009-05-23 05:22:08 +0000 | [diff] [blame] | 735 | bsc_schedule_timer(&status_timer, 5, 0); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 736 | break; |
| 737 | default: |
| 738 | break; |
| 739 | } |
| 740 | |
| 741 | return rc; |
| 742 | } |
| 743 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 744 | void status_timer_cb(void *data) |
| 745 | { |
| 746 | abis_nm_bs11_get_state(g_bts); |
| 747 | } |
| 748 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 749 | static void print_banner(void) |
| 750 | { |
Harald Welte | 5f5189e | 2010-12-14 13:14:32 +0100 | [diff] [blame] | 751 | printf("bs11_config (C) 2009-2010 by Harald Welte and Dieter Spaar\n"); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 752 | printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n"); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | static void print_help(void) |
| 756 | { |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 757 | printf("bs11_config [options] [command]\n"); |
| 758 | printf("\nSupported options:\n"); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 759 | printf("\t-h --help\t\t\tPrint this help text\n"); |
| 760 | printf("\t-p --port </dev/ttyXXX>\t\tSpecify serial port\n"); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 761 | printf("\t-s --software <file>\t\tSpecify Software file\n"); |
| 762 | printf("\t-S --safety <file>\t\tSpecify Safety Load file\n"); |
Daniel Willmann | f904fa8 | 2010-01-07 01:26:32 +0100 | [diff] [blame] | 763 | printf("\t-d --delay <ms>\t\t\tSpecify delay in milliseconds\n"); |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 764 | printf("\t-D --disconnect\t\t\tDisconnect BTS from BSC\n"); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 765 | printf("\t-w --win-size <num>\t\tSpecify Window Size\n"); |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 766 | printf("\t-f --forced\t\t\tForce Software Load\n"); |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 767 | printf("\nSupported commands:\n"); |
Daniel Willmann | f904fa8 | 2010-01-07 01:26:32 +0100 | [diff] [blame] | 768 | printf("\tquery\t\t\tQuery the BS-11 about serial number and configuration\n"); |
| 769 | printf("\tdisconnect\t\tDisconnect A-bis link (go into administrative state)\n"); |
| 770 | printf("\tresconnect\t\tReconnect A-bis link (go into normal state)\n"); |
| 771 | printf("\trestart\t\t\tRestart the BTS\n"); |
| 772 | printf("\tsoftware\t\tDownload Software (only in administrative state)\n"); |
| 773 | printf("\tcreate-trx1\t\tCreate objects for TRX1 (Danger: Your BS-11 might overheat)\n"); |
| 774 | printf("\tdelete-trx1\t\tDelete objects for TRX1\n"); |
| 775 | printf("\tpll-e1-locked\t\tSet the PLL to be locked to E1 clock\n"); |
| 776 | printf("\tpll-standalone\t\tSet the PLL to be in standalone mode\n"); |
Daniel Willmann | 6a9fa73 | 2010-01-07 01:27:50 +0100 | [diff] [blame] | 777 | printf("\tpll-setvalue <value>\tSet the PLL set value\n"); |
| 778 | printf("\tpll-workvalue <value>\tSet the PLL work value\n"); |
Daniel Willmann | f904fa8 | 2010-01-07 01:26:32 +0100 | [diff] [blame] | 779 | printf("\toml-tei\t\t\tSet OML E1 TS and TEI\n"); |
| 780 | printf("\tbport0-star\t\tSet BPORT0 line config to star\n"); |
Harald Welte | 230cd6a | 2010-12-14 13:28:43 +0100 | [diff] [blame] | 781 | printf("\tbport0-multidrop\tSet BPORT0 line config to multidrop\n"); |
| 782 | printf("\tbport1-multidrop\tSet BPORT1 line config to multidrop\n"); |
Daniel Willmann | f904fa8 | 2010-01-07 01:26:32 +0100 | [diff] [blame] | 783 | printf("\tcreate-bport1\t\tCreate BPORT1 object\n"); |
| 784 | printf("\tdelete-bport1\t\tDelete BPORT1 object\n"); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | static void handle_options(int argc, char **argv) |
| 788 | { |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 789 | int option_index = 0; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 790 | print_banner(); |
| 791 | |
| 792 | while (1) { |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 793 | int c; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 794 | static struct option long_options[] = { |
| 795 | { "help", 0, 0, 'h' }, |
| 796 | { "port", 1, 0, 'p' }, |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 797 | { "software", 1, 0, 's' }, |
| 798 | { "safety", 1, 0, 'S' }, |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 799 | { "delay", 1, 0, 'd' }, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 800 | { "disconnect", 0, 0, 'D' }, |
Harald Welte | 623d531 | 2009-01-29 21:14:05 +0000 | [diff] [blame] | 801 | { "win-size", 1, 0, 'w' }, |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 802 | { "forced", 0, 0, 'f' }, |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 803 | { "restart", 0, 0, 'r' }, |
Harald Welte | c125a68 | 2009-05-23 06:42:38 +0000 | [diff] [blame] | 804 | { "debug", 1, 0, 'b'}, |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 805 | }; |
| 806 | |
Harald Welte | 0313394 | 2009-02-18 19:51:53 +0000 | [diff] [blame] | 807 | c = getopt_long(argc, argv, "hp:s:S:td:Dw:fra:", |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 808 | long_options, &option_index); |
| 809 | |
| 810 | if (c == -1) |
| 811 | break; |
| 812 | |
| 813 | switch (c) { |
| 814 | case 'h': |
| 815 | print_help(); |
| 816 | exit(0); |
| 817 | case 'p': |
| 818 | serial_port = optarg; |
| 819 | break; |
Harald Welte | c125a68 | 2009-05-23 06:42:38 +0000 | [diff] [blame] | 820 | case 'b': |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 821 | log_parse_category_mask(stderr_target, optarg); |
Harald Welte | c125a68 | 2009-05-23 06:42:38 +0000 | [diff] [blame] | 822 | break; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 823 | case 's': |
| 824 | fname_software = optarg; |
| 825 | break; |
| 826 | case 'S': |
| 827 | fname_safety = optarg; |
| 828 | break; |
Harald Welte | 3b8ba21 | 2009-01-29 12:27:58 +0000 | [diff] [blame] | 829 | case 'd': |
| 830 | delay_ms = atoi(optarg); |
| 831 | break; |
Harald Welte | 623d531 | 2009-01-29 21:14:05 +0000 | [diff] [blame] | 832 | case 'w': |
| 833 | win_size = atoi(optarg); |
| 834 | break; |
Harald Welte | 3ffd137 | 2009-02-01 22:15:49 +0000 | [diff] [blame] | 835 | case 'D': |
| 836 | param_disconnect = 1; |
| 837 | break; |
| 838 | case 'f': |
| 839 | param_forced = 1; |
| 840 | break; |
Harald Welte | 1cbfaf5 | 2009-02-05 19:30:22 +0000 | [diff] [blame] | 841 | case 'r': |
| 842 | param_disconnect = 1; |
| 843 | param_restart = 1; |
| 844 | break; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 845 | default: |
| 846 | break; |
| 847 | } |
| 848 | } |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 849 | if (optind < argc) |
| 850 | command = argv[optind]; |
Daniel Willmann | 6a9fa73 | 2010-01-07 01:27:50 +0100 | [diff] [blame] | 851 | if (optind+1 < argc) |
| 852 | value = argv[optind+1]; |
| 853 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Harald Welte | 7ed1a64 | 2009-02-02 14:45:49 +0000 | [diff] [blame] | 856 | static int num_sigint; |
| 857 | |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 858 | static void signal_handler(int signal) |
| 859 | { |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 860 | fprintf(stdout, "\nsignal %u received\n", signal); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 861 | |
| 862 | switch (signal) { |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 863 | case SIGINT: |
Harald Welte | 7ed1a64 | 2009-02-02 14:45:49 +0000 | [diff] [blame] | 864 | num_sigint++; |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 865 | abis_nm_bs11_factory_logon(g_bts, 0); |
Harald Welte | 7ed1a64 | 2009-02-02 14:45:49 +0000 | [diff] [blame] | 866 | if (num_sigint >= 3) |
| 867 | exit(0); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 868 | break; |
| 869 | } |
| 870 | } |
| 871 | |
Holger Hans Peter Freyther | 8f44371 | 2010-05-23 21:05:01 +0800 | [diff] [blame] | 872 | extern int bts_model_bs11_init(void); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 873 | int main(int argc, char **argv) |
| 874 | { |
| 875 | struct gsm_network *gsmnet; |
Harald Welte | f186c46 | 2009-01-29 08:45:19 +0000 | [diff] [blame] | 876 | int rc; |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 877 | |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 878 | log_init(&log_info); |
| 879 | stderr_target = log_target_create_stderr(); |
| 880 | log_add_target(stderr_target); |
| 881 | log_set_all_filter(stderr_target, 1); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 882 | handle_options(argc, argv); |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 883 | bts_model_bs11_init(); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 884 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 885 | gsmnet = gsm_network_init(1, 1, NULL); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 886 | if (!gsmnet) { |
| 887 | fprintf(stderr, "Unable to allocate gsm network\n"); |
| 888 | exit(1); |
| 889 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 890 | g_bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_BS11, HARDCODED_TSC, |
| 891 | HARDCODED_BSIC); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 892 | |
Harald Welte | 273feca | 2009-03-28 16:53:25 +0000 | [diff] [blame] | 893 | rc = rs232_setup(serial_port, delay_ms, g_bts); |
Harald Welte | 7ed1a64 | 2009-02-02 14:45:49 +0000 | [diff] [blame] | 894 | if (rc < 0) { |
| 895 | fprintf(stderr, "Problem setting up serial port\n"); |
| 896 | exit(1); |
| 897 | } |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 898 | |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 899 | signal(SIGINT, &signal_handler); |
Harald Welte | 14f0934 | 2009-01-29 19:28:38 +0000 | [diff] [blame] | 900 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 901 | abis_nm_bs11_factory_logon(g_bts, 1); |
Harald Welte | 5e4d1b3 | 2009-02-01 13:36:56 +0000 | [diff] [blame] | 902 | //abis_nm_bs11_get_serno(g_bts); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 903 | |
Harald Welte | fb81ae9 | 2009-02-19 02:59:17 +0000 | [diff] [blame] | 904 | status_timer.cb = status_timer_cb; |
| 905 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 906 | while (1) { |
Harald Welte | 04d3c92 | 2009-05-23 06:07:04 +0000 | [diff] [blame] | 907 | bsc_select_main(0); |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | abis_nm_bs11_factory_logon(g_bts, 0); |
| 911 | |
Harald Welte | 61e42ad | 2009-01-18 19:10:46 +0000 | [diff] [blame] | 912 | exit(0); |
| 913 | } |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 914 | |
| 915 | /* dummy to be able to compile */ |
| 916 | void gsm_net_update_ctype(struct gsm_network *net) |
| 917 | { |
| 918 | } |