summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-09-07 01:14:14 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-11-29 16:11:27 +0000
commitdb9198d23636006f90389be9eea89caf9457136e (patch)
treec3556d69770822954edc92733108b98ec319ddc7 /src
parente5c385fbc041f6cab4c32668027719a2b0e6d7ab (diff)
trxcon/trx_if.c: add SETFH CTRL command support
The idea of SETFH command is to instruct transceiver to enable frequency hopping mode using the following parameters: CMD SETFH <HSN> <MAIO> <CH1> <CH2> [... <CHN>] Note: since the length of a CTRL command is limited to 128 symbols (BTW: why?), the amount of channels is also limited. Change-Id: Id3d44e6a2796f1ce8523a49dedd5d484052a5c7f
Diffstat (limited to 'src')
-rw-r--r--src/host/trxcon/trx_if.c44
-rw-r--r--src/host/trxcon/trx_if.h2
2 files changed, 46 insertions, 0 deletions
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index b8bbace..982fb40 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -391,6 +391,50 @@ int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta)
return trx_ctrl_cmd(trx, 0, "SETTA", "%d", ta);
}
+/*
+ * Frequency Hopping parameters indication
+ *
+ * SETFH instructs transceiver to enable frequency
+ * hopping mode using the given parameters.
+ * CMD SETFH <HSN> <MAIO> <CH1> <CH2> [... <CHN>]
+ */
+
+int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn,
+ uint8_t maio, uint16_t *ma, size_t ma_len)
+{
+ char ma_buf[100];
+ char *ptr;
+ int i, rc;
+
+ /* No channels, WTF?!? */
+ if (!ma_len)
+ return -EINVAL;
+
+ /**
+ * Compose a sequence of channels (mobile allocation)
+ * FIXME: the length of a CTRL command is limited to 128 symbols,
+ * so we may have some problems if there are many channels...
+ */
+ for (i = 0, ptr = ma_buf; i < ma_len; i++) {
+ /* Append a channel */
+ rc = snprintf(ptr, ma_buf + sizeof(ma_buf) - ptr, "%u ", ma[i]);
+ if (rc < 0)
+ return rc;
+
+ /* Move pointer */
+ ptr += rc;
+
+ /* Prevent buffer overflow */
+ if (ptr >= (ma_buf + 100))
+ return -EIO;
+ }
+
+ /* Overwrite the last space */
+ *(ptr - 1) = '\0';
+
+ return trx_ctrl_cmd(trx, 1, "SETFH", "%u %u %s", hsn, maio, ma_buf);
+}
+
/* Get response from CTRL socket */
static int trx_ctrl_read_cb(struct osmo_fd *ofd, unsigned int what)
{
diff --git a/src/host/trxcon/trx_if.h b/src/host/trxcon/trx_if.h
index be0d41a..d551252 100644
--- a/src/host/trxcon/trx_if.h
+++ b/src/host/trxcon/trx_if.h
@@ -67,6 +67,8 @@ int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn);
int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn);
int trx_if_cmd_setslot(struct trx_instance *trx, uint8_t tn, uint8_t type);
+int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn,
+ uint8_t maio, uint16_t *ma, size_t ma_len);
int trx_if_cmd_measure(struct trx_instance *trx,
uint16_t band_arfcn_start, uint16_t band_arfcn_stop);