added @marshmellows new viking demod.

adjusted it to fit with the clone/demod  that is under  "lf viking" commands.

did some code clean up,  3spaces into tab.
This commit is contained in:
iceman1001 2015-11-10 11:42:59 +01:00
commit 70459879e9
10 changed files with 273 additions and 300 deletions

View file

@ -599,6 +599,26 @@ int IOdemodFSK(uint8_t *dest, size_t size)
return -5;
}
// by marshmellow
// find viking preamble 0xF200 in already demoded data
int VikingDemod_AM(uint8_t *dest, size_t *size) {
if (justNoise(dest, *size)) return -1;
//make sure buffer has data
if (*size < 64*2) return -2;
size_t startIdx = 0;
uint8_t preamble[] = {1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
if (errChk == 0) return -4; //preamble not found
uint32_t checkCalc = bytebits_to_byte(dest+startIdx,8) ^ bytebits_to_byte(dest+startIdx+8,8) ^ bytebits_to_byte(dest+startIdx+16,8)
^ bytebits_to_byte(dest+startIdx+24,8) ^ bytebits_to_byte(dest+startIdx+32,8) ^ bytebits_to_byte(dest+startIdx+40,8)
^ bytebits_to_byte(dest+startIdx+48,8) ^ bytebits_to_byte(dest+startIdx+56,8);
if ( checkCalc != 0xA8 ) return -5;
if (*size != 64) return -5;
//return start position
return (int) startIdx;
}
// by marshmellow
// takes a array of binary values, start position, length of bits per parity (includes parity bit),
// Parity Type (1 for odd; 0 for even; 2 Always 1's), and binary Length (length to run)
@ -1505,30 +1525,3 @@ int pskRawDemod(uint8_t dest[], size_t *size, int *clock, int *invert)
*size = numBits;
return errCnt;
}
// on successful return 1 otherwise return 0
int VikingDecode(uint8_t *BitStream,
size_t size,
size_t *startIdx,
uint8_t *id_bits,
size_t id_bits_size)
{
//no arguments needed - built this way in case we want this to be a direct call from "data " cmds in the future
// otherwise could be a void with no arguments
//set defaults
uint32_t i = 0;
uint32_t lastcheckindex = size - (id_bits_size * 2);
int found = 0;
while (i < lastcheckindex)
{
if (memcmp(BitStream + i,id_bits,id_bits_size) == 0)
{
*startIdx = i;
found = 1;
break;
}
i++;
}
return found;
}

View file

@ -48,8 +48,8 @@ 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 indala26decode(uint8_t *bitStream, size_t *size, uint8_t *invert);
int PyramiddemodFSK(uint8_t *dest, size_t *size);
int ParadoxdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo);
int VikingDecode(uint8_t *BitStream, size_t size, size_t *startIdx,uint8_t *id_bit,size_t id_bits_size);
int PyramiddemodFSK(uint8_t *dest, size_t *size);
int VikingDemod_AM(uint8_t *dest, size_t *size);
#endif