aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/misc/sysmobts_misc.c
diff options
context:
space:
mode:
authorÁlvaro Neira Ayuso <anayuso@sysmocom.de>2014-05-17 11:01:13 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-05-18 09:42:49 +0200
commitc64d42573894d8295b58b268a64541c914b69bcd (patch)
tree6798106526852e2c1f0b3e231727cdded742d1b8 /src/osmo-bts-sysmo/misc/sysmobts_misc.c
parentc5fedd24c96a4ef6d7a0c0ed3c70d6ef0abd5c17 (diff)
sysmobts: Add support for changing the transmit power in sbts2050
Make the sysmobts-mgr send a manufacturer O&M message with the power reduction we want the sysmobts to apply. The sysmobts will handle this message and set the new tx output power. An ACK/NACK will be send as a response to the power reduction. Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
Diffstat (limited to 'src/osmo-bts-sysmo/misc/sysmobts_misc.c')
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.c b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
index 2417c3d9..6277a6bf 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
@@ -58,6 +58,23 @@
#define OM_HEADROOM_SIZE 128
#ifdef BUILD_SBTS2050
+
+static int check_manufacturer_reduce_nach_ack(struct msgb *msg)
+{
+ struct abis_om_fom_hdr *foh = msgb_l3(msg);
+
+ if (foh->msg_type == NM_MT_SET_RADIO_ATTR + 2) { /* NACK */
+ LOGP(DTEMP, LOGL_ERROR, "Reduce Power: Received a BTS NACK\n");
+ return -1;
+ } else if (foh->msg_type != NM_MT_SET_RADIO_ATTR + 1) { /* ACK */
+ LOGP(DTEMP, LOGL_ERROR, "Unknown message type %d\n",
+ foh->msg_type);
+ return -1;
+ }
+
+ return 0;
+}
+
static void add_sw_descr(struct msgb *msg)
{
char file_version[255];
@@ -112,6 +129,61 @@ static void add_oml_hdr_msg(struct msgb *msg, uint8_t msg_type,
omh->length = msgb_l3len(msg);
}
+int send_manufacturer_reduce_msg(int fd_unix, int reduce_power, int trx_nr)
+{
+ int rc;
+ struct msgb *msg;
+
+ msg = msgb_alloc_headroom(OM_ALLOC_SIZE, OM_HEADROOM_SIZE, "OML");
+ if (msg == NULL) {
+ LOGP(DTEMP, LOGL_ERROR, "Error creating oml msg\n");
+ return -1;
+ }
+
+ add_oml_hdr_msg(msg, NM_MT_SET_RADIO_ATTR, 2, 0, trx_nr, 255, 1);
+
+ msgb_tv_put(msg, NM_ATT_O_REDUCEPOWER, reduce_power);
+
+ prepend_oml_ipa_header(msg);
+
+ rc = send(fd_unix, msg->data, msg->len, 0);
+ if (rc < 0 || rc != msg->len) {
+ LOGP(DTEMP, LOGL_ERROR,
+ "send error %s during Reduce Manufacturer O&M msg send\n",
+ strerror(errno));
+ goto err;
+ }
+
+ msgb_reset(msg);
+ rc = recv(fd_unix, msg->tail, msg->data_len, 0);
+ if (rc <= 0) {
+ LOGP(DTEMP, LOGL_ERROR, "recv error %s during ACK/NACK recv\n",
+ strerror(errno));
+ goto err;
+ }
+ msgb_put(msg, rc);
+
+ if (check_oml_msg(msg) < 0) {
+ close(fd_unix);
+ msgb_free(msg);
+ return -1;
+ }
+
+ if (check_manufacturer_reduce_nach_ack(msg) < 0) {
+ close(fd_unix);
+ msgb_free(msg);
+ return -1;
+ }
+
+ msgb_free(msg);
+ return SYSMO_MGR_CONNECTED;
+
+err:
+ close(fd_unix);
+ msgb_free(msg);
+ return SYSMO_MGR_DISCONNECTED;
+}
+
int send_omlfailure(int fd_unix, enum sbts2050_alert_lvl alert,
enum sbts2050_temp_sensor sensor,
struct sbts2050_config_info *add_info, int trx_nr)