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.
This commit is contained in:
Holger Hans Peter Freyther 2010-11-22 19:09:38 +01:00
parent bb62b3f053
commit 70c232f75a
2 changed files with 43 additions and 7 deletions

View File

@ -2,6 +2,7 @@
#define OSMO_BSC_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 {

View File

@ -25,6 +25,7 @@
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/signal.h>
#include <openbsc/osmo_msc_data.h>
#include <osmocore/talloc.h>
#include <osmocore/protocol/gsm_12_21.h>
@ -92,15 +93,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->msc_data->mid_call_timeout, 0);
LOGP(DINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n",
rf->gsm_network->msc_data->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 +153,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]);