From 7a743398cf4738e58a7a57f94dc079a6c529829d Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 20 Feb 2008 02:28:51 +0000 Subject: channel decoding (gsmstack) --- gsm-tvoid/src/lib/gsmstack.c | 74 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 gsm-tvoid/src/lib/gsmstack.c (limited to 'gsm-tvoid/src/lib/gsmstack.c') diff --git a/gsm-tvoid/src/lib/gsmstack.c b/gsm-tvoid/src/lib/gsmstack.c new file mode 100644 index 0000000..9fc4868 --- /dev/null +++ b/gsm-tvoid/src/lib/gsmstack.c @@ -0,0 +1,74 @@ +/* + * Invoke gsmstack() with any kind of burst. Automaticly decode and retrieve + * information. + */ +#include "system.h" +#include +#include +#include +#include "gsmstack.h" +#include "gsm_constants.h" +#include "interleave.h" +#include "sch.h" + +INTERLEAVE_CTX ictx; + +static void +diff_decode(char *dst, char *src, int len) +{ + const unsigned char *end = src + len; + unsigned char last; + + src += 3; + last = 0; + memset(dst, 0, 3); + dst += 3; + + while (src < end) + { + *dst = !*src ^ last; + last = *dst; + src++; + dst++; + } +} + +/* + * Initialize a new GSMSTACK context. + */ +int +GS_new(GS_CTX *ctx) +{ + memset(ctx, 0, sizeof *ctx); + interleave_init(&ictx, 456, 114); + + return 0; +} + +/* + * 156 bit + */ +int +GS_process(GS_CTX *ctx, int ts, int type, char *data) +{ + int fn; + int bsic; + int ret; + char buf[156]; + + diff_decode(buf, data, 156); + + switch (type) + { + case SCH: + ret = decode_sch(buf, &fn, &bsic); + if (ret != 0) + break; + DEBUGF("FN %d, BSIC %d\n", fn, bsic); + break; + case NORMAL: + break; + } +} + + -- cgit v1.2.3