FreeCalypso > hg > gsm-codec-lib
comparison libgsmhr1/sid_detect.c @ 494:aaf4dec8bee0
libgsmhr1: implement perfect SID detection
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 17 Jun 2024 23:14:19 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 493:dc7249923b3a | 494:aaf4dec8bee0 |
|---|---|
| 1 /* | |
| 2 * The function in this module implements detection of perfect, error-free | |
| 3 * HRv1 SID frames in TS 101 318 raw packed format. If SID is detected, | |
| 4 * the return value is 2: the code for valid SID per GSM 06.41. | |
| 5 */ | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 #include <string.h> | |
| 9 #include "tw_gsmhr.h" | |
| 10 | |
| 11 int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload) | |
| 12 { | |
| 13 static const uint8_t all_ff_bytes[9] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
| 14 0xFF, 0xFF, 0xFF, 0xFF}; | |
| 15 | |
| 16 if ((payload[4] & 0x7F) != 0x7F) | |
| 17 return 0; | |
| 18 if (memcmp(payload + 5, all_ff_bytes, 9) == 0) | |
| 19 return 2; | |
| 20 else | |
| 21 return 0; | |
| 22 } |
