According to the datasheet, dynamic payloads take less time to transmit. This library doesn't seem to like using them. I imagine that keeping dynamic payloads disabled by default increases cohesion with the nature of not-so-dynamically-sized arrays in C++. Although the examples for dynamic payloads appropriately use an array that allocates 33 bytes (32 for nRF24L01's maximum payload size + 1 NULL terminating character for "easy printing" as a C-string). Most other nRF24L01 libraries take advantage of this basic dynamic payloads feature.
and also set dynamic_payloads_enabled private member to true in RF24::RF24() constructor.
Additional context
Enabling this would also reduce the need for a separate example on how to use dynamic payloads. The only difference at that point would be to add a comment that notes using getPayloadSize() instead of getDynamicPayloadSize() when dynamic payloads are disabled. This library already appends statically sized payloads with zeros to fill the TX FIFO levels accordingly. Of course setPayloadSize() would also need to be mentioned when dynamic payloads are disabled (which is rarely used in the current examples).
According to the datasheet, dynamic payloads take less time to transmit. This library doesn't seem to like using them. I imagine that keeping dynamic payloads disabled by default increases cohesion with the nature of not-so-dynamically-sized arrays in C++. Although the examples for dynamic payloads appropriately use an array that allocates 33 bytes (32 for nRF24L01's maximum payload size + 1 NULL terminating character for "easy printing" as a C-string). Most other nRF24L01 libraries take advantage of this basic dynamic payloads feature.
Suggested changes
in
RF24::begin()
, changeto
and also set
dynamic_payloads_enabled
private member totrue
inRF24::RF24()
constructor.Additional context
Enabling this would also reduce the need for a separate example on how to use dynamic payloads. The only difference at that point would be to add a comment that notes using
getPayloadSize()
instead ofgetDynamicPayloadSize()
when dynamic payloads are disabled. This library already appends statically sized payloads with zeros to fill the TX FIFO levels accordingly. Of coursesetPayloadSize()
would also need to be mentioned when dynamic payloads are disabled (which is rarely used in the current examples).RF24Network also uses dynamic payloads, but I found this vague comment:
@TMRh20 I have no idea what modules this could be referring to.