Change in osmo-bts[master]: tx_power: send CTRL TRAP when power ramping is completed

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Sun Nov 7 01:09:17 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/26140 )


Change subject: tx_power: send CTRL TRAP when power ramping is completed
......................................................................

tx_power: send CTRL TRAP when power ramping is completed

Change-Id: I747e1715e316999a6fb0c25275d9a86f42b5858d
---
M include/osmo-bts/gsm_data.h
M src/common/Makefile.am
M src/common/main.c
M src/common/tx_power.c
M tests/stubs.c
5 files changed, 29 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/40/26140/1

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index dcb357f..6660060 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -46,6 +46,7 @@
 	unsigned int num_bts;
 	struct osmo_plmn_id plmn;
 	struct pcu_sock_state *pcu_state;
+	struct ctrl_handle *ctrl;
 };
 
 /* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 35df73e..f0c6ebb 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -7,12 +7,14 @@
 AM_CFLAGS = \
 	-Wall \
 	$(LIBOSMOCORE_CFLAGS) \
+	$(LIBOSMOCTRL_CFLAGS) \
 	$(LIBOSMOTRAU_CFLAGS) \
 	$(LIBOSMOCODEC_CFLAGS) \
 	$(NULL)
 
 LDADD = \
 	$(LIBOSMOCORE_LIBS) \
+	$(LIBOSMOCTRL_LIBS) \
 	$(LIBOSMOTRAU_LIBS) \
 	$(LIBOSMOCODEC_LIBS) \
 	$(NULL)
diff --git a/src/common/main.c b/src/common/main.c
index b5ba21b..b47dc0a 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -59,6 +59,8 @@
 #include <osmocom/ctrl/control_vty.h>
 #include <osmo-bts/oml.h>
 
+extern struct gsm_network bts_gsmnet;
+
 static int quit = 0;
 static const char *config_file = "osmo-bts.cfg";
 static int daemonize = 0;
@@ -384,7 +386,12 @@
 		gsmtap_source_add_sink(g_bts->gsmtap.inst);
 	}
 
-	bts_controlif_setup(g_bts, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_BTS);
+	bts_gsmnet.ctrl = bts_controlif_setup(g_bts, ctrl_vty_get_bind_addr(),
+					       OSMO_CTRL_PORT_BTS);
+	if (bts_gsmnet.ctrl == NULL) {
+		fprintf(stderr, "Error initializing the control interface\n");
+		exit(1);
+	}
 
 	rc = telnet_init_dynif(tall_bts_ctx, NULL, vty_get_bind_addr(),
 			       g_vty_port_num);
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index 0307422..5e86af0 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -24,12 +24,16 @@
 #include <errno.h>
 
 #include <osmocom/core/utils.h>
+#include <osmocom/ctrl/control_if.h>
 
 #include <osmo-bts/logging.h>
 #include <osmo-bts/gsm_data.h>
 #include <osmo-bts/bts_model.h>
 #include <osmo-bts/tx_power.h>
 #include <osmo-bts/bts_trx.h>
+#include <osmo-bts/bts.h>
+
+extern struct gsm_network bts_gsmnet;
 
 static int get_pa_drive_level_mdBm(const struct power_amp *pa,
 		       int desired_p_out_mdBm, unsigned int arfcn)
@@ -212,6 +216,16 @@
 
 	/* we had finished in last loop iteration */
 	if (!first && tpp->ramp.attenuation_mdB == 0) {
+		char *name = talloc_asprintf(trx, "bts.%u.trx.%u.power-ramping-completed",
+					     trx->bts->nr, trx->nr);
+		/* FIXME: we always get "down" here */
+		const char *dir = we_are_ramping_up(trx) ? "up" : "down";
+
+		LOGPTRX(trx, DL1C, LOGL_INFO, "Power ramping (%s) completed\n", dir);
+
+		ctrl_cmd_send_trap(bts_gsmnet.ctrl, name, (char *)dir);
+		talloc_free(name);
+
 		if (tpp->ramp.compl_cb)
 			tpp->ramp.compl_cb(trx);
 		return;
diff --git a/tests/stubs.c b/tests/stubs.c
index b24dfc9..a8c4f6c 100644
--- a/tests/stubs.c
+++ b/tests/stubs.c
@@ -72,3 +72,7 @@
 
 int bts_model_phy_link_open(struct phy_link *plink)
 { return 0; }
+
+struct ctrl_handle;
+int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value)
+{ return 0; }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/26140
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I747e1715e316999a6fb0c25275d9a86f42b5858d
Gerrit-Change-Number: 26140
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211107/cd293233/attachment.htm>


More information about the gerrit-log mailing list