summaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo_bsc_rf.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/osmo_bsc_rf.c')
-rw-r--r--openbsc/src/osmo_bsc_rf.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/openbsc/src/osmo_bsc_rf.c b/openbsc/src/osmo_bsc_rf.c
index b748cc9e7..8878f7dbb 100644
--- a/openbsc/src/osmo_bsc_rf.c
+++ b/openbsc/src/osmo_bsc_rf.c
@@ -156,20 +156,44 @@ static void grace_timeout(void *_data)
switch_rf_off(rf);
}
-static int enter_grace(struct osmo_bsc_rf_conn *conn)
+static int enter_grace(struct osmo_bsc_rf *rf)
{
- struct osmo_bsc_rf *rf = conn->rf;
-
rf->grace_timeout.cb = grace_timeout;
rf->grace_timeout.data = rf;
bsc_schedule_timer(&rf->grace_timeout, rf->gsm_network->mid_call_timeout, 0);
LOGP(DINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n",
rf->gsm_network->mid_call_timeout);
- send_signal(conn->rf, S_RF_GRACE);
+ send_signal(rf, S_RF_GRACE);
return 0;
}
+static void rf_delay_cmd_cb(void *data)
+{
+ struct osmo_bsc_rf *rf = data;
+
+ switch (rf->last_request) {
+ case RF_CMD_D_OFF:
+ rf->last_state_command = "RF Direct Off";
+ bsc_del_timer(&rf->rf_check);
+ bsc_del_timer(&rf->grace_timeout);
+ switch_rf_off(rf);
+ break;
+ case RF_CMD_ON:
+ rf->last_state_command = "RF Direct On";
+ bsc_del_timer(&rf->grace_timeout);
+ lock_each_trx(rf->gsm_network, 0);
+ send_signal(rf, S_RF_ON);
+ bsc_schedule_timer(&rf->rf_check, 3, 0);
+ break;
+ case RF_CMD_OFF:
+ rf->last_state_command = "RF Scheduled Off";
+ bsc_del_timer(&rf->rf_check);
+ enter_grace(rf);
+ break;
+ }
+}
+
static int rf_read_cmd(struct bsc_fd *fd)
{
struct osmo_bsc_rf_conn *conn = fd->data;
@@ -191,22 +215,11 @@ static int rf_read_cmd(struct bsc_fd *fd)
handle_query(conn);
break;
case RF_CMD_D_OFF:
- conn->rf->last_state_command = "RF Direct Off";
- bsc_del_timer(&conn->rf->rf_check);
- bsc_del_timer(&conn->rf->grace_timeout);
- switch_rf_off(conn->rf);
- break;
case RF_CMD_ON:
- conn->rf->last_state_command = "RF Direct On";
- bsc_del_timer(&conn->rf->grace_timeout);
- lock_each_trx(conn->rf->gsm_network, 0);
- send_signal(conn->rf, S_RF_ON);
- bsc_schedule_timer(&conn->rf->rf_check, 3, 0);
- break;
case RF_CMD_OFF:
- conn->rf->last_state_command = "RF Scheduled Off";
- bsc_del_timer(&conn->rf->rf_check);
- enter_grace(conn);
+ conn->rf->last_request = buf[0];
+ if (!bsc_timer_pending(&conn->rf->delay_cmd))
+ bsc_schedule_timer(&conn->rf->delay_cmd, 1, 0);
break;
default:
conn->rf->last_state_command = "Unknown command";
@@ -343,6 +356,10 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net
rf->rf_check.data = rf;
rf->rf_check.cb = rf_check_cb;
+ /* delay cmd handling */
+ rf->delay_cmd.data = rf;
+ rf->delay_cmd.cb = rf_delay_cmd_cb;
+
return rf;
}