layer23: Introduce signals to indicate PM RES and L1 RESET to app
authorHarald Welte <laforge@gnumonks.org>
Mon, 5 Apr 2010 13:28:59 +0000 (21:28 +0800)
committerHarald Welte <laforge@gnumonks.org>
Mon, 5 Apr 2010 13:30:00 +0000 (21:30 +0800)
src/host/layer23/include/osmocom/l1ctl.h
src/host/layer23/include/osmocom/osmocom_data.h
src/host/layer23/src/app_bcch_scan.c
src/host/layer23/src/app_phone.c
src/host/layer23/src/l1ctl.c

index d0ff886..b56a931 100644 (file)
@@ -18,6 +18,8 @@ int tx_ph_rach_req(struct osmocom_ms *ms);
 
 /* Transmit L1CTL_DM_EST_REQ */
 int tx_ph_dm_est_req(struct osmocom_ms *ms, uint16_t band_arfcn, uint8_t chan_nr);
+/* Transmit NEW_CCCH_REQ */
+int l1ctl_tx_ccch_req(struct osmocom_ms *ms);
 
 int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len);
 
index e46967c..fa7aff4 100644 (file)
@@ -25,4 +25,19 @@ struct osmocom_ms {
        struct osmol2_entity l2_entity;
 };
 
+enum osmobb_sig_subsys {
+       SS_L1CTL,
+};
+
+enum osmobb_meas_sig {
+       S_L1CTL_RESET,
+       S_L1CTL_PM_RES,
+};
+
+struct osmobb_meas_res {
+       struct osmocom_ms *ms;
+       uint16_t band_arfcn;
+       uint8_t rx_lev;
+};
+
 #endif
index c89ce06..83ded48 100644 (file)
 #include <osmocore/msgb.h>
 #include <osmocore/talloc.h>
 #include <osmocore/select.h>
+#include <osmocore/signal.h>
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+                    void *handler_data, void *signal_data)
+{
+       struct osmocom_ms *ms;
+
+       if (subsys != SS_L1CTL)
+               return 0;
+
+       switch (signal) {
+       case S_L1CTL_RESET:
+               ms = signal_data;
+               return l1ctl_tx_pm_req_range(ms, 0, 124);
+               break;
+       }
+       return 0;
+}
 
 int l23_app_init(struct osmocom_ms *ms)
 {
        /* don't do layer3_init() as we don't want an actualy L3 */
-       return 0;       
+       return register_signal_handler(SS_L1CTL, &signal_cb, NULL);
 }
index 1f280a8..2393f45 100644 (file)
 #include <osmocore/msgb.h>
 #include <osmocore/talloc.h>
 #include <osmocore/select.h>
+#include <osmocore/signal.h>
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+                    void *handler_data, void *signal_data)
+{
+       struct osmocom_ms *ms;
+
+       if (subsys != SS_L1CTL)
+               return 0;
+
+       switch (signal) {
+       case S_L1CTL_RESET:
+               ms = signal_data;
+               return l1ctl_tx_ccch_req(ms);
+               break;
+       }
+       return 0;
+}
+
 
 int l23_app_init(struct osmocom_ms *ms)
 {
+       register_signal_handler(SS_L1CTL, &signal_cb, NULL);
        return layer3_init(ms);
 }
index 82c9dc5..da9d5b8 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <l1a_l23_interface.h>
 
+#include <osmocore/signal.h>
 #include <osmocore/logging.h>
 #include <osmocore/timer.h>
 #include <osmocore/msgb.h>
@@ -312,8 +313,7 @@ int l1ctl_tx_pm_req_range(struct osmocom_ms *ms, uint16_t arfcn_from,
 static int rx_l1_reset(struct osmocom_ms *ms)
 {
        printf("Layer1 Reset.\n");
-       return l1ctl_tx_pm_req_range(ms, 0, 124);
-       //return l1ctl_tx_ccch_req(ms);
+       dispatch_signal(SS_L1CTL, S_L1CTL_RESET, ms);
 }
 
 /* Receive L1CTL_PM_RESP */
@@ -323,8 +323,13 @@ static int rx_l1_pm_resp(struct osmocom_ms *ms, struct msgb *msg)
 
        for (pmr = (struct l1ctl_pm_resp *) msg->l1h;
             (uint8_t *) pmr < msg->tail; pmr++) {
+               struct osmobb_meas_res mr;
                DEBUGP(DL1C, "PM MEAS: ARFCN: %4u RxLev: %3d %3d\n",
                        ntohs(pmr->band_arfcn), pmr->pm[0], pmr->pm[1]);
+               mr.band_arfcn = ntohs(pmr->band_arfcn);
+               mr.rx_lev = (pmr->pm[0] + pmr->pm[1]) / 2;
+               mr.ms = ms;
+               dispatch_signal(SS_L1CTL, S_L1CTL_PM_RES, &mr);
        }
        return 0;
 }