diff abis/tx_func.c @ 30:5dd30224b70a

abis: starting new program
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Aug 2024 21:38:55 +0000
parents ater/tx_func.c@2742dbea95f1
children 351bd801cdce
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/abis/tx_func.c	Tue Aug 13 21:38:55 2024 +0000
@@ -0,0 +1,45 @@
+/*
+ * Here we are going to implement Tx on Abis toward the BTS.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/isdn/i460_mux.h>
+
+#include "globals.h"
+#include "submux.h"
+#include "dl_frames.h"
+
+static void tx_service_subslot(int nr)
+{
+	struct abis_subslot *ab = &subslots[nr];
+	struct msgb *msg;
+	uint8_t *outbuf;
+
+	if (!ab->is_active)
+		return;
+	msg = msgb_alloc_c(g_ctx, DL_OUTPUT_LEN, "TRAU-DL-frame");
+	if (!msg)
+		return;
+	outbuf = msgb_put(msg, DL_OUTPUT_LEN);
+	memcpy(outbuf, ab->is_efr ? dl_frame_efr : dl_frame_fr, DL_OUTPUT_LEN);
+	osmo_i460_mux_enqueue(ab->schan, msg);
+}
+
+void transmit_e1_ts(void)
+{
+	uint8_t buf[160];
+	int nr;
+
+	for (nr = 0; nr < ABIS_SUBSLOTS; nr++)
+		tx_service_subslot(nr);
+	osmo_i460_mux_out(&i460_ts, buf, 160);
+	write(ts_fd, buf, 160);
+}