diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-08-01 11:56:17 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-09-14 21:21:42 +0200 |
commit | 02c4650af1dc8e99c3c1e565724072485d61c4b4 (patch) | |
tree | 8a8debd8a7d5842cf788a32db2019df5e67bb42b /src/host/layer23/src/misc | |
parent | e746ca06ca8cadfd889f5380e8ca851d86540700 (diff) |
layer23: Move app logic in layer3.c with state struct.
It's far from perfect but at least it's not split in two file and
makes it easier to expand the logic.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host/layer23/src/misc')
-rw-r--r-- | src/host/layer23/src/misc/app_phone.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/misc/layer3.c | 31 | ||||
-rw-r--r-- | src/host/layer23/src/misc/rslms.c | 8 |
3 files changed, 27 insertions, 13 deletions
diff --git a/src/host/layer23/src/misc/app_phone.c b/src/host/layer23/src/misc/app_phone.c index bdb9b793..6b2c9281 100644 --- a/src/host/layer23/src/misc/app_phone.c +++ b/src/host/layer23/src/misc/app_phone.c @@ -43,6 +43,7 @@ static int signal_cb(unsigned int subsys, unsigned int signal, switch (signal) { case S_L1CTL_RESET: ms = signal_data; + layer3_app_reset(); return l1ctl_tx_fbsb_req(ms, ms->test_arfcn, L1CTL_FBSB_F_FB01SB, 100, 0, CCCH_MODE_NONE); diff --git a/src/host/layer23/src/misc/layer3.c b/src/host/layer23/src/misc/layer3.c index 69f558d7..3ba47344 100644 --- a/src/host/layer23/src/misc/layer3.c +++ b/src/host/layer23/src/misc/layer3.c @@ -14,7 +14,12 @@ #include <osmocom/bb/common/osmocom_data.h> #include <osmocom/bb/common/l1ctl.h> -static int ccch_mode = CCCH_MODE_NONE; +static struct { + int ccch_mode; + int ccch_enabled; + int rach_count; +} app_state; + static void dump_bcch(struct osmocom_ms *ms, uint8_t tc, const uint8_t *data) { @@ -43,16 +48,16 @@ static void dump_bcch(struct osmocom_ms *ms, uint8_t tc, const uint8_t *data) if (tc != 2 && tc != 6) fprintf(stderr, " on wrong TC"); #endif - if (ccch_mode == CCCH_MODE_NONE) { + if (app_state.ccch_mode == CCCH_MODE_NONE) { struct gsm48_system_information_type_3 *si3 = (struct gsm48_system_information_type_3 *)data; if (si3->control_channel_desc.ccch_conf == RSL_BCCH_CCCH_CONF_1_C) - ccch_mode = CCCH_MODE_COMBINED; + app_state.ccch_mode = CCCH_MODE_COMBINED; else - ccch_mode = CCCH_MODE_NON_COMBINED; + app_state.ccch_mode = CCCH_MODE_NON_COMBINED; - l1ctl_tx_ccch_mode_req(ms, ccch_mode); + l1ctl_tx_ccch_mode_req(ms, app_state.ccch_mode); } break; case GSM48_MT_RR_SYSINFO_4: @@ -231,5 +236,21 @@ int gsm48_rx_bcch(struct msgb *msg, struct osmocom_ms *ms) //dump_bcch(dl->time.tc, ccch->data); dump_bcch(ms, 0, msg->l3h); + /* Req channel logic */ + if (app_state.ccch_enabled && (app_state.rach_count < 2)) { + l1ctl_tx_rach_req(ms, app_state.rach_count, + app_state.ccch_mode == CCCH_MODE_COMBINED ? 27 : 51, 0); + app_state.rach_count++; + } + return 0; } + +void layer3_app_reset(void) +{ + /* Reset state */ + app_state.ccch_mode = CCCH_MODE_NONE; + app_state.ccch_enabled = 0; + app_state.rach_count = 0; +} + diff --git a/src/host/layer23/src/misc/rslms.c b/src/host/layer23/src/misc/rslms.c index 7231fda4..b2e00472 100644 --- a/src/host/layer23/src/misc/rslms.c +++ b/src/host/layer23/src/misc/rslms.c @@ -56,9 +56,6 @@ int rslms_tx_rll_req_l3(struct osmocom_ms *ms, uint8_t msg_type, return rslms_recvmsg(msg, ms); } -static int ccch_enabled = 0; -static int rach_count = 0; - static int rslms_rx_udata_ind(struct msgb *msg, struct osmocom_ms *ms) { struct abis_rsl_rll_hdr *rllh = msgb_l2(msg); @@ -77,13 +74,8 @@ static int rslms_rx_udata_ind(struct msgb *msg, struct osmocom_ms *ms) if (rllh->chan_nr == RSL_CHAN_PCH_AGCH) { rc = gsm48_rx_ccch(msg, ms); - ccch_enabled = 1; } else if (rllh->chan_nr == RSL_CHAN_BCCH) { rc = gsm48_rx_bcch(msg, ms); - if (ccch_enabled && (rach_count < 2)) { - l1ctl_tx_rach_req(ms, rach_count, 27, 0); - rach_count++; - } } return rc; |