summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-12-23 11:13:19 +0100
committerHarald Welte <laforge@gnumonks.org>2019-05-23 13:03:49 +0200
commit5814c01ef12114e2570876c6d8d3034a4e2237be (patch)
treeba4fe8ef93a1f775fb96cd022c714be1bdd6f8fc
parentaf91956163e98078ee71f6c713cd969c0995c6b1 (diff)
Add ringer support to built-in MNCC application of mobilelaforge/jolly_handover_rebased
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/mncc.h6
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/settings.h2
-rw-r--r--src/host/layer23/src/mobile/mnccms.c58
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c31
4 files changed, 97 insertions, 0 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/mncc.h b/src/host/layer23/include/osmocom/bb/mobile/mncc.h
index 8ec9358..b49d6d8 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/mncc.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/mncc.h
@@ -44,6 +44,9 @@ struct gsm_call {
uint8_t dtmf_state;
uint8_t dtmf_index;
char dtmf[32]; /* dtmf sequence */
+
+ struct osmo_timer_list ringer_timer;
+ uint8_t ringer_state;
};
#define DTMF_ST_IDLE 0 /* no DTMF active */
@@ -52,6 +55,9 @@ struct gsm_call {
#define DTMF_ST_STOP 3 /* DTMF stopped, waiting for resp. */
#define DTMF_ST_SPACE 4 /* wait space between tones */
+#define RINGER_MARK 0, 500000
+#define RINGER_SPACE 0, 250000
+
#define MNCC_SETUP_REQ 0x0101
#define MNCC_SETUP_IND 0x0102
#define MNCC_SETUP_RSP 0x0103
diff --git a/src/host/layer23/include/osmocom/bb/mobile/settings.h b/src/host/layer23/include/osmocom/bb/mobile/settings.h
index 03cc2c8..bdc56ff 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/settings.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h
@@ -107,6 +107,8 @@ struct gsm_settings {
/* Timeout for GSM 03.22 C7 state */
uint8_t any_timeout;
+ /* Ring tone */
+ uint8_t ringtone; /* 0 = off */
};
struct gsm_settings_abbrev {
diff --git a/src/host/layer23/src/mobile/mnccms.c b/src/host/layer23/src/mobile/mnccms.c
index 2243291..4edc5f3 100644
--- a/src/host/layer23/src/mobile/mnccms.c
+++ b/src/host/layer23/src/mobile/mnccms.c
@@ -38,6 +38,8 @@ static LLIST_HEAD(call_list);
static int dtmf_statemachine(struct gsm_call *call, struct gsm_mncc *mncc);
static void timeout_dtmf(void *arg);
+static void timeout_ringer(void *arg);
+int mncc_answer(struct osmocom_ms *ms);
/*
* support functions
@@ -60,11 +62,65 @@ static void stop_dtmf_timer(struct gsm_call *call)
}
}
+/* Ringer */
+static void update_ringer(struct gsm_call *call)
+{
+ struct osmocom_ms *ms = call->ms;
+
+ if (call->ring) {
+ struct gsm_settings *set = &ms->settings;
+
+ /* ringer on */
+ if (set->ringtone == 0) {
+ LOGP(DCC, LOGL_INFO, "Ringer disabled\n");
+ return;
+ }
+ if (osmo_timer_pending(&call->ringer_timer))
+ return;
+ LOGP(DCC, LOGL_INFO, "starting Ringer\n");
+ call->ringer_timer.cb = timeout_ringer;
+ call->ringer_timer.data = call;
+ osmo_timer_schedule(&call->ringer_timer, RINGER_MARK);
+ l1ctl_tx_ringer_req(ms, set->ringtone);
+ call->ringer_state = 1;
+ } else {
+ /* ringer off */
+ if (!osmo_timer_pending(&call->ringer_timer))
+ return;
+ LOGP(DCC, LOGL_INFO, "stop Ringer\n");
+ osmo_timer_del(&call->ringer_timer);
+ if (call->ringer_state)
+ l1ctl_tx_ringer_req(ms, 0);
+ }
+}
+
+static void timeout_ringer(void *arg)
+{
+ struct gsm_call *call = arg;
+ struct osmocom_ms *ms = call->ms;
+
+ /* on <-> off */
+ call->ringer_state = 1 - call->ringer_state;
+
+ if (call->ringer_state) {
+ struct gsm_settings *set = &ms->settings;
+
+ osmo_timer_schedule(&call->ringer_timer, RINGER_MARK);
+ l1ctl_tx_ringer_req(ms, set->ringtone);
+ } else {
+ osmo_timer_schedule(&call->ringer_timer, RINGER_SPACE);
+ l1ctl_tx_ringer_req(ms, 0);
+ }
+}
+
/* free call instance */
static void free_call(struct gsm_call *call)
{
stop_dtmf_timer(call);
+ call->ring = 0;
+ update_ringer(call);
+
llist_del(&call->entry);
DEBUGP(DMNCC, "(call %x) Call removed.\n", call->callref);
talloc_free(call);
@@ -481,6 +537,7 @@ int mncc_recv_mobile(struct osmocom_ms *ms, int msg_type, void *arg)
call->hold = true;
}
call->ring = true;
+ update_ringer(call);
memset(&mncc, 0, sizeof(struct gsm_mncc));
mncc.callref = call->callref;
mncc_tx_to_cc(ms, MNCC_ALERT_REQ, &mncc);
@@ -647,6 +704,7 @@ int mncc_answer(struct osmocom_ms *ms)
return -EBUSY;
}
alerting->ring = false;
+ update_ringer(alerting);
alerting->hold = false;
memset(&rsp, 0, sizeof(struct gsm_mncc));
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 334ff65..1519b1b 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -1356,6 +1356,11 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms)
struct gsm_settings_abbrev *abbrev;
vty_out(vty, "ms %s%s", ms->name, VTY_NEWLINE);
+ if (set->ringtone)
+ vty_out(vty, " ringtone %d%s", set->ringtone, VTY_NEWLINE);
+ else
+ if (!hide_default)
+ vty_out(vty, " no ringtone%s", VTY_NEWLINE);
vty_out(vty, " layer2-socket %s%s", set->layer2_socket_path,
VTY_NEWLINE);
vty_out(vty, " sap-socket %s%s", set->sap_socket_path, VTY_NEWLINE);
@@ -2260,6 +2265,30 @@ DEFUN(cfg_ms_no_nb_dedicated, cfg_ms_no_nb_dedicated_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_ms_ringtone, cfg_ms_ringtone_cmd,
+ "ringtone <0-255>",
+ "Enable ring tone\nVolume of ring tone")
+{
+ struct osmocom_ms *ms = vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ set->ringtone = atoi(argv[0]);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_no_ringtone, cfg_ms_no_ringtone_cmd,
+ "no ringtone",
+ NO_MS_NB_STR "Disable Ring tone")
+{
+ struct osmocom_ms *ms = vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ set->ringtone = 0;
+
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_ms_any_timeout, cfg_ms_any_timeout_cmd, "c7-any-timeout <0-255>",
"Seconds to wait in C7 before doing a PLMN search")
{
@@ -2997,6 +3026,8 @@ int ms_vty_init(void)
install_element(MS_NODE, &cfg_ms_no_nb_idle_cmd);
install_element(MS_NODE, &cfg_ms_nb_dedicated_cmd);
install_element(MS_NODE, &cfg_ms_no_nb_dedicated_cmd);
+ install_element(MS_NODE, &cfg_ms_ringtone_cmd);
+ install_element(MS_NODE, &cfg_ms_no_ringtone_cmd);
install_element(MS_NODE, &cfg_ms_any_timeout_cmd);
install_element(MS_NODE, &cfg_ms_sms_store_cmd);
install_element(MS_NODE, &cfg_ms_no_sms_store_cmd);