kopia lustrzana https://github.com/jgromes/RadioLib
[RF69] Implement finishReceive
rodzic
2481649e97
commit
290e201a3b
|
@ -122,9 +122,12 @@ int16_t RF69::transmit(const uint8_t* data, size_t len, uint8_t addr) {
|
||||||
return(finishTransmit());
|
return(finishTransmit());
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t RF69::receive(uint8_t* data, size_t len) {
|
int16_t RF69::receive(uint8_t* data, size_t len, RadioLibTime_t timeout) {
|
||||||
// calculate timeout (500 ms + 400 full 64-byte packets at current bit rate)
|
RadioLibTime_t timeoutInternal = timeout;
|
||||||
RadioLibTime_t timeout = 500 + (1.0f/(this->bitRate))*(RADIOLIB_RF69_MAX_PACKET_LENGTH*400.0f);
|
if(!timeoutInternal) {
|
||||||
|
// calculate timeout (500 ms + 400 full 64-byte packets at current bit rate)
|
||||||
|
timeoutInternal = 500 + (1.0f/(this->bitRate))*(RADIOLIB_RF69_MAX_PACKET_LENGTH*400.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// start reception
|
// start reception
|
||||||
int16_t state = startReceive();
|
int16_t state = startReceive();
|
||||||
|
@ -135,9 +138,7 @@ int16_t RF69::receive(uint8_t* data, size_t len) {
|
||||||
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
|
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
|
||||||
this->mod->hal->yield();
|
this->mod->hal->yield();
|
||||||
|
|
||||||
if(this->mod->hal->millis() - start > timeout) {
|
if(this->mod->hal->millis() - start > timeoutInternal) {
|
||||||
standby();
|
|
||||||
clearIRQFlags();
|
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,11 +528,13 @@ class RF69: public PhysicalLayer {
|
||||||
/*!
|
/*!
|
||||||
\brief Blocking binary receive method.
|
\brief Blocking binary receive method.
|
||||||
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
||||||
\param data Binary data to be sent.
|
\param data Pointer to array to save the received binary data.
|
||||||
\param len Number of bytes to send.
|
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
|
||||||
|
\param timeout Reception timeout in milliseconds. If set to 0,
|
||||||
|
timeout period will be calculated automatically based on the radio configuration.
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t receive(uint8_t* data, size_t len) override;
|
int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the module to sleep mode.
|
\brief Sets the module to sleep mode.
|
||||||
|
|
Ładowanie…
Reference in New Issue