view libgsmhr1/sid_detect.c @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents aaf4dec8bee0
children
line wrap: on
line source

/*
 * The function in this module implements detection of perfect, error-free
 * HRv1 SID frames in TS 101 318 raw packed format.  If SID is detected,
 * the return value is 2: the code for valid SID per GSM 06.41.
 */

#include <stdint.h>
#include <string.h>
#include "tw_gsmhr.h"

int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload)
{
	static const uint8_t all_ff_bytes[9] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
						0xFF, 0xFF, 0xFF, 0xFF};

	if ((payload[4] & 0x7F) != 0x7F)
		return 0;
	if (memcmp(payload + 5, all_ff_bytes, 9) == 0)
		return 2;
	else
		return 0;
}