[CC1101] Fixed blocking receive always returning timeout (#348)
This commit is contained in:
parent
4086afa691
commit
304e876c02
2 changed files with 5 additions and 13 deletions
|
@ -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!"));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue