FreeCalypso > hg > e1-fake-trau
diff ft16/tx_func.c @ 2:5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Aug 2024 13:07:16 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ft16/tx_func.c Thu Aug 29 13:07:16 2024 +0000 @@ -0,0 +1,57 @@ +/* + * 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 <osmocom/trau/trau_frame.h> + +#include "globals.h" +#include "submux.h" +#include "dl_frames.h" + +static void tx_service_subslot(int nr) +{ + struct abis_subslot *ab = &subslots[nr]; + const uint8_t *srcbuf; + struct msgb *msg; + uint8_t *outbuf; + + if (!ab->got_sync) + return; + switch (ab->frame_type) { + case TRAU_FT_FR_UP: + srcbuf = dl_frame_fr; + break; + case TRAU_FT_EFR: + srcbuf = dl_frame_efr; + break; + default: + 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, srcbuf, 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); +}