aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmobts_sock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmobts_sock.cpp')
-rw-r--r--src/osmobts_sock.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index 577d41eb..9e4000a0 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -55,7 +55,23 @@ struct pcu_sock_state {
struct llist_head upqueue; /* queue for sending messages */
} *pcu_sock_state = NULL;
-static void pcu_sock_timeout(void *_priv);
+static void pcu_sock_timeout(void *_priv)
+{
+ pcu_l1if_open();
+}
+
+static void pcu_tx_txt_retry(void *_priv)
+{
+ struct gprs_rlcmac_bts *bts = bts_main_data();
+ struct pcu_sock_state *state = pcu_sock_state;
+
+ if (bts->active)
+ return;
+
+ LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
+ pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+ osmo_timer_schedule(&state->timer, 5, 0);
+}
int pcu_sock_send(struct msgb *msg)
{
@@ -268,7 +284,7 @@ int pcu_l1if_open(void)
pcu_sock_state = state;
close(bfd->fd);
bfd->fd = -1;
- state->timer.cb = pcu_sock_timeout;
+ osmo_timer_setup(&state->timer, pcu_sock_timeout, NULL);
osmo_timer_schedule(&state->timer, 5, 0);
return 0;
}
@@ -293,6 +309,10 @@ int pcu_l1if_open(void)
LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION);
pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION);
+ /* Schedule a timer so we keep trying until the BTS becomes active. */
+ osmo_timer_setup(&state->timer, pcu_tx_txt_retry, NULL);
+ osmo_timer_schedule(&state->timer, 5, 0);
+
return 0;
}
@@ -312,8 +332,3 @@ void pcu_l1if_close(void)
talloc_free(state);
pcu_sock_state = NULL;
}
-
-static void pcu_sock_timeout(void *_priv)
-{
- pcu_l1if_open();
-}