aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-22 19:09:38 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-22 19:15:38 +0100
commite6fd64d0005fd1853464dc8984886fba1fa7d78b (patch)
treeed982fbdc33329ed985d0160674f18f35057596a /openbsc
parent00d34cd8c6613069ad3fa6b091f2491250e7fa2c (diff)
mid-call: Implement a timer to go from grace to off.
Start the timer... switch it off when we do the final tranistion by a command.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/osmo_bsc_rf.h4
-rw-r--r--openbsc/src/osmo_bsc_rf.c45
2 files changed, 42 insertions, 7 deletions
diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h
index 0c9ba32f5..7039dbdce 100644
--- a/openbsc/include/openbsc/osmo_bsc_rf.h
+++ b/openbsc/include/openbsc/osmo_bsc_rf.h
@@ -2,6 +2,7 @@
#define BSC_MSC_RF
#include <osmocore/write_queue.h>
+#include <osmocore/timer.h>
struct gsm_network;
@@ -10,6 +11,9 @@ struct osmo_bsc_rf {
int policy;
struct bsc_fd listen;
struct gsm_network *gsm_network;
+
+ /* some handling for the automatic grace switch */
+ struct timer_list grace_timeout;
};
struct osmo_bsc_rf_conn {
diff --git a/openbsc/src/osmo_bsc_rf.c b/openbsc/src/osmo_bsc_rf.c
index 06c84666c..0bf0315bd 100644
--- a/openbsc/src/osmo_bsc_rf.c
+++ b/openbsc/src/osmo_bsc_rf.c
@@ -92,15 +92,45 @@ static void handle_query(struct osmo_bsc_rf_conn *conn)
return;
}
-static void send_signal(struct osmo_bsc_rf_conn *conn, int val)
+static void send_signal(struct osmo_bsc_rf *rf, int val)
{
struct rf_signal_data sig;
- sig.net = conn->rf->gsm_network;
+ sig.net = rf->gsm_network;
- conn->rf->policy = val;
+ rf->policy = val;
dispatch_signal(SS_RF, val, &sig);
}
+static int switch_rf_off(struct osmo_bsc_rf *rf)
+{
+ lock_each_trx(rf->gsm_network, 1);
+ send_signal(rf, S_RF_OFF);
+
+ return 0;
+}
+
+static void grace_timeout(void *_data)
+{
+ struct osmo_bsc_rf *rf = (struct osmo_bsc_rf *) _data;
+
+ LOGP(DINP, LOGL_NOTICE, "Grace timeout. Disabling the TRX.\n");
+ switch_rf_off(rf);
+}
+
+static int enter_grace(struct osmo_bsc_rf_conn *conn)
+{
+ 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);
+ return 0;
+}
+
static int rf_read_cmd(struct bsc_fd *fd)
{
struct osmo_bsc_rf_conn *conn = fd->data;
@@ -122,15 +152,16 @@ static int rf_read_cmd(struct bsc_fd *fd)
handle_query(conn);
break;
case RF_CMD_OFF:
- lock_each_trx(conn->rf->gsm_network, 1);
- send_signal(conn, S_RF_OFF);
+ bsc_del_timer(&conn->rf->grace_timeout);
+ switch_rf_off(conn->rf);
break;
case RF_CMD_ON:
+ bsc_del_timer(&conn->rf->grace_timeout);
lock_each_trx(conn->rf->gsm_network, 0);
- send_signal(conn, S_RF_ON);
+ send_signal(conn->rf, S_RF_ON);
break;
case RF_CMD_GRACE:
- send_signal(conn, S_RF_GRACE);
+ enter_grace(conn);
break;
default:
LOGP(DINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);