#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)
{
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:
//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;
+}
+
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);
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;