This commit is contained in:
iceman1001 2015-01-06 20:51:11 +01:00
commit bf8328e928

View file

@ -592,17 +592,17 @@ uint32_t bytebits_to_byte(uint8_t* src, int numbits)
int IOdemodFSK(uint8_t *dest, size_t size) int IOdemodFSK(uint8_t *dest, size_t size)
{ {
static const uint8_t THRESHOLD = 140;
uint32_t idx=0; uint32_t idx=0;
//make sure buffer has data //make sure buffer has data
if (size < 66) return -1; if (size < 66) return -1;
//test samples are not just noise //test samples are not just noise
uint8_t testMax=0; uint8_t justNoise = 1;
for(idx=0;idx<65;idx++){ for(idx=0;idx< size && justNoise ;idx++){
if (testMax<dest[idx]) testMax=dest[idx]; justNoise = dest[idx] < THRESHOLD;
} }
idx=0; if(justNoise) return 0;
//if not just noise
if (testMax>20){
// FSK demodulator // FSK demodulator
size = fskdemod(dest, size,64,1,10,8); // RF/64 and invert size = fskdemod(dest, size,64,1,10,8); // RF/64 and invert
if (size < 65) return -1; //did we get a good demod? if (size < 65) return -1; //did we get a good demod?
@ -626,7 +626,6 @@ int IOdemodFSK(uint8_t *dest, size_t size)
} }
} }
} }
}
return 0; return 0;
} }