From 11081e0459f303518350b195b9d1c54b415eb6d7 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Tue, 3 Mar 2015 16:20:18 -0500 Subject: [PATCH] finish gProxII_Demod --- common/lfdemod.c | 23 ++++++++++++++++++++++- common/lfdemod.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/common/lfdemod.c b/common/lfdemod.c index bee87ece..144cb327 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -354,7 +354,6 @@ void askAmp(uint8_t *BitStream, size_t size) //by marshmellow //takes 3 arguments - clock, invert and maxErr as integers //attempts to demodulate ask only -//prints binary found and saves in graphbuffer for further commands int askrawdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr, uint8_t amp) { uint32_t i; @@ -501,6 +500,28 @@ int askrawdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int max } return bestErrCnt; } + +// demod gProxIIDemod +// error returns as -x +// success returns start position in BitStream +// BitStream must contain previously askrawdemod and biphasedemoded data +int gProxII_Demod(uint8_t BitStream[], size_t *size) +{ + size_t startIdx=0; + uint8_t preamble[] = {1,1,1,1,1,0}; + + uint8_t errChk = preambleSearch(BitStream, preamble, sizeof(preamble), size, &startIdx); + if (errChk == 0) return -3; //preamble not found + if (*size != 96) return -2; //should have found 96 bits + //check first 6 spacer bits to verify format + if (!BitStream[startIdx+5] && !BitStream[startIdx+10] && !BitStream[startIdx+15] && !BitStream[startIdx+20] && !BitStream[startIdx+25] && !BitStream[startIdx+30]){ + //confirmed proper separator bits found + //return start position + return (int) startIdx; + } + return -5; +} + //translate wave to 11111100000 (1 for each short wave 0 for each long wave) size_t fsk_wave_demod(uint8_t * dest, size_t size, uint8_t fchigh, uint8_t fclow) { diff --git a/common/lfdemod.h b/common/lfdemod.h index 9d55d064..23525a48 100644 --- a/common/lfdemod.h +++ b/common/lfdemod.h @@ -22,6 +22,7 @@ int ManchesterEncode(uint8_t *BitStream, size_t size); int manrawdecode(uint8_t *BitStream, size_t *size); int BiphaseRawDecode(uint8_t * BitStream, size_t *size, int offset, int invert); int askrawdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr, uint8_t amp); +int gProxII_Demod(uint8_t BitStream[], size_t *size); int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo); int IOdemodFSK(uint8_t *dest, size_t size); int fskdemod(uint8_t *dest, size_t size, uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow); -- 2.39.2