FreeCalypso > hg > gsm-codec-lib
view efrtest/dlcap-gsmx.c @ 604:54f0f1b74c25
libgsmhr1 TFO: require BFI=0 and SID=0 for homing
In order for a received frame to be recognized as DHF, we need
not only the correct bit pattern, but also BFI=0 and SID=0.
The BFI=0 requirement should be obvious, while the SID=0 requirement
is needed only for HR codec. With FR and EFR, SID classification
comes from the payload bits and no separate check is needed -
but in HR we get an out-of-band SID ternary flag. When SID=1,
no payload bits are used at all; when SID=2, we use only the first
33 bits of the payload. Therefore, it is proper to conditionalize
DHF acceptance on SID=0.
We already implemented this logic in the just finished full decoder;
now bring TFO code into agreement.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 04 Dec 2025 19:40:35 +0000 |
| parents | 6e39fc0134da |
| children |
line wrap: on
line source
/* * This program reads a TCH/EFS downlink capture produced with FreeCalypso tools * (fw version with TCH downlink sniffing feature and fc-shell tch record) * and converts it into our extended-libgsm binary format, to be further * fed to gsmefr-decode or other tools. */ #include <ctype.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> main(argc, argv) char **argv; { FILE *inf, *outf; char linebuf[128]; int lineno, rc; uint16_t status_words[3]; uint8_t tidsp_bytes[33], efr_bytes[31], bfi[2]; unsigned fn_mod_104; if (argc != 3) { fprintf(stderr, "usage: %s infile outfile\n", argv[0]); exit(1); } inf = fopen(argv[1], "r"); if (!inf) { perror(argv[1]); exit(1); } outf = fopen(argv[2], "w"); if (!outf) { perror(argv[2]); exit(1); } for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { /* support both old and new formats */ if (isxdigit(linebuf[0]) && isxdigit(linebuf[1]) && isxdigit(linebuf[2]) && isxdigit(linebuf[3])) { rc = parse_dlcap_common(linebuf, status_words, tidsp_bytes); if (rc < 0) { invalid: fprintf(stderr, "error: %s is not in the expected format\n", argv[1]); exit(1); } fn_mod_104 = 0; /* won't have TAF */ } else if (!strncmp(linebuf, "EFR ", 4)) { rc = parse_dlcap_common(linebuf + 4, status_words, tidsp_bytes); if (rc < 0) goto invalid; if (linebuf[85] != ' ') goto invalid; if (!isdigit(linebuf[86])) goto invalid; fn_mod_104 = strtoul(linebuf + 86, 0, 10); } else goto invalid; /* * DSP flags are documented in the TCH-tap-modes article * in freecalypso-docs. */ if ((status_words[0] & 0xC204) == 0xC000) { efr_tidsp_to_std(tidsp_bytes, efr_bytes); fwrite(efr_bytes, 1, 31, outf); } else { bfi[0] = 0xBF; bfi[1] = fn_mod_104 == 60; fwrite(bfi, 1, 2, outf); } } exit(0); }
