[CC1101] Fixed blocking receive always returning timeout (#348)

pull/358/head
jgromes 2021-08-18 17:23:08 +02:00
rodzic 4086afa691
commit 304e876c02
2 zmienionych plików z 5 dodań i 13 usunięć

Wyświetl plik

@ -77,6 +77,10 @@ void loop() {
Serial.print(F("[CC1101] LQI:\t\t"));
Serial.println(radio.getLQI());
} else if (state == ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet
Serial.println(F("timeout!"));
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));

Wyświetl plik

@ -144,7 +144,7 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
int16_t state = startReceive();
RADIOLIB_ASSERT(state);
// wait for sync word or timeout
// wait for packet or timeout
uint32_t start = Module::micros();
while(!Module::digitalRead(_mod->getIrq())) {
Module::yield();
@ -156,18 +156,6 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
}
}
// wait for packet end or timeout
start = Module::micros();
while(Module::digitalRead(_mod->getIrq())) {
Module::yield();
if(Module::micros() - start > timeout) {
standby();
SPIsendCommand(CC1101_CMD_FLUSH_TX);
return(ERR_RX_TIMEOUT);
}
}
// read packet data
return(readData(data, len));
}