[layer23] Fix of GPS states
[osmocom-bb.git] / src / host / layer23 / src / mobile / app_mobile.c
index 60055e9..6ba4b9e 100644 (file)
@@ -46,10 +46,12 @@ extern struct log_target *stderr_target;
 static const char *config_file = "/etc/osmocom/osmocom.cfg";
 extern void *l23_ctx;
 extern unsigned short vty_port;
+extern int vty_reading;
 
 int mobile_started = 0;
 
 int mncc_recv_mobile(struct osmocom_ms *ms, int msg_type, void *arg);
+int mncc_recv_dummy(struct osmocom_ms *ms, int msg_type, void *arg);
 
 int mobile_work(struct osmocom_ms *ms)
 {
@@ -147,6 +149,7 @@ int mobile_exit(struct osmocom_ms *ms)
        gsm_subscr_exit(ms);
        gsm48_cc_exit(ms);
        gsm_sim_exit(ms);
+       gsm_settings_exit(ms);
 
        printf("Power off!\n");
 
@@ -170,6 +173,7 @@ int l23_app_init(struct osmocom_ms *ms)
 
        srand(time(NULL));
 
+       gps_init();
        gsm_support_init(ms);
        gsm_sim_init(ms);
        gsm_settings_init(ms);
@@ -178,7 +182,6 @@ int l23_app_init(struct osmocom_ms *ms)
        gsm48_rr_init(ms);
        gsm48_mm_init(ms);
        INIT_LLIST_HEAD(&ms->trans_list);
-       ms->cclayer.mncc_recv = mncc_recv_mobile;
        gsm322_init(ms);
 
        l23_app_work = mobile_work;
@@ -188,6 +191,7 @@ int l23_app_init(struct osmocom_ms *ms)
        vty_init(&vty_info);
        ms_vty_init();
        dummy_conn.priv = NULL;
+       vty_reading = 1;
        rc = vty_read_config_file(config_file, &dummy_conn);
        if (rc < 0) {
                fprintf(stderr, "Failed to parse the config file: '%s'\n",
@@ -196,9 +200,16 @@ int l23_app_init(struct osmocom_ms *ms)
                        "'touch %s'\n", config_file);
                return rc;
        }
+       vty_reading = 0;
        telnet_init(l23_ctx, NULL, vty_port);
        if (rc < 0)
                return rc;
+
+       if (ms->settings.ch_cap == GSM_CAP_SDCCH)
+               ms->cclayer.mncc_recv = mncc_recv_dummy;
+       else
+               ms->cclayer.mncc_recv = mncc_recv_mobile;
+
        printf("VTY available on port %u.\n", vty_port);
 
        gsm_random_imei(&ms->settings);