Got ack payloads working. Renamed from 'ackpacket'
This commit is contained in:
parent
39b15c8b55
commit
ffc7d099ed
33
RF24.cpp
33
RF24.cpp
|
@ -202,7 +202,7 @@ void RF24::print_observe_tx(uint8_t value)
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
RF24::RF24(uint8_t _cepin, uint8_t _cspin):
|
RF24::RF24(uint8_t _cepin, uint8_t _cspin):
|
||||||
ce_pin(_cepin), csn_pin(_cspin), payload_size(32), ack_packet_available(false)
|
ce_pin(_cepin), csn_pin(_cspin), payload_size(32), ack_payload_available(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,17 +371,13 @@ boolean RF24::write( const void* buf, uint8_t len )
|
||||||
|
|
||||||
IF_SERIAL_DEBUG(Serial.print(result?"...OK.":"...Failed"));
|
IF_SERIAL_DEBUG(Serial.print(result?"...OK.":"...Failed"));
|
||||||
|
|
||||||
ack_packet_available = ( status & _BV(RX_DR) );
|
ack_payload_available = ( status & _BV(RX_DR) );
|
||||||
uint8_t pl_len = 0;
|
if ( ack_payload_available )
|
||||||
if ( ack_packet_available )
|
|
||||||
{
|
{
|
||||||
write_register(STATUS,_BV(RX_DR) );
|
write_register(STATUS,_BV(RX_DR) );
|
||||||
csn(LOW);
|
ack_payload_length = read_payload_length();
|
||||||
SPI.transfer( R_RX_PL_WID );
|
|
||||||
pl_len = SPI.transfer(0xff);
|
|
||||||
csn(HIGH);
|
|
||||||
IF_SERIAL_DEBUG(Serial.print("[AckPacket]/"));
|
IF_SERIAL_DEBUG(Serial.print("[AckPacket]/"));
|
||||||
IF_SERIAL_DEBUG(Serial.println(pl_len,DEC));
|
IF_SERIAL_DEBUG(Serial.println(ack_payload_length,DEC));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yay, we are done.
|
// Yay, we are done.
|
||||||
|
@ -398,6 +394,21 @@ boolean RF24::write( const void* buf, uint8_t len )
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
|
||||||
|
uint8_t RF24::read_payload_length(void)
|
||||||
|
{
|
||||||
|
uint8_t result = 0;
|
||||||
|
|
||||||
|
csn(LOW);
|
||||||
|
SPI.transfer( R_RX_PL_WID );
|
||||||
|
result = SPI.transfer(0xff);
|
||||||
|
csn(HIGH);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
boolean RF24::available(void)
|
boolean RF24::available(void)
|
||||||
|
@ -552,8 +563,8 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len)
|
||||||
|
|
||||||
boolean RF24::isAckPayloadAvailable(void)
|
boolean RF24::isAckPayloadAvailable(void)
|
||||||
{
|
{
|
||||||
boolean result = ack_packet_available;
|
boolean result = ack_payload_available;
|
||||||
ack_packet_available = false;
|
ack_payload_available = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
RF24.h
17
RF24.h
|
@ -21,7 +21,8 @@ private:
|
||||||
uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */
|
uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */
|
||||||
uint8_t csn_pin; /**< SPI Chip select */
|
uint8_t csn_pin; /**< SPI Chip select */
|
||||||
uint8_t payload_size; /**< Fixed size of payloads */
|
uint8_t payload_size; /**< Fixed size of payloads */
|
||||||
boolean ack_packet_available; /**< Whether there is an ack packet waiting */
|
boolean ack_payload_available; /**< Whether there is an ack payload waiting */
|
||||||
|
uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +99,17 @@ protected:
|
||||||
* @return Current value of status register
|
* @return Current value of status register
|
||||||
*/
|
*/
|
||||||
uint8_t read_payload(void* buf, uint8_t len) ;
|
uint8_t read_payload(void* buf, uint8_t len) ;
|
||||||
public:
|
|
||||||
|
/**
|
||||||
|
* Read the payload length
|
||||||
|
*
|
||||||
|
* For dynamic payloads, this pulls the size of the payload off
|
||||||
|
* the chip
|
||||||
|
*
|
||||||
|
* @return Payload length of last-received dynamic payload
|
||||||
|
*/
|
||||||
|
uint8_t read_payload_length(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty the receive buffer
|
* Empty the receive buffer
|
||||||
*
|
*
|
||||||
|
@ -112,7 +123,7 @@ public:
|
||||||
* @return Current value of status register
|
* @return Current value of status register
|
||||||
*/
|
*/
|
||||||
uint8_t flush_tx(void);
|
uint8_t flush_tx(void);
|
||||||
protected:
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the current status of the chip
|
* Retrieve the current status of the chip
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue