mid-call: Make the mid-call behavior the default for switching things off
When switching the RF off we will always go through the grace
period, add a direct off mode to switch it off directly. Make
the query return a 'g' if we are in the process of switching
things over.
diff --git a/openbsc/src/bsc/osmo_bsc_rf.c b/openbsc/src/bsc/osmo_bsc_rf.c
index d5a265b..5cc985b 100644
--- a/openbsc/src/bsc/osmo_bsc_rf.c
+++ b/openbsc/src/bsc/osmo_bsc_rf.c
@@ -39,7 +39,8 @@
#define RF_CMD_QUERY '?'
#define RF_CMD_OFF '0'
#define RF_CMD_ON '1'
-#define RF_CMD_GRACE 'g'
+#define RF_CMD_D_OFF 'd'
+#define RF_CMD_ON_G 'g'
static int lock_each_trx(struct gsm_network *net, int lock)
{
@@ -55,25 +56,9 @@
return 0;
}
-/*
- * Send a '1' when one TRX is online, otherwise send 0
- */
-static void handle_query(struct osmo_bsc_rf_conn *conn)
+static void send_resp(struct osmo_bsc_rf_conn *conn, char send)
{
struct msgb *msg;
- struct gsm_bts *bts;
- char send = RF_CMD_OFF;
-
- llist_for_each_entry(bts, &conn->rf->gsm_network->bts_list, list) {
- struct gsm_bts_trx *trx;
- llist_for_each_entry(trx, &bts->trx_list, list) {
- if (trx->nm_state.availability == NM_AVSTATE_OK &&
- trx->nm_state.operational != NM_STATE_LOCKED) {
- send = RF_CMD_ON;
- break;
- }
- }
- }
msg = msgb_alloc(10, "RF Query");
if (!msg) {
@@ -93,6 +78,35 @@
return;
}
+
+/*
+ * Send a
+ * 'g' when we are in grace mode
+ * '1' when one TRX is online,
+ * '0' otherwise
+ */
+static void handle_query(struct osmo_bsc_rf_conn *conn)
+{
+ struct gsm_bts *bts;
+ char send = RF_CMD_OFF;
+
+ if (conn->rf->policy == S_RF_GRACE)
+ return send_resp(conn, RF_CMD_ON_G);
+
+ llist_for_each_entry(bts, &conn->rf->gsm_network->bts_list, list) {
+ struct gsm_bts_trx *trx;
+ llist_for_each_entry(trx, &bts->trx_list, list) {
+ if (trx->nm_state.availability == NM_AVSTATE_OK &&
+ trx->nm_state.operational != NM_STATE_LOCKED) {
+ send = RF_CMD_ON;
+ break;
+ }
+ }
+ }
+
+ send_resp(conn, send);
+}
+
static void send_signal(struct osmo_bsc_rf *rf, int val)
{
struct rf_signal_data sig;
@@ -152,7 +166,7 @@
case RF_CMD_QUERY:
handle_query(conn);
break;
- case RF_CMD_OFF:
+ case RF_CMD_D_OFF:
bsc_del_timer(&conn->rf->grace_timeout);
switch_rf_off(conn->rf);
break;
@@ -161,7 +175,7 @@
lock_each_trx(conn->rf->gsm_network, 0);
send_signal(conn->rf, S_RF_ON);
break;
- case RF_CMD_GRACE:
+ case RF_CMD_OFF:
enter_grace(conn);
break;
default: